Exemplo n.º 1
0
        size -= 1
        self.assertEquals(len(l), size)
        self.assertEquals(l[-2:], [10, 10])

    @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
    def test_reverse(self, size):
        l = [1, 2, 3, 4, 5] * size
        l.reverse()
        self.assertEquals(len(l), size * 5)
        self.assertEquals(l[-5:], [5, 4, 3, 2, 1])
        self.assertEquals(l[:5], [5, 4, 3, 2, 1])

    @bigmemtest(minsize=_2G // 5 + 2, memuse=8 * 5)
    def test_sort(self, size):
        l = [1, 2, 3, 4, 5] * size
        l.sort()
        self.assertEquals(len(l), size * 5)
        self.assertEquals(l.count(1), size)
        self.assertEquals(l[:10], [1] * 10)
        self.assertEquals(l[-10:], [5] * 10)


def test_main():
    test_support.run_unittest(StrTest, TupleTest, ListTest)


if __name__ == '__main__':
    if len(sys.argv) > 1:
        test_support.set_memlimit(sys.argv[1])
    test_main()
     huntrleaks = a.split(':')
     if len(huntrleaks) != 3:
         print a, huntrleaks
         usage(2, '-R takes three colon-separated arguments')
     if len(huntrleaks[0]) == 0:
         huntrleaks[0] = 5
     else:
         huntrleaks[0] = int(huntrleaks[0])
     if len(huntrleaks[1]) == 0:
         huntrleaks[1] = 4
     else:
         huntrleaks[1] = int(huntrleaks[1])
     if len(huntrleaks[2]) == 0:
         huntrleaks[2] = "reflog.txt"
 elif o in ('-M', '--memlimit'):
     test_support.set_memlimit(a)
 elif o in ('-u', '--use'):
     u = [x.lower() for x in a.split(',')]
     for r in u:
         if r == 'all':
             use_resources[:] = RESOURCE_NAMES
             continue
         remove = False
         if r[0] == '-':
             remove = True
             r = r[1:]
         if r not in RESOURCE_NAMES:
             usage(1, 'Invalid -u/--use option: ' + a)
         if remove:
             if r in use_resources:
                 use_resources.remove(r)
Exemplo n.º 3
0
     huntrleaks = a.split(':')
     if len(huntrleaks) != 3:
         print a, huntrleaks
         usage(2, '-R takes three colon-separated arguments')
     if len(huntrleaks[0]) == 0:
         huntrleaks[0] = 5
     else:
         huntrleaks[0] = int(huntrleaks[0])
     if len(huntrleaks[1]) == 0:
         huntrleaks[1] = 4
     else:
         huntrleaks[1] = int(huntrleaks[1])
     if len(huntrleaks[2]) == 0:
         huntrleaks[2] = "reflog.txt"
 elif o in ('-M', '--memlimit'):
     test_support.set_memlimit(a)
 elif o in ('-u', '--use'):
     u = [x.lower() for x in a.split(',')]
     for r in u:
         if r == 'all':
             use_resources[:] = RESOURCE_NAMES
             continue
         remove = False
         if r[0] == '-':
             remove = True
             r = r[1:]
         if r not in RESOURCE_NAMES:
             usage(1, 'Invalid -u/--use option: ' + a)
         if remove:
             if r in use_resources:
                 use_resources.remove(r)
Exemplo n.º 4
0
    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)


def test_main():
    test_support.run_unittest(StrTest)

if __name__ == '__main__':
    if len(sys.argv) > 1:
        test_support.set_memlimit(sys.argv[1])
    test_main()