Skip to content

Commit 18e87c9

Browse files
committed
test(warnings-recorder): Add non working subclass behaviour of pop
1 parent 6995257 commit 18e87c9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

testing/test_recwarn.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,26 @@ def test_recwarn_captures_deprecation_warning(recwarn: WarningsRecorder) -> None
3737
assert recwarn.pop(DeprecationWarning)
3838

3939

40+
class TestSubclassWarningPop:
41+
class ParentWarning(Warning):
42+
pass
43+
44+
class ChildWarning(ParentWarning):
45+
pass
46+
47+
def raise_warnings(self):
48+
warnings.warn("Warning Child", self.ChildWarning)
49+
warnings.warn("Warning Parent", self.ParentWarning)
50+
51+
def test_pop(self):
52+
with pytest.warns((self.ParentWarning, self.ChildWarning)) as record:
53+
self.raise_warnings()
54+
55+
assert len(record) == 2
56+
_warn = record.pop(self.ParentWarning)
57+
assert _warn.category is self.ParentWarning
58+
59+
4060
class TestWarningsRecorderChecker:
4161
def test_recording(self) -> None:
4262
rec = WarningsRecorder(_ispytest=True)

0 commit comments

Comments
 (0)