コード例 #1
0
    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))
コード例 #2
0
    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'))
コード例 #3
0
    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'))