Skip to content

Commit 9cc8e49

Browse files
[3.14] gh-134179: Use sys._clear_internal_caches() at test_cmd_line (GH-134180) (#144631)
gh-134179: Use sys._clear_internal_caches() at test_cmd_line (GH-134180) Use sys._clear_internal_caches() instead of deprecated sys._clear_type_cache() at test_cmd_line. (cherry picked from commit dd2da42) Co-authored-by: alexey semenyuk <alexsemenyuk88@gmail.com>
1 parent c9646df commit 9cc8e49

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

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

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

0 commit comments

Comments
 (0)