python-dependency-injector/examples/providers/callable_delegation.py

15 lines
458 B
Python
Raw Normal View History

2015-09-02 18:48:11 +03:00
"""`di.Callable` providers delegation example."""
import sys
2015-09-02 18:48:11 +03:00
import dependency_injector as di
2015-08-31 16:31:38 +03:00
# Creating some callable provider and few delegates of it:
2015-09-02 18:48:11 +03:00
callable_provider = di.Callable(sys.exit)
callable_provider_delegate1 = callable_provider.delegate()
2015-09-02 18:48:11 +03:00
callable_provider_delegate2 = di.Delegate(callable_provider)
# Making some asserts:
assert callable_provider_delegate1() is callable_provider
assert callable_provider_delegate2() is callable_provider