2015-09-02 16:06:09 +00:00
|
|
|
"""`di.Singleton` providers delegation example."""
|
2015-07-20 16:31:31 +00:00
|
|
|
|
2015-09-02 16:06:09 +00:00
|
|
|
import dependency_injector as di
|
2015-07-20 16:31:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Some singleton provider and few delegates of it:
|
2015-09-02 16:06:09 +00:00
|
|
|
singleton_provider = di.Singleton(object)
|
2015-07-20 16:31:31 +00:00
|
|
|
singleton_provider_delegate1 = singleton_provider.delegate()
|
2015-09-02 16:06:09 +00:00
|
|
|
singleton_provider_delegate2 = di.Delegate(singleton_provider)
|
2015-07-20 16:31:31 +00:00
|
|
|
|
|
|
|
# Making some asserts:
|
|
|
|
assert singleton_provider_delegate1() is singleton_provider
|
|
|
|
assert singleton_provider_delegate2() is singleton_provider
|