python-dependency-injector/examples/providers/configuration/configuration_env_interpolation_os_default.py

20 lines
448 B
Python
Raw Permalink Normal View History

"""`Configuration` provider values loading example."""
import os
from dependency_injector import containers, providers
class Container(containers.DeclarativeContainer):
config = providers.Configuration()
2021-09-30 22:32:21 +03:00
if __name__ == "__main__":
os.environ.setdefault("ENV_VAR", "default value")
container = Container()
2021-09-30 22:32:21 +03:00
container.config.from_yaml("config-with-env-var.yml")
2021-09-30 22:32:21 +03:00
assert container.config.section.option() == "default value"