def test_reset_singletons_context_manager_as_attribute(self): container = containers.DeclarativeContainer() with container.reset_singletons() as alias: pass self.assertIs(container, alias)
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)
def test_call_object_provider(): container = containers.DeclarativeContainer() assert providers.Self(container)() is container
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))))
def test_set_container(): container = containers.DeclarativeContainer() provider = providers.Self() provider.set_container(container) assert provider() is container