From 09db20e9fcd78df64c4882a6bf0ba1de152f46ef Mon Sep 17 00:00:00 2001 From: debugtalk Date: Fri, 23 Nov 2018 11:19:01 +0800 Subject: [PATCH] save tests: add debugtalk.py file path --- httprunner/utils.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/httprunner/utils.py b/httprunner/utils.py index 9b381fa2..77515177 100644 --- a/httprunner/utils.py +++ b/httprunner/utils.py @@ -597,12 +597,19 @@ def dump_tests(tests_mapping, tag_name): file_name, file_suffix = os.path.splitext(os.path.basename(test_path)) dump_file_path = os.path.join(dir_path, "{}.{}.json".format(file_name, tag_name)) - tests_to_dump = { - "project_mapping": { - key: project_mapping[key] for key in project_mapping if key != "functions" - }, - "testcases": tests_mapping["testcases"] - } + tests_to_dump = {} + + for key in project_mapping: + if key != "functions": + tests_to_dump[key] = project_mapping[key] + continue + + if project_mapping["functions"]: + debugtalk_py_path = os.path.join(dir_path, "debugtalk.py") + tests_to_dump["debugtalk.py"] = debugtalk_py_path + + tests_to_dump["testcases"] = tests_mapping["testcases"] + with open(dump_file_path, 'w', encoding='utf-8') as outfile: json.dump(tests_to_dump, outfile, indent=4, separators=(',', ': '))