<commit_before>import unittest

from multimethods import MultiMethod, method


class NamespaceTests(unittest.TestCase):
    def test_definition_ns_required(self):
        self.assertRaises(TypeError, MultiMethod, 'definition', lambda value: value)

    def test_decorator_ns_required(self):
        MultiMethod('decorator', lambda value: value, ns='custom')

        try:
            @method(1)
            def decorator(value):
                pass
        except TypeError:
            pass
        else:
            self.fail('method decorator does not require namespace')

    def test_definition(self):
        MultiMethod('definition', lambda value: value, ns='custom')
        assert MultiMethod.instances.get('custom.definition'), "namespace is not 'custom'"

    def test_installed_methods(self):
        MultiMethod('installing', lambda value: value, ns='custom')

        try:
            @method(1, ns='custom')
            def installing(value):
                pass
        except KeyError:
            self.fail('not installing multimethods within namespace')<commit_msg>Make tests executable from the command line<commit_after>import unittest

from multimethods import MultiMethod, method


class NamespaceTests(unittest.TestCase):
    def test_definition_ns_required(self):
        self.assertRaises(TypeError, MultiMethod, 'definition', lambda value: value)

    def test_decorator_ns_required(self):
        MultiMethod('decorator', lambda value: value, ns='custom')

        try:
            @method(1)
            def decorator(value):
                pass
        except TypeError:
            pass
        else:
            self.fail('method decorator does not require namespace')

    def test_definition(self):
        MultiMethod('definition', lambda value: value, ns='custom')
        assert MultiMethod.instances.get('custom.definition'), "namespace is not 'custom'"

    def test_installed_methods(self):
        MultiMethod('installing', lambda value: value, ns='custom')

        try:
            @method(1, ns='custom')
            def installing(value):
                pass
        except KeyError:
            self.fail('not installing multimethods within namespace')

if __name__ == '__main__':
    unittest.main()
{'fraction_non_alphanumeric': 0.09422222222222222, 'fraction_numerical': 0.0017777777777777779, 'mean_word_length': 2.6661237785016287, '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': '4563828', 'n_tokens_mistral': 591, 'n_tokens_neox': 563, 'n_words': 153}