Skip to content

Commit

Permalink
Stop change CWD to .env/.flaskenv location
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli committed Apr 7, 2020
1 parent 024f0d3 commit aec6d16
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions src/flask/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aec6d16

Please sign in to comment.