summaryrefslogtreecommitdiff
path: root/Lib/test/test_collections.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-11-30 01:18:17 +0000
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-11-30 01:18:17 +0000
commit1fea5c4472b29fff85ae40a8d7f0c845347ad5c6 (patch)
treea159285c250922c6e4528a12fc7b29c0f6f086bb /Lib/test/test_collections.py
parent30ec1154aca1756a35c8bfe9ff35bfa77073ceba (diff)
downloadcpython-git-1fea5c4472b29fff85ae40a8d7f0c845347ad5c6.tar.gz
Merged revisions 86857 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r86857 | raymond.hettinger | 2010-11-28 22:56:12 -0500 (Sun, 28 Nov 2010) | 1 line Issue #10565: Iterator ABC should require both __next__ and __iter__. ........
Diffstat (limited to 'Lib/test/test_collections.py')
-rw-r--r--Lib/test/test_collections.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 94305ab2f4..2d2319fe26 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -355,8 +355,19 @@ class TestOneTrickPonyABCs(ABCTestCase):
for x in samples:
self.assertIsInstance(x, Iterator)
self.assertTrue(issubclass(type(x), Iterator), repr(type(x)))
- self.validate_abstract_methods(Iterator, 'next')
- self.validate_isinstance(Iterator, 'next')
+ self.validate_abstract_methods(Iterator, 'next', '__iter__')
+
+ # Issue 10565
+ class NextOnly:
+ def __next__(self):
+ yield 1
+ raise StopIteration
+ self.assertNotIsInstance(NextOnly(), Iterator)
+ class NextOnlyNew(object):
+ def __next__(self):
+ yield 1
+ raise StopIteration
+ self.assertNotIsInstance(NextOnlyNew(), Iterator)
def test_Sized(self):
non_samples = [None, 42, 3.14, 1j,