python-dependency-injector/examples/advanced_usage/inject_simple.py

17 lines
423 B
Python
Raw Normal View History

2015-09-02 12:23:01 +03:00
"""`@di.inject()` decorator simple example."""
2015-08-05 17:01:23 +03:00
import dependency_injector as di
2015-08-05 17:01:23 +03:00
dependency_injector_factory = di.Factory(object)
2015-08-05 17:01:23 +03:00
@di.inject(new_object=dependency_injector_factory)
@di.inject(some_setting=1334)
2015-08-05 17:01:23 +03:00
def example_callback(new_object, some_setting):
2015-09-01 22:30:49 +03:00
"""Example callback that does some asserts for input args."""
2015-08-05 17:01:23 +03:00
assert isinstance(new_object, object)
assert some_setting == 1334
example_callback()