mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
pass in specified .env file path
This commit is contained in:
@@ -212,18 +212,19 @@ class HttpRunner(object):
|
||||
|
||||
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.
|
||||
|
||||
Args:
|
||||
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.
|
||||
|
||||
Returns:
|
||||
instance: HttpRunner() instance
|
||||
|
||||
"""
|
||||
testcases = loader.load_tests(testcase_path)
|
||||
testcases = loader.load_tests(testcase_path, dot_env_path)
|
||||
return self.run_tests(testcases, mapping)
|
||||
|
||||
def gen_html_report(self, html_report_name=None, html_report_template=None):
|
||||
|
||||
@@ -79,10 +79,12 @@ def main_hrun():
|
||||
|
||||
try:
|
||||
runner = HttpRunner(
|
||||
failfast=args.failfast,
|
||||
failfast=args.failfast
|
||||
)
|
||||
runner.run(
|
||||
args.testset_paths,
|
||||
dot_env_path=args.dot_env_path
|
||||
)
|
||||
runner.run(args.testset_paths)
|
||||
except Exception:
|
||||
logger.log_error("!!!!!!!!!! exception stage: {} !!!!!!!!!!".format(runner.exception_stage))
|
||||
raise
|
||||
|
||||
@@ -935,7 +935,7 @@ def load_tests(path, dot_env_path=None):
|
||||
testcases_list = []
|
||||
|
||||
for file_path in set(path):
|
||||
testcases = load_tests(file_path)
|
||||
testcases = load_tests(file_path, dot_env_path)
|
||||
if not testcases:
|
||||
continue
|
||||
testcases_list.extend(testcases)
|
||||
@@ -952,7 +952,7 @@ def load_tests(path, dot_env_path=None):
|
||||
|
||||
if os.path.isdir(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):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user