Skip to content

Commit

Permalink
Use more reasonable nesting in test_plistlib's test_deep_nesting
Browse files Browse the repository at this point in the history
This adjust the nesting levels used by the test_deep_nesting
because the previous levels consistently hit the recursion limit
and ended up not testing anything.

Adjusting the level is reasonable because the tested nesting levels
should still be significantly larger than those seen in real world
plist files.

The test also no longer ignores recursion errors.
  • Loading branch information
ronaldoussoren committed Jan 13, 2024
1 parent c6ca562 commit 9c3c8c3
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions Lib/test/test_plistlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,18 +971,15 @@ def test_cycles(self):
self.assertIs(b['x'], b)

def test_deep_nesting(self):
for N in [300, 100000]:
for N in [50, 100]:
with self.subTest(N=N):
chunks = [b'\xa1' + (i + 1).to_bytes(4, 'big') for i in range(N)]
try:
result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4)
except RecursionError:
pass
else:
for i in range(N):
self.assertIsInstance(result, list)
self.assertEqual(len(result), 1)
result = result[0]
self.assertEqual(result, 'seed')
result = self.decode(*chunks, b'\x54seed', offset_size=4, ref_size=4)
for i in range(N):
self.assertIsInstance(result, list)
self.assertEqual(len(result), 1)
result = result[0]
self.assertEqual(result, 'seed')

def test_large_timestamp(self):
# Issue #26709: 32-bit timestamp out of range
Expand Down

0 comments on commit 9c3c8c3

Please sign in to comment.