Ejemplo n.º 1
0
 def test_bind_constructor__constructor_required(self):
     binder = Binder()
     self.assertRaisesRegex(InjectorException, "Constructor cannot be None",
                            binder.bind_to_constructor, int, None)
Ejemplo n.º 2
0
    def test_bind_constructor(self):
        constructor = lambda: 123
        binder = Binder()
        binder.bind_to_constructor(int, constructor)

        assert binder._bindings[int]._constructor is constructor
Ejemplo n.º 3
0
 def test_bind_provider__provider_required(self):
     binder = Binder()
     self.assertRaisesRegex(InjectorException, "Provider cannot be None",
                            binder.bind_to_provider, int, None)
Ejemplo n.º 4
0
    def test_bind_provider(self):
        provider = lambda: 123
        binder = Binder()
        binder.bind_to_provider(int, provider)

        assert binder._bindings[int] is provider
Ejemplo n.º 5
0
    def test_bind__duplicate_binding(self):
        binder = Binder()
        binder.bind(int, 123)

        self.assertRaisesRegex(InjectorException, "Duplicate binding",
                               binder.bind, int, 456)
Ejemplo n.º 6
0
    def test_bind__class_required(self):
        binder = Binder()

        self.assertRaisesRegex(InjectorException, 'Binding key cannot be None',
                               binder.bind, None, None)