summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMeador Inge <meadori@gmail.com>2012-07-23 15:22:36 (GMT)
committerMeador Inge <meadori@gmail.com>2012-07-23 15:22:36 (GMT)
commit9f65899d193b3056a79f2a7ea8dc32820d1127cf (patch)
tree7aa12519f8d4ec1a5f2106256861020a28e89266 /Lib/test
parentfe114f0293bde5e213211a6658644144f7df94b9 (diff)
parentb14d8c9bcfb7f58e83a5c18c8b6eac0fa261c4b6 (diff)
downloadcpython-9f65899d193b3056a79f2a7ea8dc32820d1127cf.zip
cpython-9f65899d193b3056a79f2a7ea8dc32820d1127cf.tar.gz
cpython-9f65899d193b3056a79f2a7ea8dc32820d1127cf.tar.bz2
Issue #15402: Add a __sizeof__ method to struct.Struct.
Initial patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/test')
-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 dc75858..f70435b 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -572,6 +572,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)