mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-05-23 05:56:19 +03:00
Add example for config.from_value()
This commit is contained in:
parent
7b9664e382
commit
1a8cf5d409
24
examples/providers/configuration/configuration_value.py
Normal file
24
examples/providers/configuration/configuration_value.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
"""`Configuration` provider values loading example."""
|
||||||
|
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
from dependency_injector import containers, providers
|
||||||
|
|
||||||
|
|
||||||
|
class Container(containers.DeclarativeContainer):
|
||||||
|
|
||||||
|
config = providers.Configuration()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
container = Container()
|
||||||
|
|
||||||
|
container.config.option1.from_value(date(2021, 6, 13))
|
||||||
|
container.config.option2.from_value(date(2021, 6, 14))
|
||||||
|
|
||||||
|
assert container.config() == {
|
||||||
|
'option1': date(2021, 6, 13),
|
||||||
|
'option2': date(2021, 6, 14),
|
||||||
|
}
|
||||||
|
assert container.config.option1() == date(2021, 6, 13)
|
||||||
|
assert container.config.option2() == date(2021, 6, 14)
|
Loading…
Reference in New Issue
Block a user