File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,26 @@ def test_recwarn_captures_deprecation_warning(recwarn: WarningsRecorder) -> None
37
37
assert recwarn .pop (DeprecationWarning )
38
38
39
39
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
+
40
60
class TestWarningsRecorderChecker :
41
61
def test_recording (self ) -> None :
42
62
rec = WarningsRecorder (_ispytest = True )
You can’t perform that action at this time.
0 commit comments