1 from test
import test_support
2 from test
.test_support
import bigaddrspacetest
, MAX_Py_ssize_t
9 class StrTest(unittest
.TestCase
):
12 def test_concat(self
):
13 s1
= 'x' * MAX_Py_ssize_t
14 self
.assertRaises(OverflowError, operator
.add
, s1
, '?')
17 def test_optimized_concat(self
):
18 x
= 'x' * MAX_Py_ssize_t
20 x
= x
+ '?' # this statement uses a fast path in ceval.c
24 self
.fail("should have raised OverflowError")
26 x
+= '?' # this statement uses a fast path in ceval.c
30 self
.fail("should have raised OverflowError")
31 self
.assertEquals(len(x
), MAX_Py_ssize_t
)
33 ### the following test is pending a patch
34 # (http://mail.python.org/pipermail/python-dev/2006-July/067774.html)
36 #def test_repeat(self):
37 # self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1)
41 test_support
.run_unittest(StrTest
)
43 if __name__
== '__main__':
45 test_support
.set_memlimit(sys
.argv
[1])