upgrade to 0.9.7: support .env file

This commit is contained in:
debugtalk
2018-02-27 16:36:05 +08:00
parent 98c72c7890
commit 41c979e897
4 changed files with 25 additions and 2 deletions

View File

@@ -7,7 +7,8 @@ import unittest
from httprunner import logger
from httprunner.__about__ import __version__
from httprunner.task import HttpRunner
from httprunner.utils import create_scaffold, print_output, string_type
from httprunner.utils import (create_scaffold, load_dot_env_file, print_output,
string_type)
def main_hrun():
@@ -30,6 +31,9 @@ def main_hrun():
parser.add_argument(
'--log-level', default='INFO',
help="Specify logging level, default is INFO.")
parser.add_argument(
'--dot-env-path',
help="Specify .env file path, which is useful for keeping production credentials.")
parser.add_argument(
'--failfast', action='store_true', default=False,
help="Stop the test run on the first error or failure.")
@@ -44,6 +48,10 @@ def main_hrun():
logger.color_print("{}".format(__version__), "GREEN")
exit(0)
dot_env_path = args.dot_env_path or os.path.join(os.getcwd(), ".env")
if dot_env_path:
load_dot_env_file(dot_env_path)
project_name = args.startproject
if project_name:
project_path = os.path.join(os.getcwd(), project_name)