From aec6d16be80782443955c3e832bed46ae15016b9 Mon Sep 17 00:00:00 2001 From: Grey Li Date: Tue, 7 Apr 2020 21:46:53 +0800 Subject: [PATCH] Stop change CWD to .env/.flaskenv location --- src/flask/cli.py | 7 ------- tests/test_cli.py | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/src/flask/cli.py b/src/flask/cli.py index 83bd4a83c0..29baf005ae 100644 --- a/src/flask/cli.py +++ b/src/flask/cli.py @@ -577,10 +577,6 @@ def load_dotenv(path=None): If an env var is already set it is not overwritten, so earlier files in the list are preferred over later files. - Changes the current working directory to the location of the first file - found, with the assumption that it is in the top level project directory - and will be where the Python path should import local packages from. - This is a no-op if `python-dotenv`_ is not installed. .. _python-dotenv: https://github.com/theskumar/python-dotenv#readme @@ -626,9 +622,6 @@ def load_dotenv(path=None): dotenv.load_dotenv(path) - if new_dir and os.getcwd() != new_dir: - os.chdir(new_dir) - return new_dir is not None # at least one file was located and loaded diff --git a/tests/test_cli.py b/tests/test_cli.py index 18a29653cb..ec59e400d6 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -500,7 +500,7 @@ def test_load_dotenv(monkeypatch): monkeypatch._setitem.append((os.environ, item, notset)) monkeypatch.setenv("EGGS", "3") - monkeypatch.chdir(os.path.join(test_path, "cliapp", "inner1")) + monkeypatch.chdir(test_path) assert load_dotenv() assert os.getcwd() == test_path # .flaskenv doesn't overwrite .env