Skip to content

Commit 2cef96f

Browse files
committed
Restore use of exceeds_recursion_limit
1 parent 9654790 commit 2cef96f

File tree

9 files changed

+20
-14
lines changed

9 files changed

+20
-14
lines changed

Lib/test/mapping_tests.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# tests common to dict and UserDict
22
import unittest
33
import collections
4-
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow
4+
from test import support
55

66

77
class BasicTestMappingProtocol(unittest.TestCase):
@@ -622,11 +622,11 @@ def __repr__(self):
622622
d = self._full_mapping({1: BadRepr()})
623623
self.assertRaises(Exc, repr, d)
624624

625-
@skip_wasi_stack_overflow()
626-
@skip_emscripten_stack_overflow()
625+
@support.skip_wasi_stack_overflow()
626+
@support.skip_emscripten_stack_overflow()
627627
def test_repr_deep(self):
628628
d = self._empty_mapping()
629-
for i in range(100_000):
629+
for i in range(support.exceeds_recursion_limit()):
630630
d0 = d
631631
d = self._empty_mapping()
632632
d[1] = d0

Lib/test/support/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"run_with_tz", "PGO", "missing_compiler_executable",
5757
"ALWAYS_EQ", "NEVER_EQ", "LARGEST", "SMALLEST",
5858
"LOOPBACK_TIMEOUT", "INTERNET_TIMEOUT", "SHORT_TIMEOUT", "LONG_TIMEOUT",
59-
"Py_DEBUG", "skip_on_s390x",
59+
"Py_DEBUG", "exceeds_recursion_limit", "skip_on_s390x",
6060
"requires_jit_enabled",
6161
"requires_jit_disabled",
6262
"force_not_colorized",
@@ -2625,6 +2625,12 @@ def adjust_int_max_str_digits(max_digits):
26252625
finally:
26262626
sys.set_int_max_str_digits(current)
26272627

2628+
2629+
def exceeds_recursion_limit():
2630+
"""For recursion tests, easily exceeds default recursion limit."""
2631+
return 100_000
2632+
2633+
26282634
# Windows doesn't have os.uname() but it doesn't support s390x.
26292635
is_s390x = hasattr(os, 'uname') and os.uname().machine == 's390x'
26302636
skip_on_s390x = unittest.skipIf(is_s390x, 'skipped on s390x')

Lib/test/test_call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22
from test.support import (cpython_only, is_wasi, requires_limited_api, Py_DEBUG,
3-
set_recursion_limit, skip_on_s390x, skip_emscripten_stack_overflow,
3+
set_recursion_limit, skip_on_s390x, exceeds_recursion_limit, skip_emscripten_stack_overflow,
44
skip_if_sanitizer, import_helper)
55
try:
66
import _testcapi

Lib/test/test_collections.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ def test_odd_sizes(self):
542542
self.assertEqual(Dot(1)._replace(d=999), (999,))
543543
self.assertEqual(Dot(1)._fields, ('d',))
544544

545-
n = 100_000
545+
n = support.exceeds_recursion_limit()
546546
names = list(set(''.join([choice(string.ascii_letters)
547547
for j in range(10)]) for i in range(n)))
548548
n = len(names)

Lib/test/test_dict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def __repr__(self):
598598
@support.skip_emscripten_stack_overflow()
599599
def test_repr_deep(self):
600600
d = {}
601-
for i in range(100_000):
601+
for i in range(support.exceeds_recursion_limit()):
602602
d = {1: d}
603603
self.assertRaises(RecursionError, repr, d)
604604

Lib/test/test_dictviews.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import copy
33
import pickle
44
import unittest
5-
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow
5+
from test.support import skip_emscripten_stack_overflow, skip_wasi_stack_overflow, exceeds_recursion_limit
66

77
class DictSetTest(unittest.TestCase):
88

@@ -281,7 +281,7 @@ def test_recursive_repr(self):
281281
@skip_emscripten_stack_overflow()
282282
def test_deeply_nested_repr(self):
283283
d = {}
284-
for i in range(100_000):
284+
for i in range(exceeds_recursion_limit()):
285285
d = {42: d.values()}
286286
self.assertRaises(RecursionError, repr, d)
287287

Lib/test/test_exception_group.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import collections.abc
22
import types
33
import unittest
4-
from test.support import skip_emscripten_stack_overflow
4+
from test.support import skip_emscripten_stack_overflow, exceeds_recursion_limit
55

66
class TestExceptionGroupTypeHierarchy(unittest.TestCase):
77
def test_exception_group_types(self):
@@ -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(100_000):
463+
for i in range(exceeds_recursion_limit()):
464464
e = ExceptionGroup('eg', [e])
465465
return e
466466

Lib/test/test_exceptions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ def gen():
14511451
next(generator)
14521452
recursionlimit = sys.getrecursionlimit()
14531453
try:
1454-
recurse(100_000)
1454+
recurse(support.exceeds_recursion_limit())
14551455
finally:
14561456
sys.setrecursionlimit(recursionlimit)
14571457
print('Done.')

Lib/test/test_functools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2082,7 +2082,7 @@ def fib(n):
20822082
fib.cache_clear()
20832083
with support.infinite_recursion():
20842084
with self.assertRaises(RecursionError):
2085-
fib(100_000)
2085+
fib(support.exceeds_recursion_limit())
20862086

20872087

20882088
@py_functools.lru_cache()

0 commit comments

Comments
 (0)