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