How to use the dynaconf.settings.from_env function in dynaconf

To help you get started, weā€™ve selected a few dynaconf examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rochacbruno / dynaconf / example / yaml_example / yaml_as_extra_config / app.py View on Github external
found = settings.get(key)
    assert found == getattr(settings, key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())


assertions = {
    "HOST": "prod_server.com",
    "PORT": 5000,
    "ENVIRONMENT": "this is production",
}


for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / toml_example / app.py View on Github external
"PORT": 5000,
    "USERNAME": "admin",
    "PASSWORD": "Secret",
    "LEVELS": ["debug", "info", "warning"],
    "MONEY": 500.5,
    "AGE": 42,
    "ENABLED": True,
    "WORKS": "toml_example in prod env",
    "CUSTOM": "this is custom from [production]",
    "TEST_LOADERS": {"dev": "test_dev", "prod": "test_prod"},
}


for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / yaml_example / yaml_as_extra_config / app.py View on Github external
assert found == getattr(settings, key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())


assertions = {
    "HOST": "prod_server.com",
    "PORT": 5000,
    "ENVIRONMENT": "this is production",
}


for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / multiple_folders / app.py View on Github external
for key, value in assertions.items():
    found = settings.get(key)
    assert found == getattr(settings, key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())


print("production")
print(settings.from_env("production").VAR1)
print(settings.from_env("production").VAR2)

assertions = {"VAR1": "var1_prod", "VAR2": "var2_prod"}

for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / toml_example / app.py View on Github external
"HOST": "prod_server.com from toml",
    "PORT": 5000,
    "USERNAME": "admin",
    "PASSWORD": "Secret",
    "LEVELS": ["debug", "info", "warning"],
    "MONEY": 500.5,
    "AGE": 42,
    "ENABLED": True,
    "WORKS": "toml_example in prod env",
    "CUSTOM": "this is custom from [production]",
    "TEST_LOADERS": {"dev": "test_dev", "prod": "test_prod"},
}


for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / yaml_example / settings_file / app.py View on Github external
"HOST": "prod_server.com from yaml",
    "PORT": 5000,
    "USERNAME": "admin",
    "PASSWORD": "Secret",
    "LEVELS": ["debug", "info", "warning"],
    "MONEY": 500.5,
    "AGE": 42,
    "ENABLED": True,
    "WORKS": "yaml_example in prod env",
    "CUSTOM": "this is custom from [production]",
    "TEST_LOADERS": {"dev": "test_dev", "prod": "test_prod"},
}


for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())
github rochacbruno / dynaconf / example / redis_example / redis_example.py View on Github external
from dynaconf import settings

print(settings.FOO)  # noqa
# >>> 'foo_is_default'


with settings.using_env("development"):
    assert settings.SECRET == "redis_works_in_development", settings.SECRET
    assert settings.FOO == "foo_is_default"

available_envs = ["default", "development", "production"]
all_secrets = []

for env in available_envs:
    env_settings = settings.from_env(env)
    assert env_settings.SECRET == "redis_works_in_{0}".format(
        env
    ), env_settings.SECRET
    assert env_settings.FOO == "foo_is_default", env_settings.FOO
    all_secrets.append(env_settings.SECRET)

print(available_envs)
print(all_secrets)
github rochacbruno / dynaconf / example / multiple_folders / app.py View on Github external
print(settings.VAR2)


assertions = {"VAR1": "var1_dev", "VAR2": "var2_dev"}

for key, value in assertions.items():
    found = settings.get(key)
    assert found == getattr(settings, key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())


print("production")
print(settings.from_env("production").VAR1)
print(settings.from_env("production").VAR2)

assertions = {"VAR1": "var1_prod", "VAR2": "var2_prod"}

for key, value in assertions.items():
    found = settings.from_env("production").get(key)
    assert found == getattr(settings.from_env("production"), key)
    assert (
        found == value
    ), "expected: {key}: [{value}] found: [{found}]".format(**locals())