summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2012-08-11 04:21:39 (GMT)
committerMeador Inge <meadori@gmail.com>2012-08-11 04:21:39 (GMT)
commit80dd1af4e0ee07b2f65833835754f0a27bf48975 (patch)
tree1d7f04a3c9fd2268459b864ea89abdb83ed7e8ea /Lib/test
parent688a551ca075ed28126e11b5935ed0649d1e3b83 (diff)
parent03b4d5072aa044d8c6827e387b647dcc6c9d0ff6 (diff)
downloadcpython-80dd1af4e0ee07b2f65833835754f0a27bf48975.zip
cpython-80dd1af4e0ee07b2f65833835754f0a27bf48975.tar.gz
cpython-80dd1af4e0ee07b2f65833835754f0a27bf48975.tar.bz2
Issue #15424: Add a __sizeof__ implementation for array objects.
Patch by Ludwig Hähne.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/test_array.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index eb6d77f..544c2ce 100755
--- a/Lib/test/test_array.py
+++ b/Lib/test/test_array.py
@@ -1015,6 +1015,19 @@ class BaseTest(unittest.TestCase):
a = array.array('H', b"1234")
self.assertEqual(len(a) * a.itemsize, 4)
+ @support.cpython_only
+ def test_sizeof_with_buffer(self):
+ a = array.array(self.typecode, self.example)
+ basesize = support.calcvobjsize('Pn2Pi')
+ buffer_size = a.buffer_info()[1] * a.itemsize
+ support.check_sizeof(self, a, basesize + buffer_size)
+
+ @support.cpython_only
+ def test_sizeof_without_buffer(self):
+ a = array.array(self.typecode)
+ basesize = support.calcvobjsize('Pn2Pi')
+ support.check_sizeof(self, a, basesize)
+
class StringTest(BaseTest):