[3.12] gh-111803: Make test_deep_nesting from test_plistlib more strict (GH-114026) (GH-114406)

It is no longer silently passed if RecursionError was raised for low
recursion depth.
(cherry picked from commit db1c18eb62)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-01-22 16:16:12 +01:00 committed by GitHub
parent 58fdd15d5a
commit d1f731ff08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -908,12 +908,13 @@ class TestBinaryPlistlib(unittest.TestCase):
self.assertIs(b['x'], b) self.assertIs(b['x'], b)
def test_deep_nesting(self): def test_deep_nesting(self):
for N in [300, 100000]: tests = [50, 100_000] if support.is_wasi else [50, 300, 100_000]
for N in tests:
chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)] chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)]
try: try:
result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4) result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4)
except RecursionError: except RecursionError:
pass self.assertGreater(N, sys.getrecursionlimit()//2)
else: else:
for i in range(N): for i in range(N):
self.assertIsInstance(result, list) self.assertIsInstance(result, list)