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