mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-13 06:59:45 +08:00
save testcase file path in testset config
This commit is contained in:
@@ -102,7 +102,9 @@ def load_testcases_by_path(path):
|
||||
elif os.path.isfile(path):
|
||||
testset = {
|
||||
"name": "",
|
||||
"config": {},
|
||||
"config": {
|
||||
"path": path
|
||||
},
|
||||
"testcases": []
|
||||
}
|
||||
testcases_list = load_testcases(path)
|
||||
@@ -110,7 +112,7 @@ def load_testcases_by_path(path):
|
||||
for item in testcases_list:
|
||||
for key in item:
|
||||
if key == "config":
|
||||
testset["config"] = item["config"]
|
||||
testset["config"].update(item["config"])
|
||||
testset["name"] = item["config"].get("name", "")
|
||||
elif key == "test":
|
||||
testset["testcases"].append(item["test"])
|
||||
|
||||
@@ -48,6 +48,8 @@ class TestUtils(ApiServerUnittest):
|
||||
os.getcwd(), 'tests/data/demo_testset_hardcode.json')
|
||||
testset_list = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list), 1)
|
||||
self.assertIn("path", testset_list[0]["config"])
|
||||
self.assertEqual(testset_list[0]["config"]["path"], path)
|
||||
self.assertEqual(len(testset_list[0]["testcases"]), 3)
|
||||
testsets_list.extend(testset_list)
|
||||
|
||||
@@ -55,6 +57,8 @@ class TestUtils(ApiServerUnittest):
|
||||
path = 'tests/data/demo_testset_hardcode.yml'
|
||||
testset_list = utils.load_testcases_by_path(path)
|
||||
self.assertEqual(len(testset_list), 1)
|
||||
self.assertIn("path", testset_list[0]["config"])
|
||||
self.assertIn(path, testset_list[0]["config"]["path"])
|
||||
self.assertEqual(len(testset_list[0]["testcases"]), 3)
|
||||
testsets_list.extend(testset_list)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user