def test_getting_unkown_builder_raises_KeyError(self): registry = Registry() with self.assertRaises(KeyError) as cm: registry.get('My Type') self.assertEquals( "'Unkown builder \"My Type\"'", str(cm.exception))
def test_registered_and_getting_builders(self): registry = Registry() registry.register('Foo', FooBuilder) registry.register('Bar', BarBuilder) self.assertEquals(FooBuilder, registry.get('Foo')) self.assertEquals(BarBuilder, registry.get('Bar'))
def test_overriding_registered_builders_is_possible_with_force(self): registry = Registry() registry.register('Foo', FooBuilder) registry.register('Foo', BarBuilder, force=True) self.assertEqual(BarBuilder, registry.get('Foo'))