Update tests with deprecated get_c_recursion_limit (#7039)

This commit is contained in:
Shahar Naveh authored and GitHub committed 2026-02-08 09:59:14 +09:00
1 parent bff70f957f
commit 87289fd904
6 files changed
+28 -29

No files matched your search

+5 -2
View File
@@ -6,7 +6,8 @@ import sys
from functools import cmp_to_key
from test import seq_tests
from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit
from test.support import ALWAYS_EQ, NEVER_EQ
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow
class CommonTest(seq_tests.CommonTest):
@@ -59,9 +60,11 @@ class CommonTest(seq_tests.CommonTest):
self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
@skip_wasi_stack_overflow()
@skip_emscripten_stack_overflow()
def test_repr_deep(self):
a = self.type2test([])
for i in range(get_c_recursion_limit() + 1):
for i in range(200_000):
a = self.type2test([a])
self.assertRaises(RecursionError, repr, a)
+1 -2
View File
@@ -426,8 +426,7 @@ class CommonTest(unittest.TestCase):
self.assertEqual(lst2, lst)
self.assertNotEqual(id(lst2), id(lst))
@unittest.expectedFailure # TODO: RUSTPYTHON
@support.suppress_immortalization()
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_free_after_iterating(self):
support.check_free_after_iterating(self, iter, self.type2test)
support.check_free_after_iterating(self, reversed, self.type2test)
-9
View File
@@ -2763,15 +2763,6 @@ def adjust_int_max_str_digits(max_digits):
sys.set_int_max_str_digits(current)
# XXX: RUSTPYTHON; removed in 3.14
def get_c_recursion_limit():
try:
import _testcapi
return _testcapi.Py_C_RECURSION_LIMIT
except ImportError:
raise unittest.SkipTest('requires _testcapi')
def exceeds_recursion_limit():
"""For recursion tests, easily exceeds default recursion limit."""
return 150_000
+6 -6
View File
@@ -2,7 +2,7 @@ import collections.abc
import copy
import pickle
import unittest
from test.support import get_c_recursion_limit
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
class DictSetTest(unittest.TestCase):
@@ -277,11 +277,12 @@ class DictSetTest(unittest.TestCase):
# Again.
self.assertIsInstance(r, str)
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.skip("TODO: RUSTPYTHON; segfault")
@skip_wasi_stack_overflow()
@skip_emscripten_stack_overflow()
def test_deeply_nested_repr(self):
d = {}
for i in range(get_c_recursion_limit()//2 + 100):
for i in range(exceeds_recursion_limit()):
d = {42: d.values()}
self.assertRaises(RecursionError, repr, d)
@@ -291,8 +292,7 @@ class DictSetTest(unittest.TestCase):
self.assertRaises(TypeError, copy.copy, d.values())
self.assertRaises(TypeError, copy.copy, d.items())
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_compare_error(self):
class Exc(Exception):
pass
+14 -9
View File
@@ -1,13 +1,13 @@
import collections.abc
import types
import unittest
from test.support import get_c_recursion_limit
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
class TestExceptionGroupTypeHierarchy(unittest.TestCase):
def test_exception_group_types(self):
self.assertTrue(issubclass(ExceptionGroup, Exception))
self.assertTrue(issubclass(ExceptionGroup, BaseExceptionGroup))
self.assertTrue(issubclass(BaseExceptionGroup, BaseException))
self.assertIsSubclass(ExceptionGroup, Exception)
self.assertIsSubclass(ExceptionGroup, BaseExceptionGroup)
self.assertIsSubclass(BaseExceptionGroup, BaseException)
def test_exception_is_not_generic_type(self):
with self.assertRaisesRegex(TypeError, 'Exception'):
@@ -20,8 +20,7 @@ class TestExceptionGroupTypeHierarchy(unittest.TestCase):
class BadConstructorArgs(unittest.TestCase):
# TODO: RUSTPYTHON
@unittest.expectedFailure
@unittest.expectedFailure # TODO: RUSTPYTHON
def test_bad_EG_construction__too_many_args(self):
MSG = r'BaseExceptionGroup.__new__\(\) takes exactly 2 arguments'
with self.assertRaisesRegex(TypeError, MSG):
@@ -462,15 +461,21 @@ class ExceptionGroupSplitTests(ExceptionGroupTestBase):
class DeepRecursionInSplitAndSubgroup(unittest.TestCase):
def make_deep_eg(self):
e = TypeError(1)
for i in range(get_c_recursion_limit() + 1):
for i in range(exceeds_recursion_limit()):
e = ExceptionGroup('eg', [e])
return e
@unittest.skip("TODO: RUSTPYTHON; Segfault")
@skip_emscripten_stack_overflow()
@skip_wasi_stack_overflow()
def test_deep_split(self):
e = self.make_deep_eg()
with self.assertRaises(RecursionError):
e.split(TypeError)
@unittest.skip("TODO: RUSTPYTHON; Segfault")
@skip_emscripten_stack_overflow()
@skip_wasi_stack_overflow()
def test_deep_subgroup(self):
e = self.make_deep_eg()
with self.assertRaises(RecursionError):
@@ -812,8 +817,8 @@ class NestedExceptionGroupSplitTest(ExceptionGroupSplitTestBase):
eg = ExceptionGroup("eg", [ValueError(1), TypeError(2)])
eg.__notes__ = 123
match, rest = eg.split(TypeError)
self.assertFalse(hasattr(match, '__notes__'))
self.assertFalse(hasattr(rest, '__notes__'))
self.assertNotHasAttr(match, '__notes__')
self.assertNotHasAttr(rest, '__notes__')
def test_drive_invalid_return_value(self):
class MyEg(ExceptionGroup):
+2 -1
View File
@@ -68,7 +68,8 @@ class UserListTest(list_tests.CommonTest):
# Decorate existing test with recursion limit, because
# the test is for C structure, but `UserList` is a Python structure.
test_repr_deep = list_tests.CommonTest.test_repr_deep
# test_repr_deep = list_tests.CommonTest.test_repr_deep
test_repr_deep = unittest.skip(list_tests.CommonTest.test_repr_deep) # TODO: RUSTPYTHON; Segfault
if __name__ == "__main__":
unittest.main()