summaryrefslogtreecommitdiff
path: root/test/input/func_non_iterator_returned_py_30.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/input/func_non_iterator_returned_py_30.py')
-rw-r--r--test/input/func_non_iterator_returned_py_30.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/input/func_non_iterator_returned_py_30.py b/test/input/func_non_iterator_returned_py_30.py
new file mode 100644
index 0000000..85a61c2
--- /dev/null
+++ b/test/input/func_non_iterator_returned_py_30.py
@@ -0,0 +1,52 @@
+"""Check non-iterators returned by __iter__ """
+
+# pylint: disable-msg=too-few-public-methods
+
+__revision__ = 0
+
+class FirstGoodIterator(object):
+ """ yields in iterator. """
+
+ def __iter__(self):
+ for index in range(10):
+ yield index
+
+class SecondGoodIterator(object):
+ """ __iter__ and next """
+
+ def __iter__(self):
+ return self
+
+ def next(self): # pylint: disable-msg=no-self-use
+ """ Infinite iterator, but still an iterator """
+ return 1
+
+class ThirdGoodIterator(object):
+ """ Returns other iterator, not the current instance """
+
+ def __iter__(self):
+ return SecondGoodIterator()
+
+class FourthGoodIterator(object):
+ """ __iter__ returns iter(...) """
+
+ def __iter__(self):
+ return iter(range(10))
+
+class FirstBadIterator(object):
+ """ __iter__ returns a list """
+
+ def __iter__(self):
+ return []
+
+class SecondBadIterator(object):
+ """ __iter__ without next """
+
+ def __iter__(self):
+ return self
+
+class ThirdBadIterator(object):
+ """ __iter__ returns an instance of another non-iterator """
+
+ def __iter__(self):
+ return SecondBadIterator()