<commit_before>
import pytest

from barython.hooks import HooksPool, _Hook


def test_base_hooks_pool_subscribe():
    def callback():
        pass

    hp = HooksPool()
    hp.subscribe(callback, _Hook)


def test_base_hooks_pool_subscribe_listen():
    def callback():
        pass

    hp = HooksPool(listen=True)
    hp.subscribe(callback, _Hook)


def test_base_hooks_pool_merge():
    def callback0():
        pass

    def callback1():
        pass

    hp0, hp1 = HooksPool(), HooksPool()
    hp0.subscribe(callback0, _Hook)
    hp1.subscribe(callback1, _Hook)

    hp0.merge(hp1)
    assert hp0.hooks[_Hook].callbacks == {callback0, callback1}
<commit_msg>Add tests for hooks<commit_after>
import pytest

from barython.hooks import HooksPool, _Hook


def test_base_hook_notify(mocker):
    """
    Test _Hook.notify
    """
    stub = mocker.stub()
    hook = _Hook(callbacks={stub, })
    hook.notify()
    stub.assert_called_once_with()


def test_base_hook_notify_without_callback(mocker):
    hook = _Hook()
    hook.notify()


def test_base_hooks_pool_subscribe():
    def callback():
        pass

    hp = HooksPool()
    hp.subscribe(callback, _Hook)


def test_base_hooks_pool_subscribe_listen():
    def callback():
        pass

    hp = HooksPool(listen=True)
    hp.subscribe(callback, _Hook)


def test_base_hooks_pool_merge():
    def callback0():
        pass

    def callback1():
        pass

    hp0, hp1 = HooksPool(), HooksPool()
    hp0.subscribe(callback0, _Hook)
    hp1.subscribe(callback1, _Hook)

    hp0.merge(hp1)
    assert hp0.hooks[_Hook].callbacks == {callback0, callback1}

{'fraction_non_alphanumeric': 0.10636982065553494, 'fraction_numerical': 0.016079158936301793, 'mean_word_length': 3.2578947368421054, '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': '1996381', 'n_tokens_mistral': 574, 'n_tokens_neox': 553, 'n_words': 112}