]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-94808: Improve coverage of dictresize (GH-100619)
authortqxia <44689929+tqxia@users.noreply.github.com>
Sat, 31 Dec 2022 09:15:30 +0000 (17:15 +0800)
committerGitHub <noreply@github.com>
Sat, 31 Dec 2022 09:15:30 +0000 (18:15 +0900)
Lib/test/test_dict.py

index 5b8baaf9e6e280923d845fbfb508e14708c9905d..79638340059f650d03dba441d26ae8bbf75832a0 100644 (file)
@@ -1094,6 +1094,21 @@ class DictTest(unittest.TestCase):
         d.update(o.__dict__)
         self.assertEqual(list(d), ["c", "b", "a"])
 
+    @support.cpython_only
+    def test_splittable_to_generic_combinedtable(self):
+        """split table must be correctly resized and converted to generic combined table"""
+        class C:
+            pass
+
+        a = C()
+        a.x = 1
+        d = a.__dict__
+        before_resize = sys.getsizeof(d)
+        d[2] = 2 # split table is resized to a generic combined table
+
+        self.assertGreater(sys.getsizeof(d), before_resize)
+        self.assertEqual(list(d), ['x', 2])
+
     def test_iterator_pickling(self):
         for proto in range(pickle.HIGHEST_PROTOCOL + 1):
             data = {1:"a", 2:"b", 3:"c"}