Python test.test_support.MAX_Py_ssize_t() Examples

The following are 30 code examples of test.test_support.MAX_Py_ssize_t(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module test.test_support , or try the search function .
Example #1
Source File: test_bigaddrspace.py    From CTFCrackTools with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #2
Source File: test_bigaddrspace.py    From gcblue with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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) 
Example #3
Source File: test_bigaddrspace.py    From oss-ftp with MIT License 6 votes vote down vote up
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) 
Example #4
Source File: test_bigaddrspace.py    From medicare-demo with Apache License 2.0 6 votes vote down vote up
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) 
Example #5
Source File: test_bigaddrspace.py    From BinderFilter with MIT License 6 votes vote down vote up
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) 
Example #6
Source File: test_bigaddrspace.py    From CTFCrackTools-V2 with GNU General Public License v3.0 6 votes vote down vote up
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) 
Example #7
Source File: test_bigaddrspace.py    From ironpython2 with Apache License 2.0 6 votes vote down vote up
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) 
Example #8
Source File: test_operator.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 == []) 
Example #9
Source File: test_operator.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #10
Source File: test_bigaddrspace.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #11
Source File: test_operator.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 == []) 
Example #12
Source File: test_operator.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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) 
Example #13
Source File: test_operator.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
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 == []) 
Example #14
Source File: test_operator.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
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 == []) 
Example #15
Source File: test_bigaddrspace.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #16
Source File: test_bigaddrspace.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #17
Source File: test_operator.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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 == []) 
Example #18
Source File: test_operator.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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) 
Example #19
Source File: test_operator.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
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 == []) 
Example #20
Source File: test_operator.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 == []) 
Example #21
Source File: test_bigaddrspace.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #22
Source File: test_operator.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
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 == []) 
Example #23
Source File: test_operator.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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) 
Example #24
Source File: test_operator.py    From gcblue with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 == []) 
Example #25
Source File: test_bigaddrspace.py    From oss-ftp with MIT License 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #26
Source File: test_operator.py    From oss-ftp with MIT License 5 votes vote down vote up
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 == []) 
Example #27
Source File: test_operator.py    From oss-ftp with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: test_operator.py    From oss-ftp with MIT License 5 votes vote down vote up
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 == []) 
Example #29
Source File: test_bigaddrspace.py    From BinderFilter with MIT License 5 votes vote down vote up
def test_concat(self):
        s1 = 'x' * MAX_Py_ssize_t
        self.assertRaises(OverflowError, operator.add, s1, '?') 
Example #30
Source File: test_operator.py    From BinderFilter with MIT License 5 votes vote down vote up
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 == [])