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/mapping_tests.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/mapping_tests.py')
-rw-r--r-- | Lib/test/mapping_tests.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index 77d66b2..d595cc5 100644 --- a/Lib/test/mapping_tests.py +++ b/Lib/test/mapping_tests.py @@ -69,7 +69,7 @@ class BasicTestMappingProtocol(unittest.TestCase): if not d: self.fail("Full mapping must compare to True") # keys(), items(), iterkeys() ... def check_iterandlist(iter, lst, ref): - self.assert_(hasattr(iter, 'next')) + self.assert_(hasattr(iter, '__next__')) self.assert_(hasattr(iter, '__iter__')) x = list(iter) self.assert_(set(x)==set(lst)==set(ref)) @@ -81,8 +81,8 @@ class BasicTestMappingProtocol(unittest.TestCase): check_iterandlist(iter(d.items()), list(d.items()), self.reference.items()) #get - key, value = iter(d.items()).next() - knownkey, knownvalue = iter(self.other.items()).next() + key, value = next(iter(d.items())) + knownkey, knownvalue = next(iter(self.other.items())) self.assertEqual(d.get(key, knownvalue), value) self.assertEqual(d.get(knownkey, knownvalue), knownvalue) self.failIf(knownkey in d) @@ -107,8 +107,8 @@ class BasicTestMappingProtocol(unittest.TestCase): self.assertEqual(dict(p), self.reference) d = self._full_mapping(self.reference) #setdefault - key, value = iter(d.items()).next() - knownkey, knownvalue = iter(self.other.items()).next() + key, value = next(iter(d.items())) + knownkey, knownvalue = next(iter(self.other.items())) self.assertEqual(d.setdefault(key, knownvalue), value) self.assertEqual(d[key], value) self.assertEqual(d.setdefault(knownkey, knownvalue), knownvalue) @@ -225,7 +225,7 @@ class BasicTestMappingProtocol(unittest.TestCase): self.i = 1 def __iter__(self): return self - def next(self): + def __next__(self): if self.i: self.i = 0 return 'a' @@ -242,7 +242,7 @@ class BasicTestMappingProtocol(unittest.TestCase): self.i = ord('a') def __iter__(self): return self - def next(self): + def __next__(self): if self.i <= ord('z'): rtn = chr(self.i) self.i += 1 @@ -257,7 +257,7 @@ class BasicTestMappingProtocol(unittest.TestCase): class badseq(object): def __iter__(self): return self - def next(self): + def __next__(self): raise Exc() self.assertRaises(Exc, d.update, badseq()) @@ -456,7 +456,7 @@ class TestMappingProtocol(BasicTestMappingProtocol): class BadSeq(object): def __iter__(self): return self - def next(self): + def __next__(self): raise Exc() self.assertRaises(Exc, self.type2test.fromkeys, BadSeq()) |