2002-04-27 03:40:56 +08:00
|
|
|
import unittest
|
2012-10-06 20:03:24 +08:00
|
|
|
import operator
|
2005-07-12 18:21:19 +08:00
|
|
|
import sys
|
2012-04-03 18:49:41 +08:00
|
|
|
import pickle
|
2002-04-27 03:40:56 +08:00
|
|
|
|
2008-05-21 05:35:26 +08:00
|
|
|
from test import support
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
class G:
|
|
|
|
'Sequence using __getitem__'
|
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
def __getitem__(self, i):
|
|
|
|
return self.seqn[i]
|
|
|
|
|
|
|
|
class I:
|
|
|
|
'Sequence using iterator protocol'
|
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
self.i = 0
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
2007-04-21 23:47:16 +08:00
|
|
|
def __next__(self):
|
2002-04-27 03:40:56 +08:00
|
|
|
if self.i >= len(self.seqn): raise StopIteration
|
|
|
|
v = self.seqn[self.i]
|
|
|
|
self.i += 1
|
|
|
|
return v
|
|
|
|
|
|
|
|
class Ig:
|
|
|
|
'Sequence using iterator protocol defined with a generator'
|
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
self.i = 0
|
|
|
|
def __iter__(self):
|
|
|
|
for val in self.seqn:
|
|
|
|
yield val
|
|
|
|
|
|
|
|
class X:
|
|
|
|
'Missing __getitem__ and __iter__'
|
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
self.i = 0
|
2007-04-21 23:47:16 +08:00
|
|
|
def __next__(self):
|
2002-04-27 03:40:56 +08:00
|
|
|
if self.i >= len(self.seqn): raise StopIteration
|
|
|
|
v = self.seqn[self.i]
|
|
|
|
self.i += 1
|
|
|
|
return v
|
|
|
|
|
|
|
|
class E:
|
|
|
|
'Test propagation of exceptions'
|
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
self.i = 0
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
2007-04-21 23:47:16 +08:00
|
|
|
def __next__(self):
|
2004-09-27 23:29:05 +08:00
|
|
|
3 // 0
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
class N:
|
2007-04-21 23:47:16 +08:00
|
|
|
'Iterator missing __next__()'
|
2002-04-27 03:40:56 +08:00
|
|
|
def __init__(self, seqn):
|
|
|
|
self.seqn = seqn
|
|
|
|
self.i = 0
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2012-04-03 18:49:41 +08:00
|
|
|
class PickleTest:
|
|
|
|
# Helper to check picklability
|
|
|
|
def check_pickle(self, itorg, seq):
|
|
|
|
d = pickle.dumps(itorg)
|
|
|
|
it = pickle.loads(d)
|
|
|
|
self.assertEqual(type(itorg), type(it))
|
|
|
|
self.assertEqual(list(it), seq)
|
|
|
|
|
|
|
|
it = pickle.loads(d)
|
|
|
|
try:
|
|
|
|
next(it)
|
|
|
|
except StopIteration:
|
|
|
|
self.assertFalse(seq[1:])
|
|
|
|
return
|
|
|
|
d = pickle.dumps(it)
|
|
|
|
it = pickle.loads(d)
|
|
|
|
self.assertEqual(list(it), seq[1:])
|
|
|
|
|
|
|
|
class EnumerateTestCase(unittest.TestCase, PickleTest):
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
enum = enumerate
|
2003-05-28 22:05:34 +08:00
|
|
|
seq, res = 'abc', [(0,'a'), (1,'b'), (2,'c')]
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_basicfunction(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertEqual(type(self.enum(self.seq)), self.enum)
|
|
|
|
e = self.enum(self.seq)
|
2002-04-27 03:40:56 +08:00
|
|
|
self.assertEqual(iter(e), e)
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertEqual(list(self.enum(self.seq)), self.res)
|
2002-04-27 03:40:56 +08:00
|
|
|
self.enum.__doc__
|
|
|
|
|
2012-04-03 18:49:41 +08:00
|
|
|
def test_pickle(self):
|
|
|
|
self.check_pickle(self.enum(self.seq), self.res)
|
|
|
|
|
2002-04-27 03:40:56 +08:00
|
|
|
def test_getitemseqn(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertEqual(list(self.enum(G(self.seq))), self.res)
|
2002-04-27 03:40:56 +08:00
|
|
|
e = self.enum(G(''))
|
2007-04-21 23:47:16 +08:00
|
|
|
self.assertRaises(StopIteration, next, e)
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_iteratorseqn(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertEqual(list(self.enum(I(self.seq))), self.res)
|
2002-04-27 03:40:56 +08:00
|
|
|
e = self.enum(I(''))
|
2007-04-21 23:47:16 +08:00
|
|
|
self.assertRaises(StopIteration, next, e)
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_iteratorgenerator(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertEqual(list(self.enum(Ig(self.seq))), self.res)
|
2002-04-27 03:40:56 +08:00
|
|
|
e = self.enum(Ig(''))
|
2007-04-21 23:47:16 +08:00
|
|
|
self.assertRaises(StopIteration, next, e)
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_noniterable(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertRaises(TypeError, self.enum, X(self.seq))
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_illformediterable(self):
|
2006-04-15 17:16:16 +08:00
|
|
|
self.assertRaises(TypeError, self.enum, N(self.seq))
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
def test_exception_propagation(self):
|
2003-05-28 22:05:34 +08:00
|
|
|
self.assertRaises(ZeroDivisionError, list, self.enum(E(self.seq)))
|
|
|
|
|
|
|
|
def test_argumentcheck(self):
|
|
|
|
self.assertRaises(TypeError, self.enum) # no arguments
|
|
|
|
self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable)
|
Merged revisions 63208-63209,63211-63212,63214-63217,63219-63224,63226-63227,63229-63232,63234-63235,63237-63239,63241,63243-63246,63250-63254,63256-63259,63261,63263-63264,63266-63267,63269-63270,63272-63273,63275-63276,63278,63280-63281,63283-63284,63286-63287,63289-63290,63292-63293,63295-63296,63298-63299,63301-63302,63304-63305,63307,63309-63314,63316-63322,63324-63325,63327-63335,63337-63338,63340-63342,63344-63346,63348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines
Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines
Fix a refleak in the _warnings module.
........
r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line
List all the removes and renamed modules
........
r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines
Rewrap some lines in test_py3kwarn.
........
r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines
Add NEWS entry for #2831.
........
r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines
Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
in r62788.
........
r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines
Fix another "refleak" by clearing the filters after test.
........
r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines
Install the json package and tests as well as the lib2to3 tests
so the tests work when run from an install directory.
They are currently skipped on the daily runs (not from the buildbots)
for checking refleaks, etc.
........
r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line
Note some removals and a rename
........
r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines
Add a snippet for the deprecation directive for docs.
........
r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines
disable the crashing test. I will also file a bug. This crash does
not appear to be a new bug, its just that the test coverage went up
recently exposing it. (I verified that by testing this test code on
an older Modules/_bsddb.c)
........
r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines
#2863: add gen.__name__ and add this name to generator repr().
........
r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line
Import class from distutils.cmd, not .core, to avoid circular import
........
r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines
Fixed typo in a doctest of test_genexps.
........
r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines
add Mac modules to the list of deprecated ones
........
r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines
fix typos in whatsnew
........
r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines
make test_platform a bit more assertive (We'll see what the buildbots say.)
........
2008-05-16 12:39:54 +08:00
|
|
|
self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type
|
|
|
|
self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
|
2003-05-28 22:05:34 +08:00
|
|
|
|
2010-06-26 07:24:35 +08:00
|
|
|
@support.cpython_only
|
2003-05-28 22:05:34 +08:00
|
|
|
def test_tuple_reuse(self):
|
|
|
|
# Tests an implementation detail where tuple is reused
|
|
|
|
# whenever nothing else holds a reference to it
|
2003-11-17 00:17:49 +08:00
|
|
|
self.assertEqual(len(set(map(id, list(enumerate(self.seq))))), len(self.seq))
|
|
|
|
self.assertEqual(len(set(map(id, enumerate(self.seq)))), min(1,len(self.seq)))
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
class MyEnum(enumerate):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class SubclassTestCase(EnumerateTestCase):
|
|
|
|
|
|
|
|
enum = MyEnum
|
|
|
|
|
2003-05-28 22:05:34 +08:00
|
|
|
class TestEmpty(EnumerateTestCase):
|
|
|
|
|
|
|
|
seq, res = '', []
|
|
|
|
|
|
|
|
class TestBig(EnumerateTestCase):
|
|
|
|
|
|
|
|
seq = range(10,20000,2)
|
2006-08-25 03:48:10 +08:00
|
|
|
res = list(zip(range(20000), seq))
|
2003-05-28 22:05:34 +08:00
|
|
|
|
2012-04-03 18:49:41 +08:00
|
|
|
class TestReversed(unittest.TestCase, PickleTest):
|
2003-11-06 22:06:48 +08:00
|
|
|
|
|
|
|
def test_simple(self):
|
|
|
|
class A:
|
|
|
|
def __getitem__(self, i):
|
|
|
|
if i < 5:
|
|
|
|
return str(i)
|
|
|
|
raise StopIteration
|
|
|
|
def __len__(self):
|
|
|
|
return 5
|
2007-05-08 06:24:25 +08:00
|
|
|
for data in 'abc', range(5), tuple(enumerate('abc')), A(), range(1,17,5):
|
2003-11-06 22:06:48 +08:00
|
|
|
self.assertEqual(list(data)[::-1], list(reversed(data)))
|
|
|
|
self.assertRaises(TypeError, reversed, {})
|
Merged revisions 63361-63373,63375,63377-63380 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63361 | alexandre.vassalotti | 2008-05-16 03:14:08 -0400 (Fri, 16 May 2008) | 2 lines
Rename the test file of reprlib.
........
r63364 | georg.brandl | 2008-05-16 05:34:48 -0400 (Fri, 16 May 2008) | 2 lines
Make generator repr consistent with function and code object repr.
........
r63365 | georg.brandl | 2008-05-16 05:47:29 -0400 (Fri, 16 May 2008) | 2 lines
#2869: remove parameter from signature.
........
r63366 | christian.heimes | 2008-05-16 06:23:31 -0400 (Fri, 16 May 2008) | 1 line
Fixed #2870: cmathmodule.c compile error
........
r63367 | christian.heimes | 2008-05-16 07:28:56 -0400 (Fri, 16 May 2008) | 1 line
Following Amaury's advice
........
r63368 | georg.brandl | 2008-05-16 09:10:15 -0400 (Fri, 16 May 2008) | 2 lines
#2890: support os.O_ASYNC and fcntl.FASYNC.
........
r63369 | georg.brandl | 2008-05-16 09:18:50 -0400 (Fri, 16 May 2008) | 2 lines
#2845: fix copy2's docs.
........
r63370 | georg.brandl | 2008-05-16 09:24:29 -0400 (Fri, 16 May 2008) | 2 lines
Don't allow keyword arguments to reversed().
........
r63373 | georg.brandl | 2008-05-16 09:41:26 -0400 (Fri, 16 May 2008) | 2 lines
Document O_ASYNC addition.
........
r63380 | georg.brandl | 2008-05-16 13:33:13 -0400 (Fri, 16 May 2008) | 2 lines
Fix reprlib docs.
........
2008-05-17 02:15:12 +08:00
|
|
|
# don't allow keyword arguments
|
|
|
|
self.assertRaises(TypeError, reversed, [], a=1)
|
2003-11-06 22:06:48 +08:00
|
|
|
|
2007-05-08 06:24:25 +08:00
|
|
|
def test_range_optimization(self):
|
|
|
|
x = range(1)
|
2003-11-06 22:06:48 +08:00
|
|
|
self.assertEqual(type(reversed(x)), type(iter(x)))
|
2003-05-28 22:05:34 +08:00
|
|
|
|
2004-02-10 17:33:39 +08:00
|
|
|
def test_len(self):
|
2007-05-08 06:24:25 +08:00
|
|
|
for s in ('hello', tuple('hello'), list('hello'), range(5)):
|
2012-10-06 20:03:24 +08:00
|
|
|
self.assertEqual(operator.length_hint(reversed(s)), len(s))
|
2004-09-29 19:40:50 +08:00
|
|
|
r = reversed(s)
|
|
|
|
list(r)
|
2012-10-06 20:03:24 +08:00
|
|
|
self.assertEqual(operator.length_hint(r), 0)
|
2004-09-29 19:40:50 +08:00
|
|
|
class SeqWithWeirdLen:
|
|
|
|
called = False
|
|
|
|
def __len__(self):
|
|
|
|
if not self.called:
|
|
|
|
self.called = True
|
|
|
|
return 10
|
|
|
|
raise ZeroDivisionError
|
|
|
|
def __getitem__(self, index):
|
|
|
|
return index
|
|
|
|
r = reversed(SeqWithWeirdLen())
|
2012-10-06 20:03:24 +08:00
|
|
|
self.assertRaises(ZeroDivisionError, operator.length_hint, r)
|
2004-09-29 19:40:50 +08:00
|
|
|
|
|
|
|
|
|
|
|
def test_gc(self):
|
|
|
|
class Seq:
|
|
|
|
def __len__(self):
|
|
|
|
return 10
|
|
|
|
def __getitem__(self, index):
|
|
|
|
return index
|
|
|
|
s = Seq()
|
|
|
|
r = reversed(s)
|
|
|
|
s.r = r
|
|
|
|
|
|
|
|
def test_args(self):
|
|
|
|
self.assertRaises(TypeError, reversed)
|
|
|
|
self.assertRaises(TypeError, reversed, [], 'extra')
|
2004-02-10 17:33:39 +08:00
|
|
|
|
2005-07-12 18:21:19 +08:00
|
|
|
def test_bug1229429(self):
|
|
|
|
# this bug was never in reversed, it was in
|
|
|
|
# PyObject_CallMethod, and reversed_new calls that sometimes.
|
|
|
|
if not hasattr(sys, "getrefcount"):
|
|
|
|
return
|
|
|
|
def f():
|
|
|
|
pass
|
|
|
|
r = f.__reversed__ = object()
|
|
|
|
rc = sys.getrefcount(r)
|
|
|
|
for i in range(10):
|
|
|
|
try:
|
|
|
|
reversed(f)
|
|
|
|
except TypeError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
self.fail("non-callable __reversed__ didn't raise!")
|
|
|
|
self.assertEqual(rc, sys.getrefcount(r))
|
2005-07-18 07:16:17 +08:00
|
|
|
|
2010-05-26 03:06:24 +08:00
|
|
|
def test_objmethods(self):
|
|
|
|
# Objects must have __len__() and __getitem__() implemented.
|
|
|
|
class NoLen(object):
|
|
|
|
def __getitem__(self): return 1
|
|
|
|
nl = NoLen()
|
|
|
|
self.assertRaises(TypeError, reversed, nl)
|
|
|
|
|
|
|
|
class NoGetItem(object):
|
|
|
|
def __len__(self): return 2
|
|
|
|
ngi = NoGetItem()
|
|
|
|
self.assertRaises(TypeError, reversed, ngi)
|
|
|
|
|
2012-04-03 18:49:41 +08:00
|
|
|
def test_pickle(self):
|
|
|
|
for data in 'abc', range(5), tuple(enumerate('abc')), range(1,17,5):
|
|
|
|
self.check_pickle(reversed(data), list(data)[::-1])
|
|
|
|
|
2005-07-12 18:21:19 +08:00
|
|
|
|
2010-05-09 00:51:16 +08:00
|
|
|
class EnumerateStartTestCase(EnumerateTestCase):
|
Merged revisions 63208-63209,63211-63212,63214-63217,63219-63224,63226-63227,63229-63232,63234-63235,63237-63239,63241,63243-63246,63250-63254,63256-63259,63261,63263-63264,63266-63267,63269-63270,63272-63273,63275-63276,63278,63280-63281,63283-63284,63286-63287,63289-63290,63292-63293,63295-63296,63298-63299,63301-63302,63304-63305,63307,63309-63314,63316-63322,63324-63325,63327-63335,63337-63338,63340-63342,63344-63346,63348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines
Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines
Fix a refleak in the _warnings module.
........
r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line
List all the removes and renamed modules
........
r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines
Rewrap some lines in test_py3kwarn.
........
r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines
Add NEWS entry for #2831.
........
r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines
Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
in r62788.
........
r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines
Fix another "refleak" by clearing the filters after test.
........
r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines
Install the json package and tests as well as the lib2to3 tests
so the tests work when run from an install directory.
They are currently skipped on the daily runs (not from the buildbots)
for checking refleaks, etc.
........
r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line
Note some removals and a rename
........
r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines
Add a snippet for the deprecation directive for docs.
........
r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines
disable the crashing test. I will also file a bug. This crash does
not appear to be a new bug, its just that the test coverage went up
recently exposing it. (I verified that by testing this test code on
an older Modules/_bsddb.c)
........
r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines
#2863: add gen.__name__ and add this name to generator repr().
........
r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line
Import class from distutils.cmd, not .core, to avoid circular import
........
r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines
Fixed typo in a doctest of test_genexps.
........
r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines
add Mac modules to the list of deprecated ones
........
r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines
fix typos in whatsnew
........
r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines
make test_platform a bit more assertive (We'll see what the buildbots say.)
........
2008-05-16 12:39:54 +08:00
|
|
|
|
2010-05-09 00:51:16 +08:00
|
|
|
def test_basicfunction(self):
|
|
|
|
e = self.enum(self.seq)
|
|
|
|
self.assertEqual(iter(e), e)
|
|
|
|
self.assertEqual(list(self.enum(self.seq)), self.res)
|
|
|
|
|
|
|
|
|
|
|
|
class TestStart(EnumerateStartTestCase):
|
|
|
|
|
|
|
|
enum = lambda self, i: enumerate(i, start=11)
|
|
|
|
seq, res = 'abc', [(11, 'a'), (12, 'b'), (13, 'c')]
|
Merged revisions 63208-63209,63211-63212,63214-63217,63219-63224,63226-63227,63229-63232,63234-63235,63237-63239,63241,63243-63246,63250-63254,63256-63259,63261,63263-63264,63266-63267,63269-63270,63272-63273,63275-63276,63278,63280-63281,63283-63284,63286-63287,63289-63290,63292-63293,63295-63296,63298-63299,63301-63302,63304-63305,63307,63309-63314,63316-63322,63324-63325,63327-63335,63337-63338,63340-63342,63344-63346,63348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines
Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines
Fix a refleak in the _warnings module.
........
r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line
List all the removes and renamed modules
........
r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines
Rewrap some lines in test_py3kwarn.
........
r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines
Add NEWS entry for #2831.
........
r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines
Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
in r62788.
........
r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines
Fix another "refleak" by clearing the filters after test.
........
r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines
Install the json package and tests as well as the lib2to3 tests
so the tests work when run from an install directory.
They are currently skipped on the daily runs (not from the buildbots)
for checking refleaks, etc.
........
r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line
Note some removals and a rename
........
r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines
Add a snippet for the deprecation directive for docs.
........
r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines
disable the crashing test. I will also file a bug. This crash does
not appear to be a new bug, its just that the test coverage went up
recently exposing it. (I verified that by testing this test code on
an older Modules/_bsddb.c)
........
r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines
#2863: add gen.__name__ and add this name to generator repr().
........
r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line
Import class from distutils.cmd, not .core, to avoid circular import
........
r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines
Fixed typo in a doctest of test_genexps.
........
r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines
add Mac modules to the list of deprecated ones
........
r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines
fix typos in whatsnew
........
r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines
make test_platform a bit more assertive (We'll see what the buildbots say.)
........
2008-05-16 12:39:54 +08:00
|
|
|
|
|
|
|
|
2010-05-09 00:51:16 +08:00
|
|
|
class TestLongStart(EnumerateStartTestCase):
|
Merged revisions 63208-63209,63211-63212,63214-63217,63219-63224,63226-63227,63229-63232,63234-63235,63237-63239,63241,63243-63246,63250-63254,63256-63259,63261,63263-63264,63266-63267,63269-63270,63272-63273,63275-63276,63278,63280-63281,63283-63284,63286-63287,63289-63290,63292-63293,63295-63296,63298-63299,63301-63302,63304-63305,63307,63309-63314,63316-63322,63324-63325,63327-63335,63337-63338,63340-63342,63344-63346,63348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines
Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines
Fix a refleak in the _warnings module.
........
r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line
List all the removes and renamed modules
........
r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines
Rewrap some lines in test_py3kwarn.
........
r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines
Add NEWS entry for #2831.
........
r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines
Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
in r62788.
........
r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines
Fix another "refleak" by clearing the filters after test.
........
r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines
Install the json package and tests as well as the lib2to3 tests
so the tests work when run from an install directory.
They are currently skipped on the daily runs (not from the buildbots)
for checking refleaks, etc.
........
r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line
Note some removals and a rename
........
r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines
Add a snippet for the deprecation directive for docs.
........
r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines
disable the crashing test. I will also file a bug. This crash does
not appear to be a new bug, its just that the test coverage went up
recently exposing it. (I verified that by testing this test code on
an older Modules/_bsddb.c)
........
r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines
#2863: add gen.__name__ and add this name to generator repr().
........
r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line
Import class from distutils.cmd, not .core, to avoid circular import
........
r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines
Fixed typo in a doctest of test_genexps.
........
r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines
add Mac modules to the list of deprecated ones
........
r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines
fix typos in whatsnew
........
r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines
make test_platform a bit more assertive (We'll see what the buildbots say.)
........
2008-05-16 12:39:54 +08:00
|
|
|
|
2010-05-09 00:51:16 +08:00
|
|
|
enum = lambda self, i: enumerate(i, start=sys.maxsize+1)
|
Merged revisions 63208-63209,63211-63212,63214-63217,63219-63224,63226-63227,63229-63232,63234-63235,63237-63239,63241,63243-63246,63250-63254,63256-63259,63261,63263-63264,63266-63267,63269-63270,63272-63273,63275-63276,63278,63280-63281,63283-63284,63286-63287,63289-63290,63292-63293,63295-63296,63298-63299,63301-63302,63304-63305,63307,63309-63314,63316-63322,63324-63325,63327-63335,63337-63338,63340-63342,63344-63346,63348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r63208 | georg.brandl | 2008-05-13 15:04:54 -0400 (Tue, 13 May 2008) | 2 lines
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
........
r63209 | marc-andre.lemburg | 2008-05-13 15:10:45 -0400 (Tue, 13 May 2008) | 3 lines
Remove leftovers from reverted setuptools checkin (they were added in r45525).
........
r63211 | georg.brandl | 2008-05-13 17:32:03 -0400 (Tue, 13 May 2008) | 2 lines
Fix a refleak in the _warnings module.
........
r63212 | andrew.kuchling | 2008-05-13 20:46:41 -0400 (Tue, 13 May 2008) | 1 line
List all the removes and renamed modules
........
r63214 | brett.cannon | 2008-05-13 21:09:40 -0400 (Tue, 13 May 2008) | 2 lines
Rewrap some lines in test_py3kwarn.
........
r63219 | georg.brandl | 2008-05-14 02:34:15 -0400 (Wed, 14 May 2008) | 2 lines
Add NEWS entry for #2831.
........
r63220 | neal.norwitz | 2008-05-14 02:47:56 -0400 (Wed, 14 May 2008) | 3 lines
Fix "refleak" by restoring the tearDown method removed by accident (AFAICT)
in r62788.
........
r63221 | georg.brandl | 2008-05-14 03:18:22 -0400 (Wed, 14 May 2008) | 2 lines
Fix another "refleak" by clearing the filters after test.
........
r63222 | neal.norwitz | 2008-05-14 03:21:42 -0400 (Wed, 14 May 2008) | 5 lines
Install the json package and tests as well as the lib2to3 tests
so the tests work when run from an install directory.
They are currently skipped on the daily runs (not from the buildbots)
for checking refleaks, etc.
........
r63256 | andrew.kuchling | 2008-05-14 21:10:24 -0400 (Wed, 14 May 2008) | 1 line
Note some removals and a rename
........
r63311 | brett.cannon | 2008-05-15 00:36:53 -0400 (Thu, 15 May 2008) | 2 lines
Add a snippet for the deprecation directive for docs.
........
r63313 | gregory.p.smith | 2008-05-15 00:56:18 -0400 (Thu, 15 May 2008) | 5 lines
disable the crashing test. I will also file a bug. This crash does
not appear to be a new bug, its just that the test coverage went up
recently exposing it. (I verified that by testing this test code on
an older Modules/_bsddb.c)
........
r63320 | georg.brandl | 2008-05-15 11:08:32 -0400 (Thu, 15 May 2008) | 2 lines
#2863: add gen.__name__ and add this name to generator repr().
........
r63324 | andrew.kuchling | 2008-05-15 16:07:39 -0400 (Thu, 15 May 2008) | 1 line
Import class from distutils.cmd, not .core, to avoid circular import
........
r63327 | alexandre.vassalotti | 2008-05-15 16:31:42 -0400 (Thu, 15 May 2008) | 2 lines
Fixed typo in a doctest of test_genexps.
........
r63332 | benjamin.peterson | 2008-05-15 18:34:33 -0400 (Thu, 15 May 2008) | 2 lines
add Mac modules to the list of deprecated ones
........
r63333 | benjamin.peterson | 2008-05-15 18:41:16 -0400 (Thu, 15 May 2008) | 2 lines
fix typos in whatsnew
........
r63348 | benjamin.peterson | 2008-05-15 22:24:49 -0400 (Thu, 15 May 2008) | 2 lines
make test_platform a bit more assertive (We'll see what the buildbots say.)
........
2008-05-16 12:39:54 +08:00
|
|
|
seq, res = 'abc', [(sys.maxsize+1,'a'), (sys.maxsize+2,'b'),
|
|
|
|
(sys.maxsize+3,'c')]
|
|
|
|
|
|
|
|
|
2003-05-28 22:05:34 +08:00
|
|
|
def test_main(verbose=None):
|
2010-05-09 00:51:16 +08:00
|
|
|
support.run_unittest(__name__)
|
2003-05-28 22:05:34 +08:00
|
|
|
|
|
|
|
# verify reference counting
|
|
|
|
if verbose and hasattr(sys, "gettotalrefcount"):
|
|
|
|
counts = [None] * 5
|
2007-05-08 06:24:25 +08:00
|
|
|
for i in range(len(counts)):
|
2010-05-26 03:46:20 +08:00
|
|
|
support.run_unittest(__name__)
|
2003-05-28 22:05:34 +08:00
|
|
|
counts[i] = sys.gettotalrefcount()
|
2007-02-09 13:37:30 +08:00
|
|
|
print(counts)
|
2002-04-27 03:40:56 +08:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2003-05-28 22:05:34 +08:00
|
|
|
test_main(verbose=True)
|