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

16 lines
479 B
Python
Raw Normal View History

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