Skip to content

Commit 7abfc49

Browse files
committed
Write a test case for deprecationwarning
1 parent 1b184c6 commit 7abfc49

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Lib/test/test_sys.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,12 @@ def test_sys_getwindowsversion_no_instantiation(self):
850850

851851
@test.support.cpython_only
852852
def test_clear_type_cache(self):
853-
sys._clear_type_cache()
853+
with warnings.catch_warnings(record=True) as w:
854+
warnings.simplefilter("always")
855+
sys._clear_type_cache()
856+
self.assertEqual(len(w), 1)
857+
self.assertTrue(issubclass(w[0].category, DeprecationWarning))
858+
self.assertIn("_clear_type_cache", str(w[0].message))
854859

855860
@force_not_colorized
856861
@support.requires_subprocess()

0 commit comments

Comments
 (0)