summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2012-07-23 15:01:29 (GMT)
committerMeador Inge <meadori@gmail.com>2012-07-23 15:01:29 (GMT)
commitb14d8c9bcfb7f58e83a5c18c8b6eac0fa261c4b6 (patch)
treeef670d6bf6855e80f60c9eb9c75ce1f7a513511e /Lib
parent7e918cfe2805f4556995885a14e684029c7c95ba (diff)
downloadcpython-b14d8c9bcfb7f58e83a5c18c8b6eac0fa261c4b6.zip
cpython-b14d8c9bcfb7f58e83a5c18c8b6eac0fa261c4b6.tar.gz
cpython-b14d8c9bcfb7f58e83a5c18c8b6eac0fa261c4b6.tar.bz2
Issue #15402: Add a __sizeof__ method to struct.Struct.
Initial patch by Serhiy Storchaka.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_struct.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index 2ccaad2..bd89950 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -556,6 +556,16 @@ class StructTest(unittest.TestCase):
s = struct.Struct('i')
s.__init__('ii')
+ def test_sizeof(self):
+ self.assertGreater(sys.getsizeof(struct.Struct('BHILfdspP')),
+ sys.getsizeof(struct.Struct('B')))
+ self.assertGreaterEqual(sys.getsizeof(struct.Struct('123B')),
+ sys.getsizeof(struct.Struct('B')))
+ self.assertGreaterEqual(sys.getsizeof(struct.Struct('B' * 123)),
+ sys.getsizeof(struct.Struct('123B')))
+ self.assertGreaterEqual(sys.getsizeof(struct.Struct('123xB')),
+ sys.getsizeof(struct.Struct('B')))
+
def test_main():
run_unittest(StructTest)