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