mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Closes #15469: Correct __sizeof__ support for deque
This commit is contained in:
parent
e9c5318967
commit
16e2fca47e
3 changed files with 39 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue