We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9c4ffb5 commit 48ded39Copy full SHA for 48ded39
src/_pytest/recwarn.py
@@ -332,8 +332,11 @@ def found_str():
332
# Check warnings has valid argument type (#10865).
333
wrn: warnings.WarningMessage
334
for wrn in self:
335
- if isinstance(wrn.message, Warning):
336
- if not isinstance(msg := wrn.message.args[0], str):
337
- raise TypeError(
338
- f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
339
- )
+ self._validate_message(wrn)
+
+ @staticmethod
+ def _validate_message(wrn: Any) -> None:
+ if not isinstance(msg := wrn.message.args[0], str):
340
+ raise TypeError(
341
+ f"Warning message must be str, got {msg!r} (type {type(msg).__name__})"
342
+ )
0 commit comments