Python test.test_support.check_sizeof() Examples
The following are 30
code examples of test.test_support.check_sizeof().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
test.test_support
, or try the search function
.
Example #1
Source File: test_deque.py From oss-ftp with MIT License | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #2
Source File: test_memoryio.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #3
Source File: test_deque.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #4
Source File: test_parser.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #5
Source File: test_memoryio.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #6
Source File: test_deque.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #7
Source File: test_parser.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #8
Source File: test_memoryio.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #9
Source File: test_array.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_sizeof_with_buffer(self): a = array.array(self.typecode, self.example) basesize = test_support.calcvobjsize('4P') buffer_size = a.buffer_info()[1] * a.itemsize test_support.check_sizeof(self, a, basesize + buffer_size)
Example #10
Source File: test_deque.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #11
Source File: test_parser.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #12
Source File: test_struct.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test__sizeof__(self): for code in integer_codes: self.check_sizeof(code, 1) self.check_sizeof('BHILfdspP', 9) self.check_sizeof('B' * 1234, 1234) self.check_sizeof('fd', 2) self.check_sizeof('xxxxxxxxxxxxxx', 0) self.check_sizeof('100H', 100) self.check_sizeof('187s', 1) self.check_sizeof('20p', 1) self.check_sizeof('0s', 1) self.check_sizeof('0c', 0)
Example #13
Source File: test_struct.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check_sizeof(self, format_str, number_of_codes): # The size of 'PyStructObject' totalsize = support.calcobjsize('5P') # The size taken up by the 'formatcode' dynamic array totalsize += struct.calcsize('3P') * (number_of_codes + 1) support.check_sizeof(self, struct.Struct(format_str), totalsize)
Example #14
Source File: test_memoryio.py From oss-ftp with MIT License | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #15
Source File: test_array.py From oss-ftp with MIT License | 5 votes |
def test_sizeof_with_buffer(self): a = array.array(self.typecode, self.example) basesize = test_support.calcvobjsize('4P') buffer_size = a.buffer_info()[1] * a.itemsize test_support.check_sizeof(self, a, basesize + buffer_size)
Example #16
Source File: test_struct.py From ironpython2 with Apache License 2.0 | 5 votes |
def check_sizeof(self, format_str, number_of_codes): # The size of 'PyStructObject' totalsize = support.calcobjsize('5P') # The size taken up by the 'formatcode' dynamic array totalsize += struct.calcsize('3P') * (number_of_codes + 1) support.check_sizeof(self, struct.Struct(format_str), totalsize)
Example #17
Source File: test_parser.py From oss-ftp with MIT License | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #18
Source File: test_struct.py From oss-ftp with MIT License | 5 votes |
def test__sizeof__(self): for code in integer_codes: self.check_sizeof(code, 1) self.check_sizeof('BHILfdspP', 9) self.check_sizeof('B' * 1234, 1234) self.check_sizeof('fd', 2) self.check_sizeof('xxxxxxxxxxxxxx', 0) self.check_sizeof('100H', 100) self.check_sizeof('187s', 1) self.check_sizeof('20p', 1) self.check_sizeof('0s', 1) self.check_sizeof('0c', 0)
Example #19
Source File: test_struct.py From oss-ftp with MIT License | 5 votes |
def check_sizeof(self, format_str, number_of_codes): # The size of 'PyStructObject' totalsize = support.calcobjsize('5P') # The size taken up by the 'formatcode' dynamic array totalsize += struct.calcsize('3P') * (number_of_codes + 1) support.check_sizeof(self, struct.Struct(format_str), totalsize)
Example #20
Source File: test_memoryio.py From BinderFilter with MIT License | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #21
Source File: test_array.py From BinderFilter with MIT License | 5 votes |
def test_sizeof_with_buffer(self): a = array.array(self.typecode, self.example) basesize = test_support.calcvobjsize('4P') buffer_size = a.buffer_info()[1] * a.itemsize test_support.check_sizeof(self, a, basesize + buffer_size)
Example #22
Source File: test_deque.py From BinderFilter with MIT License | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P4PlP') blocksize = struct.calcsize('2P%dP' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #23
Source File: test_parser.py From BinderFilter with MIT License | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #24
Source File: test_struct.py From BinderFilter with MIT License | 5 votes |
def test__sizeof__(self): for code in integer_codes: self.check_sizeof(code, 1) self.check_sizeof('BHILfdspP', 9) self.check_sizeof('B' * 1234, 1234) self.check_sizeof('fd', 2) self.check_sizeof('xxxxxxxxxxxxxx', 0) self.check_sizeof('100H', 100) self.check_sizeof('187s', 1) self.check_sizeof('20p', 1) self.check_sizeof('0s', 1) self.check_sizeof('0c', 0)
Example #25
Source File: test_struct.py From BinderFilter with MIT License | 5 votes |
def check_sizeof(self, format_str, number_of_codes): # The size of 'PyStructObject' totalsize = support.calcobjsize('5P') # The size taken up by the 'formatcode' dynamic array totalsize += struct.calcsize('3P') * (number_of_codes + 1) support.check_sizeof(self, struct.Struct(format_str), totalsize)
Example #26
Source File: test_memoryio.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_sizeof(self): basesize = support.calcobjsize(b'P2PP2P') check = self.check_sizeof self.assertEqual(object.__sizeof__(io.BytesIO()), basesize) check(io.BytesIO(), basesize ) check(io.BytesIO(b'a'), basesize + 1 + 1 ) check(io.BytesIO(b'a' * 1000), basesize + 1000 + 1 )
Example #27
Source File: test_array.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_sizeof_with_buffer(self): a = array.array(self.typecode, self.example) basesize = test_support.calcvobjsize('4P') buffer_size = a.buffer_info()[1] * a.itemsize test_support.check_sizeof(self, a, basesize + buffer_size)
Example #28
Source File: test_deque.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_sizeof(self): BLOCKLEN = 62 basesize = test_support.calcobjsize('2P3PlPP') blocksize = struct.calcsize('%dP2P' % BLOCKLEN) self.assertEqual(object.__sizeof__(deque()), basesize) check = self.check_sizeof check(deque(), basesize + blocksize) check(deque('a'), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2)), basesize + blocksize) check(deque('a' * (BLOCKLEN // 2 + 1)), basesize + 2 * blocksize) check(deque('a' * (42 * BLOCKLEN)), basesize + 43 * blocksize)
Example #29
Source File: test_parser.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_sizeof(self): def XXXROUNDUP(n): if n <= 1: return n if n <= 128: return (n + 3) & ~3 return 1 << (n - 1).bit_length() basesize = support.calcobjsize('Pii') nodesize = struct.calcsize('hP3iP0h') def sizeofchildren(node): if node is None: return 0 res = 0 hasstr = len(node) > 1 and isinstance(node[-1], str) if hasstr: res += len(node[-1]) + 1 children = node[1:-1] if hasstr else node[1:] if children: res += XXXROUNDUP(len(children)) * nodesize for child in children: res += sizeofchildren(child) return res def check_st_sizeof(st): self.check_sizeof(st, basesize + nodesize + sizeofchildren(st.totuple())) check_st_sizeof(parser.expr('2 + 3')) check_st_sizeof(parser.expr('2 + 3 + 4')) check_st_sizeof(parser.suite('x = 2 + 3')) check_st_sizeof(parser.suite('')) check_st_sizeof(parser.suite('# -*- coding: utf-8 -*-')) check_st_sizeof(parser.expr('[' + '2,' * 1000 + ']')) # XXX tests for pickling and unpickling of ST objects should go here
Example #30
Source File: test_struct.py From ironpython2 with Apache License 2.0 | 5 votes |
def test__sizeof__(self): for code in integer_codes: self.check_sizeof(code, 1) self.check_sizeof('BHILfdspP', 9) self.check_sizeof('B' * 1234, 1234) self.check_sizeof('fd', 2) self.check_sizeof('xxxxxxxxxxxxxx', 0) self.check_sizeof('100H', 100) self.check_sizeof('187s', 1) self.check_sizeof('20p', 1) self.check_sizeof('0s', 1) self.check_sizeof('0c', 0)