Пример #1
0
    def test_registered_items_are_stored_separately_by_registry(self):
        class RegistryOne(Registry):
            """A registry distinct from the base `Registry`."""

        class RegistryTwo(Registry):
            """A registry distinct from the base `Registry`."""

        name = self.getUniqueString()
        Registry.register_item(name, sentinel.item)
        RegistryOne.register_item(name, sentinel.item_in_one)
        RegistryTwo.register_item(name, sentinel.item_in_two)

        # Items stored in separate registries are stored separately;
        # names do not clash between registries.
        self.assertEqual(sentinel.item, Registry.get_item(name))
        self.assertEqual(sentinel.item_in_one, RegistryOne.get_item(name))
        self.assertEqual(sentinel.item_in_two, RegistryTwo.get_item(name))
Пример #2
0
 def test_get_item_returns_None_default(self):
     self.assertIsNone(Registry.get_item("resource"))
Пример #3
0
 def test_get_item_returns_default_if_value_not_present(self):
     self.assertEqual(sentinel.default,
                      Registry.get_item("resource", sentinel.default))
Пример #4
0
 def test_get_item(self):
     Registry.register_item("resource", sentinel.resource)
     self.assertEqual(sentinel.resource, Registry.get_item("resource"))
Пример #5
0
 def test_register_and_unregister_item(self):
     name = self.getUniqueString()
     Registry.register_item(name, sentinel.item)
     Registry.unregister_item(name)
     self.assertIsNone(Registry.get_item(name))
     self.assertNotIn(name, Registry)
Пример #6
0
 def test_register_and_get_item(self):
     name = self.getUniqueString()
     item = self.getUniqueString()
     Registry.register_item(name, item)
     self.assertEqual(item, Registry.get_item(name))