| from test import test_support |
| from test.test_support import bigaddrspacetest, MAX_Py_ssize_t |
| class StrTest(unittest.TestCase): |
| s1 = 'x' * MAX_Py_ssize_t |
| self.assertRaises(OverflowError, operator.add, s1, '?') |
| def test_optimized_concat(self): |
| x = x + '?' # this statement uses a fast path in ceval.c |
| self.fail("should have raised OverflowError") |
| x += '?' # this statement uses a fast path in ceval.c |
| 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) |
| # self.assertRaises(OverflowError, operator.mul, 'x', MAX_Py_ssize_t + 1) |
| test_support.run_unittest(StrTest) |
| if __name__ == '__main__': |
| test_support.set_memlimit(sys.argv[1]) |