<commit_before># -*- coding: utf-8 -*-
import os
from nose.tools import with_setup, eq_ as eq, ok_ as ok
from common import vim, cleanup


@with_setup(setup=cleanup)
def test_receiving_events():
    vim.command('call send_event(%d, "test-event", [1,2,3])' % vim.channel_id)
    events = vim.expect('test-event', lambda e: set(e[1]) == set([1, 2, 3]))
    eq(events, [['test-event', [1, 2, 3]]])
    vim.command('au FileType python call send_event(%d, "py!", bufnr("$"))' %
                vim.channel_id)
    vim.command('set filetype=python')
    events = vim.expect('py!', lambda e: e[1] == vim.current.buffer.number)
    eq(events, [['py!', vim.current.buffer.number]])

<commit_msg>Add event broadcast tests<commit_after># -*- coding: utf-8 -*-
import os
from nose.tools import with_setup, eq_ as eq, ok_ as ok
from common import vim, cleanup


@with_setup(setup=cleanup)
def test_receiving_events():
    vim.command('call send_event(%d, "test-event", [1,2,3])' % vim.channel_id)
    events = vim.expect('test-event', lambda e: set(e[1]) == set([1, 2, 3]))
    eq(events, [['test-event', [1, 2, 3]]])
    vim.command('au FileType python call send_event(%d, "py!", bufnr("$"))' %
                vim.channel_id)
    vim.command('set filetype=python')
    events = vim.expect('py!', lambda e: e[1] == vim.current.buffer.number)
    eq(events, [['py!', vim.current.buffer.number]])


@with_setup(setup=cleanup)
def test_broadcast():
    vim.subscribe('event2')
    vim.command('call send_event(0, "event1", [1,2,3])')
    vim.command('call send_event(0, "event2", [4,5,6])')
    vim.command('call send_event(0, "event2", [7,8,9])')
    events = vim.expect('event2', 2, lambda e: e[1][0] == 7)
    eq(events, [['event2', [4, 5, 6]], ['event2', [7, 8, 9]]])
    vim.unsubscribe('event2')
    vim.subscribe('event1')
    vim.command('call send_event(0, "event2", [10,11,12])')
    vim.command('call send_event(0, "event1", [13,14,15])')
    eq(vim.next_event(), ['event1', [13, 14, 15]])


{'fraction_non_alphanumeric': 0.2108706592853548, 'fraction_numerical': 0.03925515853044791, 'mean_word_length': 4.190600522193211, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2929255', 'n_tokens_mistral': 803, 'n_tokens_neox': 755, 'n_words': 170}