예제 #1
0
    def test_reset_singletons_context_manager_as_attribute(self):
        container = containers.DeclarativeContainer()

        with container.reset_singletons() as alias:
            pass

        self.assertIs(container, alias)
예제 #2
0
 def test_declarative(self):
     container: containers.Container = containers.DeclarativeContainer()
     self.assertIsInstance(container, containers.Container)
def test_reset_singletons_context_manager_as_attribute():
    container = containers.DeclarativeContainer()
    with container.reset_singletons() as alias:
        pass
    assert container is alias
 def test_repr(self):
     container = containers.DeclarativeContainer()
     provider = providers.Self(container)
     self.assertEqual(
         repr(provider), '<dependency_injector.providers.'
         'Self({0}) at {1}>'.format(repr(container), hex(id(provider))))
 def test_set_container(self):
     container = containers.DeclarativeContainer()
     provider = providers.Self()
     provider.set_container(container)
     self.assertIs(provider(), container)
 def test_call_object_provider(self):
     container = containers.DeclarativeContainer()
     self.assertIs(providers.Self(container)(), container)
예제 #7
0
def test_call_object_provider():
    container = containers.DeclarativeContainer()
    assert providers.Self(container)() is container
예제 #8
0
def test_repr():
    container = containers.DeclarativeContainer()
    provider = providers.Self(container)
    assert repr(provider) == ("<dependency_injector.providers."
                              "Self({0}) at {1}>".format(
                                  repr(container), hex(id(provider))))
예제 #9
0
def test_set_container():
    container = containers.DeclarativeContainer()
    provider = providers.Self()
    provider.set_container(container)
    assert provider() is container