Beispiel #1
0
    def test_specific_registry_clearing(self):
        Ent = type('Ent', (Registrable,), {})
        Ent.make_registry()

        Sub = type('Sub', (Ent,), {})
        Sub.register()

        self.assertTrue(Sub in Registry.entries_for(Ent))

        Registry.clear(Ent)

        self.assertFalse(Sub in Registry.entries_for(Ent))
Beispiel #2
0
    def test_specific_registry_clearing(self):
        Ent = type('Ent', (Registrable, ), {})
        Ent.make_registry()

        Sub = type('Sub', (Ent, ), {})
        Sub.register()

        self.assertTrue(Sub in Registry.entries_for(Ent))

        Registry.clear(Ent)

        self.assertFalse(Sub in Registry.entries_for(Ent))
Beispiel #3
0
    def test_decorators(self):
        @registry
        class Ent(Registrable): pass

        self.assertTrue(issubclass(Ent, Registry))

        @register
        class Sub(Ent): pass

        self.assertTrue(Sub in Registry.entries_for(Ent))
Beispiel #4
0
    def test_that_it_registers_properly(self):
        Ent = type('Ent', (Registrable,), {})
        Ent.make_registry()

        self.assertTrue(issubclass(Ent, Registry))

        Sub = type('Sub', (Ent,), {})
        Sub.register()

        self.assertTrue(Sub in Registry.entries_for(Ent))
Beispiel #5
0
    def test_that_it_registers_properly(self):
        Ent = type('Ent', (Registrable, ), {})
        Ent.make_registry()

        self.assertTrue(issubclass(Ent, Registry))

        Sub = type('Sub', (Ent, ), {})
        Sub.register()

        self.assertTrue(Sub in Registry.entries_for(Ent))
Beispiel #6
0
    def test_decorators(self):
        @registry
        class Ent(Registrable):
            pass

        self.assertTrue(issubclass(Ent, Registry))

        @register
        class Sub(Ent):
            pass

        self.assertTrue(Sub in Registry.entries_for(Ent))
Beispiel #7
0
    def test_on_registration_data_binding(self):
        Ent = type(
            'Ent', (Registrable, ), {
                'on_registration':
                classmethod(lambda cls: {'non_entry_specific': True})
            })
        Ent.make_registry()

        Sub = type('Sub', (Ent, ), {})
        Sub.register()

        self.assertEqual([(Sub, {
            'non_entry_specific': True
        })], Registry.entries_with_data_for(Ent))
Beispiel #8
0
    def test_on_registration_data_binding(self):
        Ent = type('Ent', (Registrable,), {
            'on_registration': classmethod(lambda cls: {
                'non_entry_specific': True
            })
        })
        Ent.make_registry()

        Sub = type('Sub', (Ent,), {})
        Sub.register()

        self.assertEqual(
            [(Sub, {'non_entry_specific': True})],
            Registry.entries_with_data_for(Ent)
        )
Beispiel #9
0
    def test_global_registries_clearing(self):
        Ent1 = type('Ent1', (Registrable,), {})
        Ent1.make_registry()

        Ent2 = type('Ent2', (Registrable,), {})
        Ent2.make_registry()

        Registry.clear()

        with self.assertRaises(TypeError):
            Registry.entries_for(Ent1)

        with self.assertRaises(TypeError):
            Registry.entries_for(Ent2)
Beispiel #10
0
    def test_global_registries_clearing(self):
        Ent1 = type('Ent1', (Registrable, ), {})
        Ent1.make_registry()

        Ent2 = type('Ent2', (Registrable, ), {})
        Ent2.make_registry()

        Registry.clear()

        with self.assertRaises(TypeError):
            Registry.entries_for(Ent1)

        with self.assertRaises(TypeError):
            Registry.entries_for(Ent2)
Beispiel #11
0
 def tearDown(self):
     Registry.clear()
Beispiel #12
0
 def tearDown(self):
     Registry.clear()