Skip to content
Myr

windows env vars are uppercase

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Lord · committed by David Lord · parent 4eb5e94 · Browse files · 2 files+24 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+24 added−9 removed

  • tests:+18 added−6 removed
  • other:+6 added−3 removed

2 files+24 added−9 removed

modified:docs/config.rst+6 added-3 removed
592 unmodified lines
593.. code-block:: python594595 app.config["MYAPI"]["credentials"]["username"] # Is "user123"596597For even more config loading features, including merging, try a598dedicated library such as Dynaconf_, which includes integration with599Flask.597On Windows, environment variable keys are always uppercase, therefore598the above example would end up as ``MYAPI__CREDENTIALS__USERNAME``.599600For even more config loading features, including merging and601case-insensitive Windows support, try a dedicated library such as602Dynaconf_, which includes integration with Flask.603604.. _Dynaconf: https://www.dynaconf.com/605606607Configuration Best Practices
207 unmodified lines
modified:tests/test_config.py+18 added-6 removed
77 unmodified lines
78 app = flask.Flask(__name__)79 app.config["EXIST"] = {"ok": "value", "flag": True, "inner": {"ik": 1}}80 app.config.from_prefixed_env()8182 if os.name != "nt":82 assert app.config["EXIST"] == {83 "ok": "other",84 "flag": True,85 "inner": {"ik": 2},86 "new": {"more": {"k": False}},87 }83 assert app.config["EXIST"] == {84 "ok": "other",85 "flag": True,86 "inner": {"ik": 2},87 "new": {"more": {"k": False}},88 }89 else:90 # Windows env var keys are always uppercase.91 assert app.config["EXIST"] == {92 "ok": "value",93 "OK": "other",94 "flag": True,95 "inner": {"ik": 1},96 "INNER": {"IK": 2},97 "NEW": {"MORE": {"k": False}},98 }99100 assert app.config["NEW"] == {"K": "v"}101102103def test_config_from_mapping():
149 unmodified lines