summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJesus Cea <jcea@jcea.es>2012-08-03 12:49:42 (GMT)
committerJesus Cea <jcea@jcea.es>2012-08-03 12:49:42 (GMT)
commit16e2fca47e44e6244d7aaa285fde5ae162c4baab (patch)
tree1df990f455d3509567d22eee1500059c0ad1c2f1 /Lib
parente9c5318967e1e62e940b72cd47502a1a3b559b95 (diff)
downloadcpython-16e2fca47e44e6244d7aaa285fde5ae162c4baab.zip
cpython-16e2fca47e44e6244d7aaa285fde5ae162c4baab.tar.gz
cpython-16e2fca47e44e6244d7aaa285fde5ae162c4baab.tar.bz2
Closes #15469: Correct __sizeof__ support for deque
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_deque.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_deque.py b/Lib/test/test_deque.py
index 0dcadeb..f0afe1d 100644
--- a/Lib/test/test_deque.py
+++ b/Lib/test/test_deque.py
@@ -7,6 +7,7 @@ import copy
import pickle
from io import StringIO
import random
+import struct
BIG = 100000
@@ -518,6 +519,21 @@ class TestBasic(unittest.TestCase):
gc.collect()
self.assertTrue(ref() is None, "Cycle was not collected")
+ check_sizeof = support.check_sizeof
+
+ @support.cpython_only
+ def test_sizeof(self):
+ BLOCKLEN = 62
+ basesize = support.calcobjsize('2P4PlP')
+ blocksize = struct.calcsize('2P%dP' % BLOCKLEN)
+ self.assertEqual(object.__sizeof__(deque()), basesize)
+ check = self.check_sizeof
+ check(deque(), basesize + blocksize)
+ check(deque('a'), basesize + blocksize)
+ check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize)
+ check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize)
+ check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
+
class TestVariousIteratorArgs(unittest.TestCase):
def test_constructor(self):