Skip to content
Myr

Stop change CWD to .env/.flaskenv location

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Grey Li · committed by Grey Li · parent 3fe5eec · Browse files · 2 files+1 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+1 added−8 removed

  • tests:+1 added−1 removed
  • other:+0 added−7 removed

2 files+1 added−8 removed

modified:src/flask/cli.py-7 removed
608 unmodified lines
609610 If an env var is already set it is not overwritten, so earlier files in the611 list are preferred over later files.612613 Changes the current working directory to the location of the first file614 found, with the assumption that it is in the top level project directory615 and will be where the Python path should import local packages from.616613 This is a no-op if `python-dotenv`_ is not installed.614615 .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme616
37 unmodified lines
654 new_dir = os.path.dirname(path)655656 dotenv.load_dotenv(path)657662 if new_dir and os.getcwd() != new_dir:663 os.chdir(new_dir)664658 return new_dir is not None # at least one file was located and loaded659660661def show_server_banner(env, debug, app_import_path, eager_loading):
303 unmodified lines
modified:tests/test_cli.py+1 added-1 removed
502 unmodified lines
503 for item in ("FOO", "BAR", "SPAM"):504 monkeypatch._setitem.append((os.environ, item, notset))505506 monkeypatch.setenv("EGGS", "3")507 monkeypatch.chdir(os.path.join(test_path, "cliapp", "inner1"))507 monkeypatch.chdir(test_path)508 assert load_dotenv()509 assert os.getcwd() == test_path510 # .flaskenv doesn't overwrite .env511 assert os.environ["FOO"] == "env"
145 unmodified lines