Skip to content

Commit 7b7bd30

Browse files
committed
fix(warnings-recorder): Add handling of rest
1 parent 2706271 commit 7b7bd30

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/_pytest/recwarn.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ def pop(self, cls: Type[Warning] = Warning) -> "warnings.WarningMessage":
217217
__tracebackhide__ = True
218218
raise AssertionError(f"{cls!r} not found in warning list")
219219
(idx, best), *rest = matches
220+
for i, w in rest:
221+
if issubclass(w.category, best.category) and not issubclass(
222+
best.category, w.category
223+
):
224+
idx, best = i, w
220225
return self._list.pop(idx)
221226

222227
def clear(self) -> None:

0 commit comments

Comments
 (0)