Skip to content

Commit f8bd0c6

Browse files
author
Saurabh Kumar
committed
Improve test coverage
1 parent 3db481d commit f8bd0c6

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ release: clean
1919
sdist: clean
2020
python setup.py sdist
2121
ls -l dist
22+
23+
test:
24+
pip install -e .
25+
py.test tests/
26+
27+
coverage:
28+
coverage run --source=dotenv.py --omit='*tests*' -m py.test tests/ -v --tb=native
29+
coverage report
30+
31+
coverage-html: coverage
32+
coverage html

dotenv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def load_dotenv(dotenv_path):
1515
Read a .env file and load into os.environ.
1616
"""
1717
if not os.path.exists(dotenv_path):
18-
warnings.warn("can't read %s - it doesn't exist." % dotenv_path)
18+
warnings.warn("Not loading %s - it doesn't exist." % dotenv_path)
1919
return None
2020
for k, v in parse_dotenv(dotenv_path):
2121
os.environ.setdefault(k, v)

tests/test_core.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import warnings
2+
3+
from dotenv import load_dotenv
4+
5+
6+
def test_warns_if_file_does_not_exist():
7+
with warnings.catch_warnings(record=True) as w:
8+
load_dotenv('.does_not_exist')
9+
10+
assert len(w) == 1
11+
assert w[0].category is UserWarning
12+
assert str(w[0].message) == "Not loading .does_not_exist - it doesn't exist."

0 commit comments

Comments
 (0)