mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2024-11-27 12:04:00 +03:00
14 lines
448 B
Python
14 lines
448 B
Python
"""`di.Singleton` providers delegation example."""
|
|
|
|
import dependency_injector as di
|
|
|
|
|
|
# Some singleton provider and few delegates of it:
|
|
singleton_provider = di.Singleton(object)
|
|
singleton_provider_delegate1 = singleton_provider.delegate()
|
|
singleton_provider_delegate2 = di.Delegate(singleton_provider)
|
|
|
|
# Making some asserts:
|
|
assert singleton_provider_delegate1() is singleton_provider
|
|
assert singleton_provider_delegate2() is singleton_provider
|