Skip to content

Commit 2f13ef8

Browse files
committed
gh-134179: use sys._clear_internal_caches isntead of deprecated sys._clear_type_cache at test_cmd_line
1 parent 84914ad commit 2f13ef8

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
@@ -936,21 +935,15 @@ def test_python_asyncio_debug(self):
936935

937936
@unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option")
938937
def test_python_dump_refs(self):
939-
code = 'import sys; sys._clear_type_cache()'
940-
# TODO: Remove warnings context manager once sys._clear_type_cache is removed
941-
with warnings.catch_warnings():
942-
warnings.simplefilter("ignore", DeprecationWarning)
943-
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1')
938+
code = 'import sys; sys._clear_internal_caches()'
939+
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFS='1')
944940
self.assertEqual(rc, 0)
945941

946942
@unittest.skipUnless(sysconfig.get_config_var('Py_TRACE_REFS'), "Requires --with-trace-refs build option")
947943
def test_python_dump_refs_file(self):
948944
with tempfile.NamedTemporaryFile() as dump_file:
949-
code = 'import sys; sys._clear_type_cache()'
950-
# TODO: Remove warnings context manager once sys._clear_type_cache is removed
951-
with warnings.catch_warnings():
952-
warnings.simplefilter("ignore", DeprecationWarning)
953-
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name)
945+
code = 'import sys; sys._clear_internal_caches()'
946+
rc, out, err = assert_python_ok('-c', code, PYTHONDUMPREFSFILE=dump_file.name)
954947
self.assertEqual(rc, 0)
955948
with open(dump_file.name, 'r') as file:
956949
contents = file.read()

0 commit comments

Comments
 (0)