Skip to content

Commit dd2da42

Browse files
gh-134179: Use sys._clear_internal_caches() at test_cmd_line (#134180)
Use sys._clear_internal_caches() instead of deprecated sys._clear_type_cache() at test_cmd_line.
1 parent ff531f9 commit dd2da42

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

Lib/test/test_cmd_line.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import tempfile
1010
import textwrap
1111
import unittest
12-
import warnings
1312
from test import support
1413
from test.support import os_helper
1514
from test.support import force_not_colorized
@@ -943,21 +942,15 @@ def test_python_asyncio_debug(self):
943942

944943
@unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option")
945944
def test_python_dump_refs(self):
946-
code = 'import sys; sys._clear_type_cache()'
947-
# TODO: Remove warnings context manager once sys._clear_type_cache is removed
948-
with warnings.catch_warnings():
949-
warnings.simplefilter("ignore", DeprecationWarning)
950-
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1')
945+
code = 'import sys; sys._clear_internal_caches()'
946+
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1')
951947
self.assertEqual(rc, 0)
952948

953949
@unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option")
954950
def test_python_dump_refs_file(self):
955951
with tempfile.NamedTemporaryFile() as dump_file:
956-
code = 'import sys; sys._clear_type_cache()'
957-
# TODO: Remove warnings context manager once sys._clear_type_cache is removed
958-
with warnings.catch_warnings():
959-
warnings.simplefilter("ignore", DeprecationWarning)
960-
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name)
952+
code = 'import sys; sys._clear_internal_caches()'
953+
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name)
961954
self.assertEqual(rc, 0)
962955
with open(dump_file.name, 'r') as file:
963956
contents = file.read()

0 commit comments

Comments
 (0)