当前位置: 首页>>代码示例>>Python>>正文


Python test_support.check_sizeof方法代码示例

本文整理汇总了Python中test.test_support.check_sizeof方法的典型用法代码示例。如果您正苦于以下问题:Python test_support.check_sizeof方法的具体用法?Python test_support.check_sizeof怎么用?Python test_support.check_sizeof使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在test.test_support的用法示例。


在下文中一共展示了test_support.check_sizeof方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: check_sizeof

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:8,代码来源:test_struct.py

示例2: test__sizeof__

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:14,代码来源:test_struct.py

示例3: test_sizeof

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:39,代码来源:test_parser.py

示例4: test_sizeof

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_deque.py

示例5: test_sizeof_with_buffer

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_array.py

示例6: test_sizeof

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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 ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_memoryio.py

示例7: test_sizeof

# 需要导入模块: from test import test_support [as 别名]
# 或者: from test.test_support import check_sizeof [as 别名]
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) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:13,代码来源:test_deque.py


注:本文中的test.test_support.check_sizeof方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。