mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
Merged revisions 55007-55179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk ........ r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines Use the new print syntax, at least. ........ r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line remove old cruftiness ........ r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line make this work with the new Python ........ r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line Get asdl code gen working with Python 2.3. Should continue to work with 3.0 ........ r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line Verify checkins to p3yk (sic) branch go to 3000 list. ........ r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line Fix this test so it runs again by importing warnings_test properly. ........ r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines So long xrange. range() now supports values that are outside -sys.maxint to sys.maxint. floats raise a TypeError. This has been sitting for a long time. It probably has some problems and needs cleanup. Objects/rangeobject.c now uses 4-space indents since it is almost completely new. ........ r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines Fix two tests that were previously depending on significant spaces at the end of a line (and before that on Python 2.x print behavior that has no exact equivalent in 3.0). ........
This commit is contained in:
parent
598d98a7e8
commit
805365ee39
150 changed files with 1412 additions and 1320 deletions
|
@ -75,7 +75,7 @@ class TestBase(unittest.TestCase):
|
|||
return "Stable(%d, %d)" % (self.key, self.index)
|
||||
|
||||
for n in sizes:
|
||||
x = range(n)
|
||||
x = list(range(n))
|
||||
if verbose:
|
||||
print("Testing size", n)
|
||||
|
||||
|
@ -115,7 +115,7 @@ class TestBase(unittest.TestCase):
|
|||
Complains.maybe_complain = False
|
||||
check("exception during sort left some permutation", x, s)
|
||||
|
||||
s = [Stable(random.randrange(10), i) for i in xrange(n)]
|
||||
s = [Stable(random.randrange(10), i) for i in range(n)]
|
||||
augmented = [(e, e.index) for e in s]
|
||||
augmented.sort() # forced stable because ties broken by index
|
||||
x = [e for e, i in augmented] # a stable sort of s
|
||||
|
@ -144,10 +144,10 @@ class TestBugs(unittest.TestCase):
|
|||
def test_cmpNone(self):
|
||||
# Testing None as a comparison function.
|
||||
|
||||
L = range(50)
|
||||
L = list(range(50))
|
||||
random.shuffle(L)
|
||||
L.sort(None)
|
||||
self.assertEqual(L, range(50))
|
||||
self.assertEqual(L, list(range(50)))
|
||||
|
||||
def test_undetected_mutation(self):
|
||||
# Python 2.4a1 did not always detect mutation
|
||||
|
@ -182,7 +182,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
self.assertRaises(TypeError, data.sort, None, lambda x,y: 0)
|
||||
|
||||
def test_stability(self):
|
||||
data = [(random.randrange(100), i) for i in xrange(200)]
|
||||
data = [(random.randrange(100), i) for i in range(200)]
|
||||
copy = data[:]
|
||||
data.sort(key=lambda (x,y): x) # sort on the random first field
|
||||
copy.sort() # sort using both fields
|
||||
|
@ -204,13 +204,13 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
|
||||
def test_key_with_exception(self):
|
||||
# Verify that the wrapper has been removed
|
||||
data = range(-2,2)
|
||||
data = list(range(-2, 2))
|
||||
dup = data[:]
|
||||
self.assertRaises(ZeroDivisionError, data.sort, None, lambda x: 1/x)
|
||||
self.assertEqual(data, dup)
|
||||
|
||||
def test_key_with_mutation(self):
|
||||
data = range(10)
|
||||
data = list(range(10))
|
||||
def k(x):
|
||||
del data[:]
|
||||
data[:] = range(20)
|
||||
|
@ -218,7 +218,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
self.assertRaises(ValueError, data.sort, key=k)
|
||||
|
||||
def test_key_with_mutating_del(self):
|
||||
data = range(10)
|
||||
data = list(range(10))
|
||||
class SortKiller(object):
|
||||
def __init__(self, x):
|
||||
pass
|
||||
|
@ -230,7 +230,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
self.assertRaises(ValueError, data.sort, key=SortKiller)
|
||||
|
||||
def test_key_with_mutating_del_and_exception(self):
|
||||
data = range(10)
|
||||
data = list(range(10))
|
||||
## dup = data[:]
|
||||
class SortKiller(object):
|
||||
def __init__(self, x):
|
||||
|
@ -238,7 +238,7 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
raise RuntimeError
|
||||
def __del__(self):
|
||||
del data[:]
|
||||
data[:] = range(20)
|
||||
data[:] = list(range(20))
|
||||
self.assertRaises(RuntimeError, data.sort, key=SortKiller)
|
||||
## major honking subtlety: we *can't* do:
|
||||
##
|
||||
|
@ -250,14 +250,14 @@ class TestDecorateSortUndecorate(unittest.TestCase):
|
|||
## date (this cost some brain cells to figure out...).
|
||||
|
||||
def test_reverse(self):
|
||||
data = range(100)
|
||||
data = list(range(100))
|
||||
random.shuffle(data)
|
||||
data.sort(reverse=True)
|
||||
self.assertEqual(data, range(99,-1,-1))
|
||||
self.assertEqual(data, list(range(99,-1,-1)))
|
||||
self.assertRaises(TypeError, data.sort, "wrong type")
|
||||
|
||||
def test_reverse_stability(self):
|
||||
data = [(random.randrange(100), i) for i in xrange(200)]
|
||||
data = [(random.randrange(100), i) for i in range(200)]
|
||||
copy1 = data[:]
|
||||
copy2 = data[:]
|
||||
data.sort(cmp=lambda x,y: cmp(x[0],y[0]), reverse=True)
|
||||
|
@ -281,7 +281,7 @@ def test_main(verbose=None):
|
|||
if verbose and hasattr(sys, "gettotalrefcount"):
|
||||
import gc
|
||||
counts = [None] * 5
|
||||
for i in xrange(len(counts)):
|
||||
for i in range(len(counts)):
|
||||
test_support.run_unittest(*test_classes)
|
||||
gc.collect()
|
||||
counts[i] = sys.gettotalrefcount()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue