mirror of https://github.com/python/cpython
bpo-46542: test_json uses support.infinite_recursion() (GH-30972)
Fix test_json tests checking for RecursionError: modify these tests to use support.infinite_recursion().
This commit is contained in:
parent
18ea973c21
commit
e7a6285f1b
|
@ -1,3 +1,4 @@
|
|||
from test import support
|
||||
from test.test_json import PyTest, CTest
|
||||
|
||||
|
||||
|
@ -69,10 +70,13 @@ class TestRecursion:
|
|||
# test that loading highly-nested objects doesn't segfault when C
|
||||
# accelerations are used. See #12017
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('{"a":' * 100000 + '1' + '}' * 100000)
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('{"a":' * 100000 + '[1]' + '}' * 100000)
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.loads('[' * 100000 + '1' + ']' * 100000)
|
||||
|
||||
def test_highly_nested_objects_encoding(self):
|
||||
|
@ -81,8 +85,10 @@ class TestRecursion:
|
|||
for x in range(100000):
|
||||
l, d = [l], {'k':d}
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.dumps(l)
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
self.dumps(d)
|
||||
|
||||
def test_endless_recursion(self):
|
||||
|
@ -93,6 +99,7 @@ class TestRecursion:
|
|||
return [o]
|
||||
|
||||
with self.assertRaises(RecursionError):
|
||||
with support.infinite_recursion():
|
||||
EndlessJSONEncoder(check_circular=False).encode(5j)
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix ``test_json`` tests checking for :exc:`RecursionError`: modify these tests
|
||||
to use ``support.infinite_recursion()``. Patch by Victor Stinner.
|
Loading…
Reference in New Issue