diff options
author | Georg Brandl <georg@python.org> | 2007-04-21 15:47:16 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2007-04-21 15:47:16 (GMT) |
commit | a18af4e7a2091d11478754eb66ae387a85535763 (patch) | |
tree | fea8015d656cfee937bb6f3d106e6ca0e9f19d78 /Lib/test/test_enumerate.py | |
parent | 4d2adcca52ced412d4bdf131b872729c43520d58 (diff) | |
download | cpython-a18af4e7a2091d11478754eb66ae387a85535763.zip cpython-a18af4e7a2091d11478754eb66ae387a85535763.tar.gz cpython-a18af4e7a2091d11478754eb66ae387a85535763.tar.bz2 |
PEP 3114: rename .next() to .__next__() and add next() builtin.
Diffstat (limited to 'Lib/test/test_enumerate.py')
-rw-r--r-- | Lib/test/test_enumerate.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Lib/test/test_enumerate.py b/Lib/test/test_enumerate.py index 6290070..af7512d 100644 --- a/Lib/test/test_enumerate.py +++ b/Lib/test/test_enumerate.py @@ -17,7 +17,7 @@ class I: self.i = 0 def __iter__(self): return self - def next(self): + def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 @@ -37,7 +37,7 @@ class X: def __init__(self, seqn): self.seqn = seqn self.i = 0 - def next(self): + def __next__(self): if self.i >= len(self.seqn): raise StopIteration v = self.seqn[self.i] self.i += 1 @@ -50,11 +50,11 @@ class E: self.i = 0 def __iter__(self): return self - def next(self): + def __next__(self): 3 // 0 class N: - 'Iterator missing next()' + 'Iterator missing __next__()' def __init__(self, seqn): self.seqn = seqn self.i = 0 @@ -76,17 +76,17 @@ class EnumerateTestCase(unittest.TestCase): def test_getitemseqn(self): self.assertEqual(list(self.enum(G(self.seq))), self.res) e = self.enum(G('')) - self.assertRaises(StopIteration, e.next) + self.assertRaises(StopIteration, next, e) def test_iteratorseqn(self): self.assertEqual(list(self.enum(I(self.seq))), self.res) e = self.enum(I('')) - self.assertRaises(StopIteration, e.next) + self.assertRaises(StopIteration, next, e) def test_iteratorgenerator(self): self.assertEqual(list(self.enum(Ig(self.seq))), self.res) e = self.enum(Ig('')) - self.assertRaises(StopIteration, e.next) + self.assertRaises(StopIteration, next, e) def test_noniterable(self): self.assertRaises(TypeError, self.enum, X(self.seq)) |