Skip to content

Commit

Permalink
fix(find_dotenv): it should walk up the directory from where it's cal…
Browse files Browse the repository at this point in the history
…led from

Fixes #24
  • Loading branch information
Saurabh Kumar committed May 19, 2016
1 parent fbcbe89 commit d3929c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion dotenv/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
import os
import sys
import warnings

from .compat import OrderedDict
Expand Down Expand Up @@ -125,7 +126,8 @@ def find_dotenv(filename='.env', raise_error_if_not_found=False, usecwd=False):
path = os.getcwd()
else:
# will work for .py files
path = os.path.dirname(os.path.abspath(__file__))
frame_filename = sys._getframe().f_back.f_code.co_filename
path = os.path.dirname(os.path.abspath(frame_filename))

for dirname in _walk_to_root(path):
check_path = os.path.join(dirname, filename)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_find_dotenv():
Then try to automatically `find_dotenv` starting in `child4`
"""
tmpdir = tempfile.mkdtemp()
tmpdir = os.path.realpath(tempfile.mkdtemp())

curr_dir = tmpdir
dirs = []
Expand Down

0 comments on commit d3929c6

Please sign in to comment.