[pypy-svn] r56436 - in pypy/dist/pypy/module/itertools: . test

adurdin at codespeak.net adurdin at codespeak.net
Fri Jul 11 10:09:16 CEST 2008


Author: adurdin
Date: Fri Jul 11 10:09:15 2008
New Revision: 56436

Modified:
   pypy/dist/pypy/module/itertools/__init__.py
   pypy/dist/pypy/module/itertools/test/test_itertools.py
Log:
(adurdin, jlg) Added test for presence of docstrings.

Modified: pypy/dist/pypy/module/itertools/__init__.py
==============================================================================
--- pypy/dist/pypy/module/itertools/__init__.py	(original)
+++ pypy/dist/pypy/module/itertools/__init__.py	Fri Jul 11 10:09:15 2008
@@ -2,7 +2,27 @@
 from pypy.interpreter.mixedmodule import MixedModule 
 
 class Module(MixedModule):
-    """An itertools module."""
+    """Functional tools for creating and using iterators.
+
+    Infinite iterators:
+    count([n]) --> n, n+1, n+2, ...
+    cycle(p) --> p0, p1, ... plast, p0, p1, ...
+    repeat(elem [,n]) --> elem, elem, elem, ... endlessly or up to n times
+
+    Iterators terminating on the shortest input sequence:
+    izip(p, q, ...) --> (p[0], q[0]), (p[1], q[1]), ... 
+    ifilter(pred, seq) --> elements of seq where pred(elem) is True
+    ifilterfalse(pred, seq) --> elements of seq where pred(elem) is False
+    islice(seq, [start,] stop [, step]) --> elements from
+           seq[start:stop:step]
+    imap(fun, p, q, ...) --> fun(p0, q0), fun(p1, q1), ...
+    starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...
+    tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n
+    chain(p, q, ...) --> p0, p1, ... plast, q0, q1, ... 
+    takewhile(pred, seq) --> seq[0], seq[1], until pred fails
+    dropwhile(pred, seq) --> seq[n], seq[n+1], starting when pred fails
+    groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)
+    """
 
     interpleveldefs = {
         'count'     : 'interp_itertools.W_Count',

Modified: pypy/dist/pypy/module/itertools/test/test_itertools.py
==============================================================================
--- pypy/dist/pypy/module/itertools/test/test_itertools.py	(original)
+++ pypy/dist/pypy/module/itertools/test/test_itertools.py	Fri Jul 11 10:09:15 2008
@@ -242,6 +242,23 @@
 
         raises(TypeError, itertools.islice, [], 0, 0, 0, 0)
 
+    def test_docstrings(self):
+        import itertools
+        
+        assert itertools.__doc__ != ""
+        methods = [
+            itertools.count,
+            itertools.repeat,
+            itertools.takewhile,
+            itertools.dropwhile,
+            itertools.ifilter,
+            itertools.ifilterfalse,
+            itertools.islice,
+            ]
+        for method in methods:
+            assert method.__doc__ != ""
+        
+
     def test_subclassing(self):
         import itertools
         # not sure how useful this actually is, but CPython implements it



More information about the Pypy-commit mailing list