mirror of
https://github.com/httprunner/httprunner.git
synced 2026-07-07 15:31:23 +08:00
change: generate logs folder in current working directory
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
- remove support for Python 2.7
|
- remove support for Python 2.7
|
||||||
- replace string format with f-string
|
- replace string format with f-string
|
||||||
- remove dependency colorama and colorlog
|
- remove dependency colorama and colorlog
|
||||||
- generate reports folder in current working directory
|
- generate reports/logs folder in current working directory
|
||||||
|
|
||||||
## 2.5.7 (2020-02-21)
|
## 2.5.7 (2020-02-21)
|
||||||
|
|
||||||
|
|||||||
@@ -419,7 +419,7 @@ def load_project_data(test_path, dot_env_path=None):
|
|||||||
# locate PWD and load debugtalk.py functions
|
# locate PWD and load debugtalk.py functions
|
||||||
project_mapping["PWD"] = project_working_directory
|
project_mapping["PWD"] = project_working_directory
|
||||||
project_mapping["functions"] = debugtalk_functions
|
project_mapping["functions"] = debugtalk_functions
|
||||||
project_mapping["test_path"] = os.path.abspath(test_path)
|
project_mapping["test_path"] = os.path.abspath(test_path)[len(project_working_directory)+1:]
|
||||||
|
|
||||||
return project_mapping
|
return project_mapping
|
||||||
|
|
||||||
|
|||||||
@@ -596,24 +596,23 @@ def dump_json_file(json_data, json_file_abs_path):
|
|||||||
def prepare_dump_json_file_abs_path(project_mapping, tag_name):
|
def prepare_dump_json_file_abs_path(project_mapping, tag_name):
|
||||||
""" prepare dump json file absolute path.
|
""" prepare dump json file absolute path.
|
||||||
"""
|
"""
|
||||||
pwd_dir_path = project_mapping.get("PWD") or os.getcwd()
|
current_working_dir = os.getcwd()
|
||||||
test_path = project_mapping.get("test_path")
|
test_path = project_mapping.get("test_path")
|
||||||
|
|
||||||
if not test_path:
|
if not test_path:
|
||||||
# running passed in testcase/testsuite data structure
|
# running passed in testcase/testsuite data structure
|
||||||
dump_file_name = f"tests_mapping.{tag_name}.json"
|
dump_file_name = f"tests_mapping.{tag_name}.json"
|
||||||
dumped_json_file_abs_path = os.path.join(pwd_dir_path, "logs", dump_file_name)
|
dumped_json_file_abs_path = os.path.join(current_working_dir, "logs", dump_file_name)
|
||||||
return dumped_json_file_abs_path
|
return dumped_json_file_abs_path
|
||||||
|
|
||||||
# both test_path and pwd_dir_path are absolute path
|
# both test_path and pwd_dir_path are absolute path
|
||||||
logs_dir_path = os.path.join(pwd_dir_path, "logs")
|
logs_dir_path = os.path.join(current_working_dir, "logs")
|
||||||
test_path_relative_path = test_path[len(pwd_dir_path)+1:]
|
|
||||||
|
|
||||||
if os.path.isdir(test_path):
|
if os.path.isdir(test_path):
|
||||||
file_foder_path = os.path.join(logs_dir_path, test_path_relative_path)
|
file_foder_path = os.path.join(logs_dir_path, test_path)
|
||||||
dump_file_name = f"all.{tag_name}.json"
|
dump_file_name = f"all.{tag_name}.json"
|
||||||
else:
|
else:
|
||||||
file_relative_folder_path, test_file = os.path.split(test_path_relative_path)
|
file_relative_folder_path, test_file = os.path.split(test_path)
|
||||||
file_foder_path = os.path.join(logs_dir_path, file_relative_folder_path)
|
file_foder_path = os.path.join(logs_dir_path, file_relative_folder_path)
|
||||||
test_file_name, _file_suffix = os.path.splitext(test_file)
|
test_file_name, _file_suffix = os.path.splitext(test_file)
|
||||||
dump_file_name = f"{test_file_name}.{tag_name}.json"
|
dump_file_name = f"{test_file_name}.{tag_name}.json"
|
||||||
|
|||||||
@@ -278,26 +278,22 @@ class TestUtils(unittest.TestCase):
|
|||||||
|
|
||||||
def test_prepare_dump_json_file_path_for_folder(self):
|
def test_prepare_dump_json_file_path_for_folder(self):
|
||||||
# hrun tests/httpbin/a.b.c/ --save-tests
|
# hrun tests/httpbin/a.b.c/ --save-tests
|
||||||
project_working_directory = os.path.join(os.getcwd(), "tests")
|
|
||||||
project_mapping = {
|
project_mapping = {
|
||||||
"PWD": project_working_directory,
|
"test_path": os.path.join("tests", "httpbin", "a.b.c")
|
||||||
"test_path": os.path.join(os.getcwd(), "tests", "httpbin", "a.b.c")
|
|
||||||
}
|
}
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
||||||
os.path.join(project_working_directory, "logs", "httpbin/a.b.c/all.loaded.json")
|
os.path.join(os.getcwd(), "logs", "tests/httpbin/a.b.c/all.loaded.json")
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_prepare_dump_json_file_path_for_file(self):
|
def test_prepare_dump_json_file_path_for_file(self):
|
||||||
# hrun tests/httpbin/a.b.c/rpc.yml --save-tests
|
# hrun tests/httpbin/a.b.c/rpc.yml --save-tests
|
||||||
project_working_directory = os.path.join(os.getcwd(), "tests")
|
|
||||||
project_mapping = {
|
project_mapping = {
|
||||||
"PWD": project_working_directory,
|
"test_path": os.path.join("tests", "httpbin", "a.b.c", "rpc.yml")
|
||||||
"test_path": os.path.join(os.getcwd(), "tests", "httpbin", "a.b.c", "rpc.yml")
|
|
||||||
}
|
}
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
||||||
os.path.join(project_working_directory, "logs", "httpbin/a.b.c/rpc.loaded.json")
|
os.path.join(os.getcwd(), "logs", "tests/httpbin/a.b.c/rpc.loaded.json")
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_prepare_dump_json_file_path_for_passed_testcase(self):
|
def test_prepare_dump_json_file_path_for_passed_testcase(self):
|
||||||
@@ -307,5 +303,5 @@ class TestUtils(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
utils.prepare_dump_json_file_abs_path(project_mapping, "loaded"),
|
||||||
os.path.join(project_working_directory, "logs", "tests_mapping.loaded.json")
|
os.path.join(os.getcwd(), "logs", "tests_mapping.loaded.json")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user