implement @bluetech changes

implement code review changes
This commit is contained in:
Reagan Lee 2024-02-03 15:39:49 -08:00
parent 5feabaab41
commit 497ffc51c1
3 changed files with 7 additions and 4 deletions

View File

@ -0,0 +1 @@
Fix regression with :func:`pytest.warns` using custom warning subclasses which have more than one parameter in their `__init__`.

View File

@ -322,10 +322,10 @@ class WarningsChecker(WarningsRecorder):
for w in self:
if not self.matches(w):
warnings.warn_explicit(
str(w.message),
w.message.__class__, # type: ignore[arg-type]
w.filename,
w.lineno,
message=w.message,
category=w.category,
filename=w.filename,
lineno=w.lineno,
module=w.__module__,
source=w.source,
)

View File

@ -480,6 +480,8 @@ class TestWarns:
raise ValueError("some exception")
def test_multiple_arg_custom_warning(self) -> None:
"""Test for issue #11906."""
class CustomWarning(UserWarning):
def __init__(self, a, b):
pass