bug fix
implement @bluetech changes implement code review changes
This commit is contained in:
parent
5feabaab41
commit
497ffc51c1
|
@ -0,0 +1 @@
|
||||||
|
Fix regression with :func:`pytest.warns` using custom warning subclasses which have more than one parameter in their `__init__`.
|
|
@ -322,10 +322,10 @@ class WarningsChecker(WarningsRecorder):
|
||||||
for w in self:
|
for w in self:
|
||||||
if not self.matches(w):
|
if not self.matches(w):
|
||||||
warnings.warn_explicit(
|
warnings.warn_explicit(
|
||||||
str(w.message),
|
message=w.message,
|
||||||
w.message.__class__, # type: ignore[arg-type]
|
category=w.category,
|
||||||
w.filename,
|
filename=w.filename,
|
||||||
w.lineno,
|
lineno=w.lineno,
|
||||||
module=w.__module__,
|
module=w.__module__,
|
||||||
source=w.source,
|
source=w.source,
|
||||||
)
|
)
|
||||||
|
|
|
@ -480,6 +480,8 @@ class TestWarns:
|
||||||
raise ValueError("some exception")
|
raise ValueError("some exception")
|
||||||
|
|
||||||
def test_multiple_arg_custom_warning(self) -> None:
|
def test_multiple_arg_custom_warning(self) -> None:
|
||||||
|
"""Test for issue #11906."""
|
||||||
|
|
||||||
class CustomWarning(UserWarning):
|
class CustomWarning(UserWarning):
|
||||||
def __init__(self, a, b):
|
def __init__(self, a, b):
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in New Issue