mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
#2831: add start argument to enumerate(). Patch by Scott Dial and me.
This commit is contained in:
parent
ef9764f1a4
commit
913835763a
3 changed files with 45 additions and 11 deletions
|
|
@ -100,7 +100,8 @@ class EnumerateTestCase(unittest.TestCase):
|
|||
def test_argumentcheck(self):
|
||||
self.assertRaises(TypeError, self.enum) # no arguments
|
||||
self.assertRaises(TypeError, self.enum, 1) # wrong type (not iterable)
|
||||
self.assertRaises(TypeError, self.enum, 'abc', 2) # too many arguments
|
||||
self.assertRaises(TypeError, self.enum, 'abc', 'a') # wrong type
|
||||
self.assertRaises(TypeError, self.enum, 'abc', 2, 3) # too many arguments
|
||||
|
||||
def test_tuple_reuse(self):
|
||||
# Tests an implementation detail where tuple is reused
|
||||
|
|
@ -196,6 +197,19 @@ class TestReversed(unittest.TestCase):
|
|||
self.assertEqual(rc, sys.getrefcount(r))
|
||||
|
||||
|
||||
class TestStart(EnumerateTestCase):
|
||||
|
||||
enum = lambda i: enumerate(i, start=11)
|
||||
seq, res = 'abc', [(1, 'a'), (2, 'b'), (3, 'c')]
|
||||
|
||||
|
||||
class TestLongStart(EnumerateTestCase):
|
||||
|
||||
enum = lambda i: enumerate(i, start=sys.maxint+1)
|
||||
seq, res = 'abc', [(sys.maxint+1,'a'), (sys.maxint+2,'b'),
|
||||
(sys.maxint+3,'c')]
|
||||
|
||||
|
||||
def test_main(verbose=None):
|
||||
testclasses = (EnumerateTestCase, SubclassTestCase, TestEmpty, TestBig,
|
||||
TestReversed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue