<commit_before>import unittest

from kiwi.component import AlreadyImplementedError, Interface, \
     get_utility, provide_utility, remove_utility, implements

class IBanana(Interface):
    pass

class Obj(object): pass
o = Obj()

class TestUtilities(unittest.TestCase):
    def tearDown(self):
        # Yey, yey
        from kiwi.component import _handler
        _handler._utilities = {}

    def testGet(self):
        self.assertEqual(None, get_utility(IBanana, None))
        provide_utility(IBanana, o)
        self.assertRaises(TypeError, get_utility, object)
        self.assertEqual(get_utility(IBanana), o)

    def testProvide(self):
        self.assertRaises(NotImplementedError, get_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertRaises(TypeError, provide_utility, object, o)

    def testRemove(self):
        self.assertRaises(NotImplementedError, remove_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertEqual(remove_utility(IBanana), o)
        self.assertRaises(NotImplementedError, remove_utility, IBanana)

    def testAlreadyImplemented(self):
        self.assertRaises(NotImplementedError, get_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertRaises(AlreadyImplementedError,<commit_msg>And update test...<commit_after>import unittest

from kiwi.component import AlreadyImplementedError, Interface, \
     get_utility, provide_utility, remove_utility, implements, utilities

class IBanana(Interface):
    pass

class Obj(object): pass
o = Obj()

class TestUtilities(unittest.TestCase):
    def tearDown(self):
        utilities.clean()

    def testGet(self):
        self.assertEqual(None, get_utility(IBanana, None))
        provide_utility(IBanana, o)
        self.assertRaises(TypeError, get_utility, object)
        self.assertEqual(get_utility(IBanana), o)

    def testProvide(self):
        self.assertRaises(NotImplementedError, get_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertRaises(TypeError, provide_utility, object, o)

    def testRemove(self):
        self.assertRaises(NotImplementedError, remove_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertEqual(remove_utility(IBanana), o)
        self.assertRaises(NotImplementedError, remove_utility, IBanana)

    def testAlreadyImplemented(self):
        self.assertRaises(NotImplementedError, get_utility, IBanana)
        provide_utility(IBanana, o)
        self.assertRaises(AlreadyImplementedError,
{'fraction_non_alphanumeric': 0.08764940239043825, 'fraction_numerical': 0.0, 'mean_word_length': 3.9138943248532287, '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': '83333', 'n_tokens_mistral': 807, 'n_tokens_neox': 781, 'n_words': 142}