Skip to content

Commit 0270181

Browse files
committed
feat: 10865 fix v2 for codecov
1 parent 269b674 commit 0270181

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/_pytest/recwarn.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ def found_str():
334334
# Check warnings has valid argument type (#10865).
335335
wrn: warnings.WarningMessage
336336
for wrn in self:
337-
if isinstance(wrn.message, Warning):
338-
if not isinstance(msg := wrn.message.args[0], str):
339-
raise TypeError(
340-
f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
341-
)
337+
self._validate_message(wrn)
338+
339+
@staticmethod
340+
def _validate_message(wrn: Any) -> None:
341+
if not isinstance(msg := wrn.message.args[0], str):
342+
raise TypeError(
343+
f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
344+
)

0 commit comments

Comments
 (0)