forked from orbit-oss/flask
add text parameter to config.from_file
This commit is contained in:
parent
4c288bc97e
commit
b10b6d4af1
4 changed files with 23 additions and 5 deletions
2
tests/static/config.toml
Normal file
2
tests/static/config.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
TEST_KEY="foo"
|
||||
SECRET_KEY="config"
|
||||
|
|
@ -6,7 +6,6 @@ import pytest
|
|||
|
||||
import flask
|
||||
|
||||
|
||||
# config keys used for the TestConfig
|
||||
TEST_KEY = "foo"
|
||||
SECRET_KEY = "config"
|
||||
|
|
@ -30,13 +29,23 @@ def test_config_from_object():
|
|||
common_object_test(app)
|
||||
|
||||
|
||||
def test_config_from_file():
|
||||
def test_config_from_file_json():
|
||||
app = flask.Flask(__name__)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
app.config.from_file(os.path.join(current_dir, "static", "config.json"), json.load)
|
||||
common_object_test(app)
|
||||
|
||||
|
||||
def test_config_from_file_toml():
|
||||
tomllib = pytest.importorskip("tomllib", reason="tomllib added in 3.11")
|
||||
app = flask.Flask(__name__)
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
app.config.from_file(
|
||||
os.path.join(current_dir, "static", "config.toml"), tomllib.load, text=False
|
||||
)
|
||||
common_object_test(app)
|
||||
|
||||
|
||||
def test_from_prefixed_env(monkeypatch):
|
||||
monkeypatch.setenv("FLASK_STRING", "value")
|
||||
monkeypatch.setenv("FLASK_BOOL", "true")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue