Skip to content

Commit 6dd8ad6

Browse files
committed
refactor(MarkMatcher): replace from_item with from_markers method
1 parent 1e7eb20 commit 6dd8ad6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/_pytest/mark/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import dataclasses
77
from typing import AbstractSet
88
from typing import Collection
9+
from typing import Iterable
910
from typing import Optional
1011
from typing import TYPE_CHECKING
1112

@@ -227,9 +228,9 @@ class MarkMatcher:
227228
own_mark_name_mapping: dict[str, list[Mark]]
228229

229230
@classmethod
230-
def from_item(cls, item: Item) -> MarkMatcher:
231+
def from_markers(cls, markers: Iterable[Mark]) -> MarkMatcher:
231232
mark_name_mapping = collections.defaultdict(list)
232-
for mark in item.iter_markers():
233+
for mark in markers:
233234
mark_name_mapping[mark.name].append(mark)
234235
return cls(mark_name_mapping)
235236

@@ -256,7 +257,7 @@ def deselect_by_mark(items: list[Item], config: Config) -> None:
256257
remaining: list[Item] = []
257258
deselected: list[Item] = []
258259
for item in items:
259-
if expr.evaluate(MarkMatcher.from_item(item)):
260+
if expr.evaluate(MarkMatcher.from_markers(item.iter_markers())):
260261
remaining.append(item)
261262
else:
262263
deselected.append(item)

0 commit comments

Comments
 (0)