add ENOTDIR to from_file silent error handling

This commit is contained in:
abdullahmujahidali 2026-02-09 07:27:09 +05:00
parent d3b78fd18a
commit 560ea7fd40
3 changed files with 17 additions and 1 deletions

View file

@ -195,6 +195,20 @@ def test_config_missing_file():
assert not app.config.from_file("missing.json", load=json.load, silent=True)
def test_config_from_file_enotdir(tmp_path):
not_a_dir = tmp_path / "not_a_dir"
not_a_dir.write_text("")
app = flask.Flask(__name__)
app.config.root_path = str(tmp_path)
with pytest.raises(OSError):
app.config.from_file("not_a_dir/config.json", load=json.load)
assert not app.config.from_file(
"not_a_dir/config.json", load=json.load, silent=True
)
def test_custom_config_class():
class Config(flask.Config):
pass