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

21 lines
504 B
Python
Raw Normal View History

2015-09-02 15:56:32 +00:00
"""Static providers example."""
from dependency_injector import providers
2015-06-18 11:55:13 +00:00
# Provides class - `object`:
cls_provider = providers.Class(object)
assert cls_provider() is object
2015-06-18 11:55:13 +00:00
# Provides object - `object()`:
object_provider = providers.Object(object())
assert isinstance(object_provider(), object)
2015-06-18 11:55:13 +00:00
# Provides function - `len`:
function_provider = providers.Function(len)
assert function_provider() is len
2015-06-18 11:55:13 +00:00
# Provides value - `123`:
value_provider = providers.Value(123)
assert value_provider() == 123