Skip to content

Commit d6fd9f4

Browse files
authored
🎨 Improve codes readability (via #501)
1 parent 8d14ec0 commit d6fd9f4

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

allure-pytest/src/plugin.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,24 @@ def select_by_testcase(items):
156156
plan = json.load(plan_file)
157157
planned_tests = plan.get("tests", [])
158158

159-
return filter(lambda item: any(
160-
[str(planed_item.get("id")) in [str(allure_id) for allure_id in allure_label(item, LabelType.ID)]
161-
or
162-
(planed_item.get("selector") == allure_full_name(item))
163-
for planed_item in planned_tests]), items) if planned_tests else items
159+
if planned_tests:
160+
161+
def is_planed(item):
162+
allure_ids = allure_label(item, LabelType.ID)
163+
allure_string_ids = list(map(str, allure_ids))
164+
for planed_item in planned_tests:
165+
planed_item_string_id = str(planed_item.get("id"))
166+
planed_item_selector = planed_item.get("selector")
167+
if (
168+
planed_item_string_id in allure_string_ids
169+
or planed_item_selector == allure_full_name(item)
170+
):
171+
return True
172+
return False
173+
174+
return [item for item in items if is_planed(item)]
175+
else:
176+
return items
164177

165178

166179
def pytest_collection_modifyitems(items, config):

0 commit comments

Comments
 (0)