Skip to content

Commit 1ad01cd

Browse files
authored
change testplan format (via #482)
1 parent b6a166c commit 1ad01cd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

allure-pytest/src/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,18 +148,19 @@ def select_by_labels(items, config):
148148

149149

150150
def select_by_testcase(items):
151-
plan = []
151+
planned_tests = []
152152
file_path = os.environ.get("AS_TESTPLAN_PATH")
153153

154154
if file_path:
155155
with open(file_path, 'r') as plan_file:
156156
plan = json.load(plan_file)
157+
planned_tests = plan.get("tests", [])
157158

158159
return filter(lambda item: any(
159160
[str(planed_item.get("id")) in [str(allure_id) for allure_id in allure_label(item, LabelType.ID)]
160161
or
161162
(planed_item.get("selector") == allure_full_name(item))
162-
for planed_item in plan]), items) if plan else items
163+
for planed_item in planned_tests]), items) if planned_tests else items
163164

164165

165166
def pytest_collection_modifyitems(items, config):

allure-pytest/test/integration/allure_ee/select_by_testcase_id_test.py renamed to allure-pytest/test/integration/allure_ee/select_test_from_testplan_test.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77
@pytest.mark.parametrize(
8-
["plan_json", "expected_tests"],
8+
["planned_tests", "expected_tests"],
99
[
1010
# by ids only
1111
(
@@ -56,7 +56,7 @@
5656
),
5757
]
5858
)
59-
def test_select_by_testcase_id_test(plan_json, expected_tests, allured_testdir, request):
59+
def test_select_by_testcase_id_test(planned_tests, expected_tests, allured_testdir, request):
6060
"""
6161
>>> import allure
6262
@@ -82,11 +82,13 @@ def test_select_by_testcase_id_test(plan_json, expected_tests, allured_testdir,
8282
full_name_base_template = "{base}.test_select_by_testcase_id_test".format(
8383
base=test_dir.strip(os.sep).replace(os.sep, "."))
8484

85-
if plan_json:
86-
for item in plan_json:
85+
if planned_tests:
86+
for item in planned_tests:
8787
if "selector" in item:
8888
item["selector"] = "{base}#{name}".format(base=full_name_base_template, name=item["selector"])
89-
py_path = allured_testdir.testdir.makefile(".json", json.dumps(plan_json))
89+
90+
testplan = {"tests": planned_tests}
91+
py_path = allured_testdir.testdir.makefile(".json", json.dumps(testplan))
9092
os.environ["AS_TESTPLAN_PATH"] = py_path.strpath
9193
else:
9294
os.environ.pop("AS_TESTPLAN_PATH", None)

0 commit comments

Comments
 (0)