Config.from_prefixed_env: Allow to not trim prefix

Fixes #5060
This commit is contained in:
Felix Stupp 2023-04-14 11:52:37 +02:00
parent 182ce3dd15
commit a34549a33a
No known key found for this signature in database
GPG key ID: 93E1BD26F6B02FB7
3 changed files with 33 additions and 7 deletions

View file

@ -108,6 +108,18 @@ def test_from_prefixed_env_nested(monkeypatch):
assert app.config["NEW"] == {"K": "v"}
def test_from_prefixed_env_no_trim(monkeypatch):
monkeypatch.setenv("FLASK_SECRET_KEY", "asdf")
monkeypatch.setenv("APP_DEBUG", "true")
app = flask.Flask(__name__)
app.config.from_prefixed_env(trim_prefix=True)
app.config.from_prefixed_env("APP", trim_prefix=False)
assert app.config["SECRET_KEY"] == "asdf"
assert app.config["APP_DEBUG"] is True
def test_config_from_mapping():
app = flask.Flask(__name__)
app.config.from_mapping({"SECRET_KEY": "config", "TEST_KEY": "foo"})