Browse Source

Fix #2937: Ensure the consistency in load_dotenv's return type

pull/2939/head
Adarsh Sharma 6 years ago
parent
commit
d3a052b2af
  1. 8
      flask/cli.py
  2. 4
      tests/test_cli.py

8
flask/cli.py

@ -594,10 +594,14 @@ def load_dotenv(path=None):
' * Tip: There are .env or .flaskenv files present.'
' Do "pip install python-dotenv" to use them.',
fg='yellow')
return
return False
# if the given path specifies the actual file then return True,
# else False
if path is not None:
return dotenv.load_dotenv(path)
if os.path.isfile(path):
return dotenv.load_dotenv(path)
return False
new_dir = None

4
tests/test_cli.py

@ -493,6 +493,10 @@ def test_load_dotenv(monkeypatch):
# set manually, files don't overwrite
assert os.environ['EGGS'] == '3'
# Non existent file should not load
file_loaded = load_dotenv('non-existent-file')
assert file_loaded == False
@need_dotenv
def test_dotenv_path(monkeypatch):

Loading…
Cancel
Save