forked from Kitware/romanesco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory_test.py
55 lines (33 loc) · 1.09 KB
/
factory_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from six import add_metaclass
from base import TestCase
from gaia.core import factory
TestRegistry = factory.create_registry()
Registry2 = factory.create_registry()
@add_metaclass(TestRegistry)
class TestMainClass(object):
"""A toplevel class for registry testing."""
pass
registry = TestRegistry.registry()
@add_metaclass(Registry2)
class Secondary(object):
"""A second toplevel class."""
pass
class FactoryTest(TestCase):
"""Contains test for the class registry metaclass."""
def test_create_registry(self):
"""Test generation of class registries."""
class Test1(TestMainClass):
pass
class Test2(TestMainClass):
pass
self.assertEqual(
set(registry.keys()),
set(('Test1', 'Test2', "TestMainClass"))
)
self.assertEqual(registry['TestMainClass'], TestMainClass)
self.assertEqual(registry['Test1'], Test1)
self.assertEqual(registry['Test2'], Test2)
self.assertEqual(
Registry2.registry(),
{'Secondary': Secondary}
)