mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Update test_dict.py from CPython v3.12.0
This commit is contained in:
1 parent
f1991c25bc
commit
d5e4af7a4b
1 file changed
+17
-2
Vendored
+17
-2
@@ -8,7 +8,7 @@ import sys
|
||||
import unittest
|
||||
import weakref
|
||||
from test import support
|
||||
from test.support import import_helper
|
||||
from test.support import import_helper, C_RECURSION_LIMIT
|
||||
|
||||
|
||||
class DictTest(unittest.TestCase):
|
||||
@@ -599,7 +599,7 @@ class DictTest(unittest.TestCase):
|
||||
@unittest.skipIf(sys.platform == 'win32', 'TODO: RUSTPYTHON Windows')
|
||||
def test_repr_deep(self):
|
||||
d = {}
|
||||
for i in range(sys.getrecursionlimit() + 100):
|
||||
for i in range(C_RECURSION_LIMIT + 1):
|
||||
d = {1: d}
|
||||
self.assertRaises(RecursionError, repr, d)
|
||||
|
||||
@@ -1099,6 +1099,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"}
|
||||
|
||||
Reference in new issue
Block a user