Skip to content

Commit 636e9dd

Browse files
authoredDec 31, 2022
gh-94808: Improve coverage of dictresize (GH-100619)
1 parent f59c7f8 commit 636e9dd

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎Lib/test/test_dict.py

+15
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,21 @@ def __init__(self, order):
10941094
d.update(o.__dict__)
10951095
self.assertEqual(list(d), ["c", "b", "a"])
10961096

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

0 commit comments

Comments
 (0)
Please sign in to comment.