MCPcopy Create free account
hub / github.com/pallets/flask / test_load_dotenv

Function test_load_dotenv

tests/test_cli.py:536–556  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

534
535@need_dotenv
536def test_load_dotenv(monkeypatch):
537 # can't use monkeypatch.delitem since the keys don't exist yet
538 for item in ("FOO", "BAR", "SPAM", "HAM"):
539 monkeypatch._setitem.append((os.environ, item, notset))
540
541 monkeypatch.setenv("EGGS", "3")
542 monkeypatch.chdir(test_path)
543 assert load_dotenv()
544 assert Path.cwd() == test_path
545 # .flaskenv doesn't overwrite .env
546 assert os.environ["FOO"] == "env"
547 # set only in .flaskenv
548 assert os.environ["BAR"] == "bar"
549 # set only in .env
550 assert os.environ["SPAM"] == "1"
551 # set manually, files don't overwrite
552 assert os.environ["EGGS"] == "3"
553 # test env file encoding
554 assert os.environ["HAM"] == "火腿"
555 # Non existent file should not load
556 assert not load_dotenv("non-existent-file", load_defaults=False)
557
558
559@need_dotenv

Callers

nothing calls this directly

Calls 1

load_dotenvFunction · 0.90

Tested by

no test coverage detected