python-dependency-injector/examples/providers/delegated_callable.py
2016-06-06 11:54:05 +03:00

23 lines
640 B
Python

"""`DelegatedCallable` providers example."""
import dependency_injector.providers as providers
def command1(config):
"""Some example command."""
return config['some_value'] * 5
def command2(command1):
"""Some example command."""
return command1() / 2
# Creating callable providers for commands:
command1_provider = providers.DelegatedCallable(command1,
config={'some_value': 4})
command2_provider = providers.DelegatedCallable(command2,
command1=command1_provider)
# Making some asserts:
assert command2_provider() == 10