mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-05 22:41:22 +08:00
pass in specified .env file path
This commit is contained in:
@@ -212,18 +212,19 @@ class HttpRunner(object):
|
|||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def run(self, testcase_path, mapping=None):
|
def run(self, testcase_path, dot_env_path=None, mapping=None):
|
||||||
""" main entrance, run testcase path with variables mapping.
|
""" main entrance, run testcase path with variables mapping.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
testcase_path (str/list): testcase file/foler path.
|
testcase_path (str/list): testcase file/foler path.
|
||||||
|
dot_env_path (str): specified .env file path.
|
||||||
mapping (dict): if mapping is specified, it will override variables in config block.
|
mapping (dict): if mapping is specified, it will override variables in config block.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
instance: HttpRunner() instance
|
instance: HttpRunner() instance
|
||||||
|
|
||||||
"""
|
"""
|
||||||
testcases = loader.load_tests(testcase_path)
|
testcases = loader.load_tests(testcase_path, dot_env_path)
|
||||||
return self.run_tests(testcases, mapping)
|
return self.run_tests(testcases, mapping)
|
||||||
|
|
||||||
def gen_html_report(self, html_report_name=None, html_report_template=None):
|
def gen_html_report(self, html_report_name=None, html_report_template=None):
|
||||||
|
|||||||
@@ -79,10 +79,12 @@ def main_hrun():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
runner = HttpRunner(
|
runner = HttpRunner(
|
||||||
failfast=args.failfast,
|
failfast=args.failfast
|
||||||
|
)
|
||||||
|
runner.run(
|
||||||
|
args.testset_paths,
|
||||||
dot_env_path=args.dot_env_path
|
dot_env_path=args.dot_env_path
|
||||||
)
|
)
|
||||||
runner.run(args.testset_paths)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_error("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage))
|
logger.log_error("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage))
|
||||||
raise
|
raise
|
||||||
|
|||||||
@@ -935,7 +935,7 @@ def load_tests(path, dot_env_path=None):
|
|||||||
testcases_list = []
|
testcases_list = []
|
||||||
|
|
||||||
for file_path in set(path):
|
for file_path in set(path):
|
||||||
testcases = load_tests(file_path)
|
testcases = load_tests(file_path, dot_env_path)
|
||||||
if not testcases:
|
if not testcases:
|
||||||
continue
|
continue
|
||||||
testcases_list.extend(testcases)
|
testcases_list.extend(testcases)
|
||||||
@@ -952,7 +952,7 @@ def load_tests(path, dot_env_path=None):
|
|||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
files_list = load_folder_files(path)
|
files_list = load_folder_files(path)
|
||||||
testcases_list = load_tests(files_list)
|
testcases_list = load_tests(files_list, dot_env_path)
|
||||||
|
|
||||||
elif os.path.isfile(path):
|
elif os.path.isfile(path):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user