本文整理匯總了Python中test.test_support.MAX_Py_ssize_t方法的典型用法代碼示例。如果您正苦於以下問題:Python test_support.MAX_Py_ssize_t方法的具體用法?Python test_support.MAX_Py_ssize_t怎麽用?Python test_support.MAX_Py_ssize_t使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類test.test_support
的用法示例。
在下文中一共展示了test_support.MAX_Py_ssize_t方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_optimized_concat
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_optimized_concat(self):
x = 'x' * MAX_Py_ssize_t
try:
x = x + '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
try:
x += '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
self.assertEqual(len(x), MAX_Py_ssize_t)
### the following test is pending a patch
# (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
#@bigaddrspacetest
#def test_repeat(self):
# self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
示例2: test_optimized_concat
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_optimized_concat(self):
x = 'x' * MAX_Py_ssize_t
try:
x = x + '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
try:
x += '?' # this statement uses a fast path in ceval.c
except OverflowError:
pass
else:
self.fail("should have raised OverflowError")
self.assertEquals(len(x), MAX_Py_ssize_t)
### the following test is pending a patch
# (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
#@bigaddrspacetest
#def test_repeat(self):
# self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
示例3: test_setslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_setslice(self):
a = range(4)
self.assertRaises(TypeError, operator.setslice, a)
self.assertRaises(TypeError, operator.setslice, a, None, None, None)
self.assertTrue(operator.setslice(a, 1, 3, [2, 1]) is None)
self.assertTrue(a == [0, 2, 1, 3])
operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
self.assertTrue(a == [])
示例4: test_delslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_delslice(self):
a = range(10)
self.assertRaises(TypeError, operator.delslice, a)
self.assertRaises(TypeError, operator.delslice, a, None, None)
self.assertTrue(operator.delslice(a, 2, 8) is None)
self.assertTrue(a == [0, 1, 8, 9])
operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
self.assertTrue(a == [])
示例5: test_getslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_getslice(self):
a = range(10)
self.assertRaises(TypeError, operator.getslice)
self.assertRaises(TypeError, operator.getslice, a, None, None)
self.assertTrue(operator.getslice(a, 4, 6) == [4, 5])
b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
self.assertTrue(b == a)
示例6: test_concat
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_concat(self):
s1 = 'x' * MAX_Py_ssize_t
self.assertRaises(OverflowError, operator.add, s1, '?')
示例7: test_delslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_delslice(self):
a = range(10)
self.failUnlessRaises(TypeError, operator.delslice, a)
self.failUnlessRaises(TypeError, operator.delslice, a, None, None)
self.failUnless(operator.delslice(a, 2, 8) is None)
self.assert_(a == [0, 1, 8, 9])
operator.delslice(a, 0, test_support.MAX_Py_ssize_t)
self.assert_(a == [])
示例8: test_getslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_getslice(self):
a = range(10)
self.failUnlessRaises(TypeError, operator.getslice)
self.failUnlessRaises(TypeError, operator.getslice, a, None, None)
self.failUnless(operator.getslice(a, 4, 6) == [4, 5])
b = operator.getslice(a, 0, test_support.MAX_Py_ssize_t)
self.assert_(b == a)
示例9: test_setslice
# 需要導入模塊: from test import test_support [as 別名]
# 或者: from test.test_support import MAX_Py_ssize_t [as 別名]
def test_setslice(self):
a = range(4)
self.failUnlessRaises(TypeError, operator.setslice, a)
self.failUnlessRaises(TypeError, operator.setslice, a, None, None, None)
self.failUnless(operator.setslice(a, 1, 3, [2, 1]) is None)
self.assert_(a == [0, 2, 1, 3])
operator.setslice(a, 0, test_support.MAX_Py_ssize_t, [])
self.assert_(a == [])