mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-21 16:23:16 +08:00
relocate .env file loader
This commit is contained in:
@@ -375,25 +375,6 @@ def create_scaffold(project_path):
|
||||
|
||||
logger.color_print(msg, "BLUE")
|
||||
|
||||
def load_dot_env_file(path):
|
||||
""" load .env file and set to os.environ
|
||||
"""
|
||||
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 exceptions.FileNotFound("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:
|
||||
for line in fp:
|
||||
variable, value = line.split("=")
|
||||
variable = variable.strip()
|
||||
os.environ[variable] = value.strip()
|
||||
logger.log_debug("Loaded variable: {}".format(variable))
|
||||
|
||||
def validate_json_file(file_list):
|
||||
""" validate JSON testset format
|
||||
|
||||
Reference in New Issue
Block a user