fix #343: locate debugtalk.py and use as project working directory

This commit is contained in:
debugtalk
2018-08-23 13:03:42 +08:00
parent 0648ee9bf6
commit e2ba773e78
8 changed files with 70 additions and 68 deletions

View File

@@ -36,22 +36,6 @@ class HttpRunner(object):
self.kwargs = kwargs
self.http_client_session = self.kwargs.pop("http_client_session", None)
self.__loader()
def __loader(self):
""" load project dependent files, including api/testcase definitions,
environment variables and builtin module.
"""
loader.reset_loader()
# load api/testcase definition and debugtalk.py module
project_folder_path = os.path.join(os.getcwd(), "tests") # TODO: remove tests
loader.load_project_tests(project_folder_path)
self.project_mapping = loader.project_mapping
utils.set_os_environ(self.project_mapping["env"])
def load_tests(self, path_or_testcases):
""" load testcases, extend and merge with api/testcase definitions.
@@ -94,14 +78,14 @@ class HttpRunner(object):
if isinstance(path_or_testcases, list):
for testcase in path_or_testcases:
try:
dir_path = os.path.dirname(testcase["config"]["path"])
loader.load_debugtalk_module(dir_path)
test_path = os.path.dirname(testcase["config"]["path"])
loader.load_project_tests(test_path)
except KeyError:
pass
else:
try:
dir_path = os.path.dirname(path_or_testcases["config"]["path"])
loader.load_debugtalk_module(dir_path)
test_path = os.path.dirname(path_or_testcases["config"]["path"])
loader.load_project_tests(test_path)
except KeyError:
pass
@@ -109,6 +93,8 @@ class HttpRunner(object):
else:
testcases = loader.load_testcases(path_or_testcases)
self.project_mapping = loader.project_mapping
if not testcases:
raise exceptions.TestcaseNotFound
@@ -245,8 +231,9 @@ class HttpRunner(object):
instance: HttpRunner() instance
"""
# parser
# loader
testcases_list = self.load_tests(path_or_testcases)
# parser
parsed_testcases_list = self.parse_tests(testcases_list)
# initialize