Use Singleton provider; clean up formatting

This commit is contained in:
jazzthief 2023-05-24 15:46:06 +02:00
parent 64942563b3
commit c0131549b0
No known key found for this signature in database
GPG Key ID: 650DC0A0E6B6947C
2 changed files with 11 additions and 4 deletions

View File

@ -64,7 +64,7 @@ class Container(containers.DeclarativeContainer):
class ContainerSingleton(containers.DeclarativeContainer):
singleton = providers.Resource(Singleton)
singleton = providers.Singleton(Singleton)
service = providers.Resource(
init_service_with_singleton,
singleton
@ -83,12 +83,16 @@ def test_function(service: Service = Closing[Provide["service"]]):
@inject
def test_function_dependency(factory: FactoryService = Closing[Provide["factory_service"]]):
def test_function_dependency(
factory: FactoryService = Closing[Provide["factory_service"]]
):
return factory
@inject
def test_function_dependency_kwargs(factory: FactoryService = Closing[Provide["factory_service_kwargs"]]):
def test_function_dependency_kwargs(
factory: FactoryService = Closing[Provide["factory_service_kwargs"]]
):
return factory

View File

@ -33,7 +33,10 @@ def subcontainer():
container.unwire()
@fixture(params=[resourceclosing.Container, resourceclosing.ContainerSingleton])
@fixture(params=[
resourceclosing.Container,
resourceclosing.ContainerSingleton,
])
def resourceclosing_container(request):
container = request.param()
container.wire(modules=[resourceclosing])