mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 19:39:44 +08:00
fix: fix load_tests for not exist path
This commit is contained in:
@@ -257,9 +257,7 @@ class HttpRunner(object):
|
||||
"""
|
||||
# load tests
|
||||
self.exception_stage = "load tests"
|
||||
path = loader.prepare_path(path)
|
||||
tests_mapping = loader.load_tests(path, dot_env_path)
|
||||
tests_mapping["project_mapping"]["test_path"] = path
|
||||
|
||||
if mapping:
|
||||
tests_mapping["project_mapping"]["variables"] = mapping
|
||||
|
||||
@@ -779,6 +779,19 @@ def load_project_tests(test_path, dot_env_path=None):
|
||||
environments and debugtalk.py functions.
|
||||
|
||||
"""
|
||||
|
||||
def prepare_path(path):
|
||||
if not os.path.exists(path):
|
||||
err_msg = "path not exist: {}".format(path)
|
||||
logger.log_error(err_msg)
|
||||
raise exceptions.FileNotFound(err_msg)
|
||||
|
||||
if not os.path.isabs(path):
|
||||
path = os.path.join(os.getcwd(), path)
|
||||
|
||||
return path
|
||||
|
||||
test_path = prepare_path(test_path)
|
||||
# locate debugtalk.py file
|
||||
debugtalk_path = locate_debugtalk_py(test_path)
|
||||
|
||||
@@ -810,24 +823,13 @@ def load_project_tests(test_path, dot_env_path=None):
|
||||
project_mapping["PWD"] = project_working_directory
|
||||
built_in.PWD = project_working_directory
|
||||
project_mapping["functions"] = debugtalk_functions
|
||||
project_mapping["test_path"] = test_path
|
||||
|
||||
# load api
|
||||
tests_def_mapping["api"] = load_api_folder(os.path.join(project_working_directory, "api"))
|
||||
tests_def_mapping["PWD"] = project_working_directory
|
||||
|
||||
|
||||
def prepare_path(path):
|
||||
if not os.path.exists(path):
|
||||
err_msg = "path not exist: {}".format(path)
|
||||
logger.log_error(err_msg)
|
||||
raise exceptions.FileNotFound(err_msg)
|
||||
|
||||
if not os.path.isabs(path):
|
||||
path = os.path.join(os.getcwd(), path)
|
||||
|
||||
return path
|
||||
|
||||
|
||||
def load_tests(path, dot_env_path=None):
|
||||
""" load testcases from file path, extend and merge with api/testcase definitions.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user