Update tests for re-emitted warnings

This commit is contained in:
Zac Hatfield-Dodds
2023-06-30 15:29:03 -07:00
parent a1b37022af
commit 7022fb455d
2 changed files with 61 additions and 49 deletions

View File

@@ -135,8 +135,9 @@ def warns( # noqa: F811
>>> with pytest.warns(UserWarning, match=r'must be \d+$'):
... warnings.warn("value must be 42", UserWarning)
>>> with pytest.warns(UserWarning, match=r'must be \d+$'):
... warnings.warn("this is not here", UserWarning)
>>> with pytest.warns(UserWarning): # catch re-emitted warning
... with pytest.warns(UserWarning, match=r'must be \d+$'):
... warnings.warn("this is not here", UserWarning)
Traceback (most recent call last):
...
Failed: DID NOT WARN. No warnings of type ...UserWarning... were emitted...
@@ -327,7 +328,7 @@ class WarningsChecker(WarningsRecorder):
if not self.matches(w):
warnings.warn_explicit(
str(w.message),
w.message.__class__,
w.message.__class__, # type: ignore
w.filename,
w.lineno,
module=w.__module__,