Skip to content

Commit d5e4af7

Browse files
committed
Update test_dict.py from CPython v3.12.0
1 parent f1991c2 commit d5e4af7

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

Lib/test/test_dict.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import unittest
99
import weakref
1010
from test import support
11-
from test.support import import_helper
11+
from test.support import import_helper, C_RECURSION_LIMIT
1212

1313

1414
class DictTest(unittest.TestCase):
@@ -599,7 +599,7 @@ def __repr__(self):
599599
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
600600
def test_repr_deep(self):
601601
d = {}
602-
for i in range(sys.getrecursionlimit() + 100):
602+
for i in range(C_RECURSION_LIMIT + 1):
603603
d = {1: d}
604604
self.assertRaises(RecursionError, repr, d)
605605

@@ -1099,6 +1099,21 @@ def __init__(self, order):
10991099
d.update(o.__dict__)
11001100
self.assertEqual(list(d), ["c", "b", "a"])
11011101

1102+
@support.cpython_only
1103+
def test_splittable_to_generic_combinedtable(self):
1104+
"""split table must be correctly resized and converted to generic combined table"""
1105+
class C:
1106+
pass
1107+
1108+
a = C()
1109+
a.x = 1
1110+
d = a.__dict__
1111+
before_resize = sys.getsizeof(d)
1112+
d[2] = 2 # split table is resized to a generic combined table
1113+
1114+
self.assertGreater(sys.getsizeof(d), before_resize)
1115+
self.assertEqual(list(d), ['x', 2])
1116+
11021117
def test_iterator_pickling(self):
11031118
for proto in range(pickle.HIGHEST_PROTOCOL + 1):
11041119
data = {1:"a", 2:"b", 3:"c"}

0 commit comments

Comments
 (0)