Skip to content

Commit

Permalink
windows env vars are uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Mar 25, 2022
1 parent 4eb5e94 commit e75d575
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
9 changes: 6 additions & 3 deletions docs/config.rst
Expand Up @@ -594,9 +594,12 @@ exist on the parent dict will be initialized to an empty dict.
app.config["MYAPI"]["credentials"]["username"] # Is "user123"
For even more config loading features, including merging, try a
dedicated library such as Dynaconf_, which includes integration with
Flask.
On Windows, environment variable keys are always uppercase, therefore
the above example would end up as ``MYAPI__CREDENTIALS__USERNAME``.

For even more config loading features, including merging and
case-insensitive Windows support, try a dedicated library such as
Dynaconf_, which includes integration with Flask.

.. _Dynaconf: https://www.dynaconf.com/

Expand Down
24 changes: 18 additions & 6 deletions tests/test_config.py
Expand Up @@ -79,12 +79,24 @@ def test_from_prefixed_env_nested(monkeypatch):
app.config["EXIST"] = {"ok": "value", "flag": True, "inner": {"ik": 1}}
app.config.from_prefixed_env()

assert app.config["EXIST"] == {
"ok": "other",
"flag": True,
"inner": {"ik": 2},
"new": {"more": {"k": False}},
}
if os.name != "nt":
assert app.config["EXIST"] == {
"ok": "other",
"flag": True,
"inner": {"ik": 2},
"new": {"more": {"k": False}},
}
else:
# Windows env var keys are always uppercase.
assert app.config["EXIST"] == {
"ok": "value",
"OK": "other",
"flag": True,
"inner": {"ik": 1},
"INNER": {"IK": 2},
"NEW": {"MORE": {"k": False}},
}

assert app.config["NEW"] == {"K": "v"}


Expand Down

0 comments on commit e75d575

Please sign in to comment.