mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-22 01:26:51 +03:00
Use Singleton
provider; clean up formatting
This commit is contained in:
parent
64942563b3
commit
c0131549b0
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue
Block a user