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


Python _testcapi.INT_MIN属性代码示例

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


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

示例1: test_fcntl_bad_file

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def test_fcntl_bad_file(self):
        class F:
            def __init__(self, fn):
                self.fn = fn
            def fileno(self):
                return self.fn
        self.assertRaises(ValueError, fcntl.fcntl, -1, fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(-1), fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(TypeError, fcntl.fcntl, 'spam', fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(TypeError, fcntl.fcntl, F('spam'), fcntl.F_SETFL, os.O_NONBLOCK)
        # Issue 15989
        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MAX + 1,
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MAX + 1),
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, _testcapi.INT_MIN - 1,
                                                   fcntl.F_SETFL, os.O_NONBLOCK)
        self.assertRaises(ValueError, fcntl.fcntl, F(_testcapi.INT_MIN - 1),
                                                   fcntl.F_SETFL, os.O_NONBLOCK) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_fcntl.py

示例2: test_fcntl_bad_file_overflow

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def test_fcntl_bad_file_overflow(self):
        from _testcapi import INT_MAX, INT_MIN
        # Issue 15989
        with self.assertRaises(ValueError):
            fcntl.fcntl(INT_MAX + 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(BadFile(INT_MAX + 1), fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(INT_MIN - 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(ValueError):
            fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:test_fcntl.py

示例3: testInvalidFd_overflow

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def testInvalidFd_overflow(self):
        # Issue 15989
        import _testcapi
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1)
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_fileio.py

示例4: testInvalidFd

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def testInvalidFd(self):
        self.assertRaises(ValueError, _FileIO, -10)
        self.assertRaises(OSError, _FileIO, make_bad_fd())
        if sys.platform == 'win32':
            import msvcrt
            self.assertRaises(IOError, msvcrt.get_osfhandle, make_bad_fd())
        # Issue 15989
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MAX + 1)
        self.assertRaises(TypeError, _FileIO, _testcapi.INT_MIN - 1) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:11,代码来源:test_fileio.py

示例5: test_FromSeconds

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def test_FromSeconds(self):
        from _testcapi import PyTime_FromSeconds
        for seconds in (0, 3, -456, _testcapi.INT_MAX, _testcapi.INT_MIN):
            with self.subTest(seconds=seconds):
                self.assertEqual(PyTime_FromSeconds(seconds),
                                 seconds * SEC_TO_NS) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_time.py

示例6: test_fcntl_bad_file_overflow

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def test_fcntl_bad_file_overflow(self):
        from _testcapi import INT_MAX, INT_MIN
        # Issue 15989
        with self.assertRaises(OverflowError):
            fcntl.fcntl(INT_MAX + 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(OverflowError):
            fcntl.fcntl(BadFile(INT_MAX + 1), fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(OverflowError):
            fcntl.fcntl(INT_MIN - 1, fcntl.F_SETFL, os.O_NONBLOCK)
        with self.assertRaises(OverflowError):
            fcntl.fcntl(BadFile(INT_MIN - 1), fcntl.F_SETFL, os.O_NONBLOCK) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_fcntl.py

示例7: testInvalidFd_overflow

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def testInvalidFd_overflow(self):
        # Issue 15989
        import _testcapi
        self.assertRaises(TypeError, self.FileIO, _testcapi.INT_MAX + 1)
        self.assertRaises(TypeError, self.FileIO, _testcapi.INT_MIN - 1) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_fileio.py

示例8: test_FromSeconds

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def test_FromSeconds(self):
        from _testcapi import PyTime_FromSeconds

        # PyTime_FromSeconds() expects a C int, reject values out of range
        def c_int_filter(secs):
            return (_testcapi.INT_MIN <= secs <= _testcapi.INT_MAX)

        self.check_int_rounding(lambda secs, rnd: PyTime_FromSeconds(secs),
                                lambda secs: secs * SEC_TO_NS,
                                value_filter=c_int_filter)

        # test nan
        for time_rnd, _ in ROUNDING_MODES:
            with self.assertRaises(TypeError):
                PyTime_FromSeconds(float('nan')) 
开发者ID:bkerler,项目名称:android_universal,代码行数:17,代码来源:test_time.py

示例9: _rounding_values

# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import INT_MIN [as 别名]
def _rounding_values(self, use_float):
        "Build timestamps used to test rounding."

        units = [1, US_TO_NS, MS_TO_NS, SEC_TO_NS]
        if use_float:
            # picoseconds are only tested to pytime_converter accepting floats
            units.append(1e-3)

        values = (
            # small values
            1, 2, 5, 7, 123, 456, 1234,
            # 10^k - 1
            9,
            99,
            999,
            9999,
            99999,
            999999,
            # test half even rounding near 0.5, 1.5, 2.5, 3.5, 4.5
            499, 500, 501,
            1499, 1500, 1501,
            2500,
            3500,
            4500,
        )

        ns_timestamps = [0]
        for unit in units:
            for value in values:
                ns = value * unit
                ns_timestamps.extend((-ns, ns))
        for pow2 in (0, 5, 10, 15, 22, 23, 24, 30, 33):
            ns = (2 ** pow2) * SEC_TO_NS
            ns_timestamps.extend((
                -ns-1, -ns, -ns+1,
                ns-1, ns, ns+1
            ))
        for seconds in (_testcapi.INT_MIN, _testcapi.INT_MAX):
            ns_timestamps.append(seconds * SEC_TO_NS)
        if use_float:
            # numbers with an exact representation in IEEE 754 (base 2)
            for pow2 in (3, 7, 10, 15):
                ns = 2.0 ** (-pow2)
                ns_timestamps.extend((-ns, ns))

        # seconds close to _PyTime_t type limit
        ns = (2 ** 63 // SEC_TO_NS) * SEC_TO_NS
        ns_timestamps.extend((-ns, ns))

        return ns_timestamps 
开发者ID:bkerler,项目名称:android_universal,代码行数:52,代码来源:test_time.py


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