Skip to content

Commit 428c46a

Browse files
committed
Up the limits for recursion tests
1 parent 350f8ec commit 428c46a

File tree

8 files changed

+13
-20
lines changed

8 files changed

+13
-20
lines changed

Lib/test/list_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def test_repr(self):
6262
@skip_emscripten_stack_overflow()
6363
def test_repr_deep(self):
6464
a = self.type2test([])
65-
for i in range(get_c_recursion_limit() * 10):
65+
for i in range(100_000):
6666
a = self.type2test([a])
6767
self.assertRaises(RecursionError, repr, a)
6868

Lib/test/mapping_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def __repr__(self):
625625
@skip_emscripten_stack_overflow()
626626
def test_repr_deep(self):
627627
d = self._empty_mapping()
628-
for i in range(get_c_recursion_limit() * 5):
628+
for i in range(100_000):
629629
d0 = d
630630
d = self._empty_mapping()
631631
d[1] = d0

Lib/test/test_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,8 @@ def test_yet_more_evil_still_undecodable(self):
714714
def test_compiler_recursion_limit(self):
715715
# Compiler frames are small
716716
limit = get_c_recursion_limit() * 3 // 2
717-
fail_depth = limit * 10
718-
crash_depth = limit * 50
717+
fail_depth = limit * 50
718+
crash_depth = limit * 200
719719
success_depth = limit
720720

721721
def check_limit(prefix, repeated, mode="single"):

Lib/test/test_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ def __repr__(self):
597597
@support.skip_emscripten_stack_overflow()
598598
def test_repr_deep(self):
599599
d = {}
600-
for i in range(get_c_recursion_limit() * 10):
600+
for i in range(100_000):
601601
d = {1: d}
602602
self.assertRaises(RecursionError, repr, d)
603603

Lib/test/test_exception_group.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ def test_basics_split_by_predicate__match(self):
460460
class DeepRecursionInSplitAndSubgroup(unittest.TestCase):
461461
def make_deep_eg(self):
462462
e = TypeError(1)
463-
for i in range(get_c_recursion_limit() * 10):
463+
for i in range(100_000):
464464
e = ExceptionGroup('eg', [e])
465465
return e
466466

Lib/test/test_isinstance.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -267,15 +267,13 @@ def test_subclass_tuple(self):
267267
def test_subclass_recursion_limit(self):
268268
# make sure that issubclass raises RecursionError before the C stack is
269269
# blown
270-
with support.infinite_recursion():
271-
self.assertRaises(RecursionError, blowstack, issubclass, str, str)
270+
self.assertRaises(RecursionError, blowstack, issubclass, str, str)
272271

273272
@support.skip_emscripten_stack_overflow()
274273
def test_isinstance_recursion_limit(self):
275274
# make sure that issubclass raises RecursionError before the C stack is
276275
# blown
277-
with support.infinite_recursion():
278-
self.assertRaises(RecursionError, blowstack, isinstance, '', str)
276+
self.assertRaises(RecursionError, blowstack, isinstance, '', str)
279277

280278
def test_subclass_with_union(self):
281279
self.assertTrue(issubclass(int, int | float | int))
@@ -355,8 +353,9 @@ def blowstack(fxn, arg, compare_to):
355353
# Make sure that calling isinstance with a deeply nested tuple for its
356354
# argument will raise RecursionError eventually.
357355
tuple_arg = (compare_to,)
358-
for cnt in range(support.exceeds_recursion_limit()):
359-
tuple_arg = (tuple_arg,)
356+
while True:
357+
for _ in range(100):
358+
tuple_arg = (tuple_arg,)
360359
fxn(arg, tuple_arg)
361360

362361

Lib/test/test_userdict.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,7 @@ class G(collections.UserDict):
213213
else:
214214
self.fail("g[42] didn't raise KeyError")
215215

216-
# Decorate existing test with recursion limit, because
217-
# the test is for C structure, but `UserDict` is a Python structure.
218-
test_repr_deep = support.infinite_recursion(25)(
219-
mapping_tests.TestHashMappingProtocol.test_repr_deep,
220-
)
216+
test_repr_deep = mapping_tests.TestHashMappingProtocol.test_repr_deep
221217

222218

223219
if __name__ == "__main__":

Lib/test/test_userlist.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def test_userlist_copy(self):
6969

7070
# Decorate existing test with recursion limit, because
7171
# the test is for C structure, but `UserList` is a Python structure.
72-
test_repr_deep = support.infinite_recursion(25)(
73-
list_tests.CommonTest.test_repr_deep,
74-
)
72+
test_repr_deep = list_tests.CommonTest.test_repr_deep
7573

7674
if __name__ == "__main__":
7775
unittest.main()

0 commit comments

Comments
 (0)