<commit_before>from ..dispatcher import Dispatcher
import unittest


class TestDispatcher(unittest.TestCase):

    """ Test Dispatcher functionality."""

    def test_getter(self):
        d = Dispatcher()

        with self.assertRaises(KeyError):
            d["method"]

        d["add"] = lambda *args: sum(args)
        self.assertEqual(d["add"](1, 1), 2)

    def test_in(self):
        d = Dispatcher()
        d["method"] = lambda: ""
        self.assertIn("method", d)

    def test_add_method(self):
        d = Dispatcher()

        @d.add_method
        def add(x, y):
            return x + y

        self.assertIn("add", d)
        self.assertEqual(d["add"](1, 1), 2)

    def test_to_dict(self):
        d = Dispatcher()
        func = lambda: ""
        d["method"] = func
        self.assertEqual(dict(d), {"method": func})<commit_msg>cover dispatcher functionality with tests<commit_after>from ..dispatcher import Dispatcher
import unittest


class TestDispatcher(unittest.TestCase):

    """ Test Dispatcher functionality."""

    def test_getter(self):
        d = Dispatcher()

        with self.assertRaises(KeyError):
            d["method"]

        d["add"] = lambda *args: sum(args)
        self.assertEqual(d["add"](1, 1), 2)

    def test_in(self):
        d = Dispatcher()
        d["method"] = lambda: ""
        self.assertIn("method", d)

    def test_add_method(self):
        d = Dispatcher()

        @d.add_method
        def add(x, y):
            return x + y

        self.assertIn("add", d)
        self.assertEqual(d["add"](1, 1), 2)

    def test_del_method(self):
        d = Dispatcher()
        d["method"] = lambda: ""
        self.assertIn("method", d)

        del d["method"]
        self.assertNotIn("method", d)

    def test_to_dict(self):
        d = Dispatcher()
        func = lambda: ""
        d["method"] = func
        self.assertEqual(dict(d), {"method": func})
{'fraction_non_alphanumeric': 0.14672216441207075, 'fraction_numerical': 0.006243496357960458, 'mean_word_length': 2.2157190635451505, 'pattern_counts': {'":': 2, '<': 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': '2741088', 'n_tokens_mistral': 627, 'n_tokens_neox': 581, 'n_words': 135}