diff Lib/test/test_array.py @ 78493:45ef9bc8739f 3.2

Issue #15424: Add a __sizeof__ implementation for array objects. Patch by Ludwig Hähne.
author Meador Inge <meadori@gmail.com>
date Fri, 10 Aug 2012 22:35:45 -0500
parents 3c9232a684ae
children 7d82a60850fd
line wrap: on
line diff
--- a/Lib/test/test_array.py	Thu Aug 09 21:26:34 2012 +0300
+++ b/Lib/test/test_array.py	Fri Aug 10 22:35:45 2012 -0500
@@ -988,6 +988,19 @@
         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('4Pi')
+        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('4Pi')
+        support.check_sizeof(self, a, basesize)
+
 
 class StringTest(BaseTest):