diff options
author | tqxia <44689929+tqxia@users.noreply.github.com> | 2022-12-31 09:15:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-31 09:15:30 (GMT) |
commit | 636e9dd23f88c701eecf91156835fe0fc8b1feb6 (patch) | |
tree | dc14a563b84a6c8926ae56e934926aef23594ffc | |
parent | f59c7f8edd5ba5f6c1954383542a2292bcf51d91 (diff) | |
download | cpython-636e9dd23f88c701eecf91156835fe0fc8b1feb6.zip cpython-636e9dd23f88c701eecf91156835fe0fc8b1feb6.tar.gz cpython-636e9dd23f88c701eecf91156835fe0fc8b1feb6.tar.bz2 |
gh-94808: Improve coverage of dictresize (GH-100619)
-rw-r--r-- | Lib/test/test_dict.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 5b8baaf..7963834 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -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"} |