From c16120e2aae34039271b74481cabcd5aafec8341 Mon Sep 17 00:00:00 2001 From: debugtalk Date: Wed, 30 Aug 2017 16:54:55 +0800 Subject: [PATCH] save testcase file path in testset config --- ate/utils.py | 6 ++++-- tests/test_utils.py | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ate/utils.py b/ate/utils.py index 4922c0d3..3934c00d 100644 --- a/ate/utils.py +++ b/ate/utils.py @@ -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"]) diff --git a/tests/test_utils.py b/tests/test_utils.py index 18379b83..d033dbdb 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -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)