Open
Description
I have attempted to override the entire container for test purposes and realized that even though I have replaced all the resources with dummy ones, the original resources were still being initialized. To better visualize this, see a test case below that is currently failing on latest master:
def test_override_resource():
def broken_resource_factory():
raise Exception("Something went wrong")
def working_resource_factory():
yield "hello world"
class _Container(containers.DeclarativeContainer):
res = providers.Resource(working_resource_factory)
class _OverridingContainer(containers.DeclarativeContainer):
res = providers.Resource(broken_resource_factory)
container = _Container()
overriding_container = _OverridingContainer()
container.init_resources()
container.override(overriding_container)
assert container.res() == "hello world"
Fails with:
def broken_resource_factory():
> raise Exception("Something went wrong")
E Exception: Something went wrong
unit/containers/instance/test_main_py2_py3.py:114: Exception
Is it a bug or is it by design?
Metadata
Metadata
Assignees
Labels
No labels