mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-08 17:29:34 +08:00
fix: fix load_tests for not exist path
This commit is contained in:
@@ -257,9 +257,7 @@ class HttpRunner(object):
|
|||||||
"""
|
"""
|
||||||
# load tests
|
# load tests
|
||||||
self.exception_stage = "load tests"
|
self.exception_stage = "load tests"
|
||||||
path = loader.prepare_path(path)
|
|
||||||
tests_mapping = loader.load_tests(path, dot_env_path)
|
tests_mapping = loader.load_tests(path, dot_env_path)
|
||||||
tests_mapping["project_mapping"]["test_path"] = path
|
|
||||||
|
|
||||||
if mapping:
|
if mapping:
|
||||||
tests_mapping["project_mapping"]["variables"] = 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.
|
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
|
# locate debugtalk.py file
|
||||||
debugtalk_path = locate_debugtalk_py(test_path)
|
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
|
project_mapping["PWD"] = project_working_directory
|
||||||
built_in.PWD = project_working_directory
|
built_in.PWD = project_working_directory
|
||||||
project_mapping["functions"] = debugtalk_functions
|
project_mapping["functions"] = debugtalk_functions
|
||||||
|
project_mapping["test_path"] = test_path
|
||||||
|
|
||||||
# load api
|
# load api
|
||||||
tests_def_mapping["api"] = load_api_folder(os.path.join(project_working_directory, "api"))
|
tests_def_mapping["api"] = load_api_folder(os.path.join(project_working_directory, "api"))
|
||||||
tests_def_mapping["PWD"] = project_working_directory
|
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):
|
def load_tests(path, dot_env_path=None):
|
||||||
""" load testcases from file path, extend and merge with api/testcase definitions.
|
""" load testcases from file path, extend and merge with api/testcase definitions.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user