Skip to content

Commit

Permalink
Merge b7ed057 into f0af058
Browse files Browse the repository at this point in the history
  • Loading branch information
variable committed Nov 14, 2019
2 parents f0af058 + b7ed057 commit 70c32a8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion environ/environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ def read_env(cls, env_file=None, **overrides):
"""
if env_file is None:
frame = sys._getframe()
env_file = os.path.join(os.path.dirname(frame.f_back.f_code.co_filename), '.env')
env_file = os.environ.get('ENV_FILE')
env_file = env_file or os.path.join(os.path.dirname(frame.f_back.f_code.co_filename), '.env')
if not os.path.exists(env_file):
warnings.warn(
"%s doesn't exist - if you're not configuring your "
Expand Down
12 changes: 11 additions & 1 deletion environ/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,16 @@ def setUp(self):
file_path = Path(__file__, is_file=True)('test_env.txt')
self.env.read_env(file_path, PATH_VAR=Path(__file__, is_file=True).__root__)


class FileEnvByEnvVarTests(EnvTests):

def setUp(self):
super(FileEnvByEnvVarTests, self).setUp()
Env.ENVIRON = {}
os.environ['ENV_FILE'] = './environ/test_env.txt'
self.env = Env()
self.env.read_env()

class SubClassTests(EnvTests):

def setUp(self):
Expand Down Expand Up @@ -746,7 +756,7 @@ def load_suite():

test_suite = unittest.TestSuite()
cases = [
EnvTests, FileEnvTests, SubClassTests, SchemaEnvTests, PathTests,
EnvTests, FileEnvTests, FileEnvByEnvVarTests, SubClassTests, SchemaEnvTests, PathTests,
DatabaseTestSuite, CacheTestSuite, EmailTests, SearchTestSuite
]
for case in cases:
Expand Down

0 comments on commit 70c32a8

Please sign in to comment.