mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Issue #15402: Add a __sizeof__ method to struct.Struct.
Initial patch by Serhiy Storchaka.
This commit is contained in:
parent
7e918cfe28
commit
b14d8c9bcf
3 changed files with 31 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue