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_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 #4
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 #5
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 #6
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 #7
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 #8
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))