@@ -61,6 +61,26 @@ def _caplog():
6161
6262
6363class TestSupport (unittest .TestCase ):
64+ @classmethod
65+ def setUpClass (cls ):
66+ orig_filter_len = len (warnings ._get_filters ())
67+ cls ._warnings_helper_token = support .ignore_deprecations_from (
68+ "test.support.warnings_helper" , like = ".*used in test_support.*"
69+ )
70+ cls ._test_support_token = support .ignore_deprecations_from (
71+ __name__ , like = ".*You should NOT be seeing this.*"
72+ )
73+ assert len (warnings ._get_filters ()) == orig_filter_len + 2
74+
75+ @classmethod
76+ def tearDownClass (cls ):
77+ orig_filter_len = len (warnings ._get_filters ())
78+ support .clear_ignored_deprecations (
79+ cls ._warnings_helper_token ,
80+ cls ._test_support_token ,
81+ )
82+ assert len (warnings ._get_filters ()) == orig_filter_len - 2
83+
6484 def test_check_sanitizer_config_args (self ):
6585 sanitizers = (
6686 ('address' , 'address' ),
@@ -84,26 +104,6 @@ def test_check_sanitizer_config_args(self):
84104 support .check_sanitizer (** {keyword : True }), expected
85105 )
86106
87- @classmethod
88- def setUpClass (cls ):
89- orig_filter_len = len (warnings ._get_filters ())
90- cls ._warnings_helper_token = support .ignore_deprecations_from (
91- "test.support.warnings_helper" , like = ".*used in test_support.*"
92- )
93- cls ._test_support_token = support .ignore_deprecations_from (
94- __name__ , like = ".*You should NOT be seeing this.*"
95- )
96- assert len (warnings ._get_filters ()) == orig_filter_len + 2
97-
98- @classmethod
99- def tearDownClass (cls ):
100- orig_filter_len = len (warnings ._get_filters ())
101- support .clear_ignored_deprecations (
102- cls ._warnings_helper_token ,
103- cls ._test_support_token ,
104- )
105- assert len (warnings ._get_filters ()) == orig_filter_len - 2
106-
107107 def test_ignored_deprecations_are_silent (self ):
108108 """Test support.ignore_deprecations_from() silences warnings"""
109109 with warnings .catch_warnings (record = True ) as warning_objs :
0 commit comments