call load_dot_env_file when initializing HttpRunner

This commit is contained in:
debugtalk
2018-05-09 17:16:20 +08:00
parent 9c26dba415
commit a414fe56d5
6 changed files with 30 additions and 10 deletions

View File

@@ -500,8 +500,14 @@ def create_scaffold(project_path):
def load_dot_env_file(path):
""" load .env file and set to os.environ
"""
if not os.path.isfile(path):
return
if not path:
path = os.path.join(os.getcwd(), ".env")
if not os.path.isfile(path):
logger.log_debug(".env file not exist: {}".format(path))
return
else:
if not os.path.isfile(path):
raise exception.FileNotFoundError("env file not exist: {}".format(path))
logger.log_info("Loading environment variables from {}".format(path))
with io.open(path, 'r', encoding='utf-8') as fp: