forked from orbit-oss/flask
windows env vars are uppercase
This commit is contained in:
parent
4eb5e9455b
commit
e75d575361
2 changed files with 24 additions and 9 deletions
|
|
@ -594,9 +594,12 @@ exist on the parent dict will be initialized to an empty dict.
|
||||||
|
|
||||||
app.config["MYAPI"]["credentials"]["username"] # Is "user123"
|
app.config["MYAPI"]["credentials"]["username"] # Is "user123"
|
||||||
|
|
||||||
For even more config loading features, including merging, try a
|
On Windows, environment variable keys are always uppercase, therefore
|
||||||
dedicated library such as Dynaconf_, which includes integration with
|
the above example would end up as ``MYAPI__CREDENTIALS__USERNAME``.
|
||||||
Flask.
|
|
||||||
|
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/
|
.. _Dynaconf: https://www.dynaconf.com/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,12 +79,24 @@ def test_from_prefixed_env_nested(monkeypatch):
|
||||||
app.config["EXIST"] = {"ok": "value", "flag": True, "inner": {"ik": 1}}
|
app.config["EXIST"] = {"ok": "value", "flag": True, "inner": {"ik": 1}}
|
||||||
app.config.from_prefixed_env()
|
app.config.from_prefixed_env()
|
||||||
|
|
||||||
assert app.config["EXIST"] == {
|
if os.name != "nt":
|
||||||
"ok": "other",
|
assert app.config["EXIST"] == {
|
||||||
"flag": True,
|
"ok": "other",
|
||||||
"inner": {"ik": 2},
|
"flag": True,
|
||||||
"new": {"more": {"k": False}},
|
"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"}
|
assert app.config["NEW"] == {"K": "v"}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue