@@ -51,41 +51,18 @@ def test_warning_double_register_fail():
51
51
52
52
def test_warning_register ():
53
53
assert m .CustomWarning is not None
54
- assert issubclass (m .CustomWarning , DeprecationWarning )
55
54
56
55
with pytest .warns (m .CustomWarning ) as excinfo :
57
56
warnings .warn ("This is warning from Python!" , m .CustomWarning , stacklevel = 1 )
58
57
59
58
assert issubclass (excinfo [0 ].category , DeprecationWarning )
60
- assert issubclass (excinfo [0 ].category , m .CustomWarning )
61
59
assert str (excinfo [0 ].message ) == "This is warning from Python!"
62
60
63
61
64
- @pytest .mark .parametrize (
65
- (
66
- "expected_category" ,
67
- "expected_base" ,
68
- "expected_message" ,
69
- "expected_value" ,
70
- "module_function" ,
71
- ),
72
- [
73
- (
74
- m .CustomWarning ,
75
- DeprecationWarning ,
76
- "This is CustomWarning" ,
77
- 37 ,
78
- m .warn_with_custom_type ,
79
- ),
80
- ],
81
- )
82
- def test_warning_custom (
83
- expected_category , expected_base , expected_message , expected_value , module_function
84
- ):
85
- with pytest .warns (expected_category ) as excinfo :
86
- value = module_function ()
62
+ def test_warning_custom ():
63
+ with pytest .warns (m .CustomWarning ) as excinfo :
64
+ value = m .warn_with_custom_type ()
87
65
88
- assert issubclass (excinfo [0 ].category , expected_base )
89
- assert issubclass (excinfo [0 ].category , expected_category )
90
- assert str (excinfo [0 ].message ) == expected_message
91
- assert value == expected_value
66
+ assert issubclass (excinfo [0 ].category , DeprecationWarning )
67
+ assert str (excinfo [0 ].message ) == "This is CustomWarning"
68
+ assert value == 37
0 commit comments