give priority to '-e/--env-file' option over default files (#5628)

Signed-off-by: Jalaj <96870071+jalaj711@users.noreply.github.com>
This commit is contained in:
Jalaj 2024-11-07 23:07:51 +05:30
parent ce08bc704e
commit f60d6c9042
No known key found for this signature in database
GPG key ID: FDC1954BB2CAC91C
4 changed files with 37 additions and 6 deletions

View file

@ -565,6 +565,21 @@ def test_disable_dotenv_from_env(monkeypatch, runner):
assert "FOO" not in os.environ
@need_dotenv
def test_custom_dotenv_takes_priority(monkeypatch, runner):
monkeypatch.chdir(test_path)
runner.invoke(FlaskGroup(), "-e .customenv")
# .customenv is loaded
assert "BAZ" in os.environ
# .customenv takes priority over .flaskenv
assert os.environ["BAR"] == "custombar"
# .customenv takes priority over .env
assert os.environ["FOO"] == "customenv"
def test_run_cert_path():
# no key
with pytest.raises(click.BadParameter):