summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_descr.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_descr.py')
-rw-r--r--Lib/test/test_descr.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index af7848c..a5404b3 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -5500,17 +5500,19 @@ class SharedKeyTests(unittest.TestCase):
class B(A):
pass
+ #Shrink keys by repeatedly creating instances
+ [(A(), B()) for _ in range(20)]
+
a, b = A(), B()
self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({"a":1}))
- # Initial hash table can contain at most 5 elements.
+ # Initial hash table can contain only one or two elements.
# Set 6 attributes to cause internal resizing.
a.x, a.y, a.z, a.w, a.v, a.u = range(6)
self.assertNotEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(b)))
a2 = A()
- self.assertEqual(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
- self.assertLess(sys.getsizeof(vars(a)), sys.getsizeof({"a":1}))
- b.u, b.v, b.w, b.t, b.s, b.r = range(6)
+ self.assertGreater(sys.getsizeof(vars(a)), sys.getsizeof(vars(a2)))
+ self.assertLess(sys.getsizeof(vars(a2)), sys.getsizeof({"a":1}))
self.assertLess(sys.getsizeof(vars(b)), sys.getsizeof({"a":1}))