本文整理汇总了Python中_testcapi.UINT_MAX属性的典型用法代码示例。如果您正苦于以下问题:Python _testcapi.UINT_MAX属性的具体用法?Python _testcapi.UINT_MAX怎么用?Python _testcapi.UINT_MAX使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类_testcapi
的用法示例。
在下文中一共展示了_testcapi.UINT_MAX属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSetBlocking
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def testSetBlocking(self):
# Testing whether set blocking works
self.serv.setblocking(True)
self.assertIsNone(self.serv.gettimeout())
self.serv.setblocking(False)
self.assertEqual(self.serv.gettimeout(), 0.0)
start = time.time()
try:
self.serv.accept()
except socket.error:
pass
end = time.time()
self.assertTrue((end - start) < 1.0, "Error setting non-blocking mode.")
# Issue 15989
if _testcapi.UINT_MAX < _testcapi.ULONG_MAX:
self.serv.setblocking(_testcapi.UINT_MAX + 1)
self.assertIsNone(self.serv.gettimeout())
示例2: test_poll3
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_poll3(self):
# test int overflow
pollster = select.poll()
pollster.register(1)
self.assertRaises(OverflowError, pollster.poll, 1L << 64)
x = 2 + 3
if x != 5:
self.fail('Overflow must have occurred')
pollster = select.poll()
# Issue 15989
self.assertRaises(OverflowError, pollster.register, 0,
_testcapi.SHRT_MAX + 1)
self.assertRaises(OverflowError, pollster.register, 0,
_testcapi.USHRT_MAX + 1)
self.assertRaises(OverflowError, pollster.poll, _testcapi.INT_MAX + 1)
self.assertRaises(OverflowError, pollster.poll, _testcapi.UINT_MAX + 1)
示例3: test_formatting_c_limits
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_formatting_c_limits(self):
from _testcapi import PY_SSIZE_T_MAX, INT_MAX, UINT_MAX
SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
width = int(PY_SSIZE_T_MAX + 1)
if width <= sys.maxint:
self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
prec = int(INT_MAX + 1)
if prec <= sys.maxint:
self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
# Issue 15989
width = int(SIZE_MAX + 1)
if width <= sys.maxint:
self.checkraises(OverflowError, '%*s', '__mod__', (width, ''))
prec = int(UINT_MAX + 1)
if prec <= sys.maxint:
self.checkraises(OverflowError, '%.*f', '__mod__', (prec, 1. / 7))
示例4: _testShutdown_overflow
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def _testShutdown_overflow(self):
import _testcapi
self.serv_conn.send(MSG)
# Issue 15989
self.assertRaises(OverflowError, self.serv_conn.shutdown,
_testcapi.INT_MAX + 1)
self.assertRaises(OverflowError, self.serv_conn.shutdown,
2 + (_testcapi.UINT_MAX + 1))
self.serv_conn.shutdown(2)
示例5: testSetBlocking_overflow
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def testSetBlocking_overflow(self):
# Issue 15989
import _testcapi
if _testcapi.UINT_MAX >= _testcapi.ULONG_MAX:
self.skipTest('needs UINT_MAX < ULONG_MAX')
self.serv.setblocking(False)
self.assertEqual(self.serv.gettimeout(), 0.0)
self.serv.setblocking(_testcapi.UINT_MAX + 1)
self.assertIsNone(self.serv.gettimeout())
示例6: test_poll_c_limits
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_poll_c_limits(self):
from _testcapi import USHRT_MAX, INT_MAX, UINT_MAX
pollster = select.poll()
pollster.register(1)
# Issues #15989, #17919
self.assertRaises(OverflowError, pollster.register, 0, USHRT_MAX + 1)
self.assertRaises(OverflowError, pollster.modify, 1, USHRT_MAX + 1)
self.assertRaises(OverflowError, pollster.poll, INT_MAX + 1)
self.assertRaises(OverflowError, pollster.poll, UINT_MAX + 1)
示例7: test_issue16335
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_issue16335(self, size):
func = self.test_issue16335
if size < func.minsize:
raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
(func.minsize * func.memuse / float(1024**3),))
# very very long bogus character name
x = b'\\N{SPACE' + b'x' * int(UINT_MAX + 1) + b'}'
self.assertEqual(len(x), len(b'\\N{SPACE}') + (UINT_MAX + 1))
self.assertRaisesRegexp(UnicodeError,
'unknown Unicode character name',
x.decode, 'unicode-escape'
)
示例8: _testShutdown
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def _testShutdown(self):
self.serv_conn.send(MSG)
# Issue 15989
self.assertRaises(OverflowError, self.serv_conn.shutdown,
_testcapi.INT_MAX + 1)
self.assertRaises(OverflowError, self.serv_conn.shutdown,
2 + (_testcapi.UINT_MAX + 1))
self.serv_conn.shutdown(2)
示例9: test_issue16335
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_issue16335(self, size):
func = self.test_issue16335
if size < func.minsize:
raise unittest.SkipTest("not enough memory: %.1fG minimum needed" %
(func.minsize * func.memuse / float(1024**3),))
# very very long bogus character name
x = b'\\N{SPACE' + b'x' * int(_testcapi.UINT_MAX + 1) + b'}'
self.assertEqual(len(x), len(b'\\N{SPACE}') +
(_testcapi.UINT_MAX + 1))
self.assertRaisesRegexp(UnicodeError,
'unknown Unicode character name',
x.decode, 'unicode-escape'
)
示例10: test_device_encoding
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_device_encoding(self):
# Issue 15989
import _testcapi
b = self.BytesIO()
b.fileno = lambda: _testcapi.INT_MAX + 1
self.assertRaises(OverflowError, self.TextIOWrapper, b)
b.fileno = lambda: _testcapi.UINT_MAX + 1
self.assertRaises(OverflowError, self.TextIOWrapper, b)
示例11: test_pipe2_c_limits
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_pipe2_c_limits(self):
# Issue 15989
import _testcapi
self.assertRaises(OverflowError, os.pipe2, _testcapi.INT_MAX + 1)
self.assertRaises(OverflowError, os.pipe2, _testcapi.UINT_MAX + 1)
示例12: test_formatting_c_limits
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_formatting_c_limits(self):
from _testcapi import PY_SSIZE_T_MAX, INT_MAX, UINT_MAX
SIZE_MAX = (1 << (PY_SSIZE_T_MAX.bit_length() + 1)) - 1
self.checkraises(OverflowError, '%*s', '__mod__',
(PY_SSIZE_T_MAX + 1, ''))
self.checkraises(OverflowError, '%.*f', '__mod__',
(INT_MAX + 1, 1. / 7))
# Issue 15989
self.checkraises(OverflowError, '%*s', '__mod__',
(SIZE_MAX + 1, ''))
self.checkraises(OverflowError, '%.*f', '__mod__',
(UINT_MAX + 1, 1. / 7))
示例13: test_packed_c_limits
# 需要导入模块: import _testcapi [as 别名]
# 或者: from _testcapi import UINT_MAX [as 别名]
def test_packed_c_limits(self):
# Issue 15989
import _testcapi
d = {"_fields_": [("a", c_byte)],
"_pack_": _testcapi.INT_MAX + 1}
self.assertRaises(ValueError, type(Structure), "X", (Structure,), d)
d = {"_fields_": [("a", c_byte)],
"_pack_": _testcapi.UINT_MAX + 2}
self.assertRaises(ValueError, type(Structure), "X", (Structure,), d)