[pypy-svn] r12319 - pypy/dist/pypy/documentation

hpk at codespeak.net hpk at codespeak.net
Sun May 15 19:48:03 CEST 2005


Author: hpk
Date: Sun May 15 19:48:03 2005
New Revision: 12319

Modified:
   pypy/dist/pypy/documentation/conftest.py
   pypy/dist/pypy/documentation/getting_started.txt
Log:
issue4 testing 

There is now preliminary doctest support for our documentation files 
executing ">>>" prompts at interpreter level with the doctest module
behind the scenes.   This makes some code snippets fail but also 
many of them work.  In getting_started.txt you'll see the
way you can specify scopes that will not be shown in the
generated html. 

.. >>> from os.path import abspath 

   >>> assert abspath 

will pass the doctest and the import-line will be ignored by
html generation  (at least it should be).  

Let's see if this approach is sensible enough. 

Applevel doctests (i.e. >>>> prompts) are not implemented yet 
and are probably a post-M0.5 matter. (and running them simply
at app level would be at least be slow if not somewhat messy). 

P.S.: you need to "svn up" at dist-level because most of 
      the doctest support code comes with the py lib 
      but upgrading at dist-level is always a good idea. 



Modified: pypy/dist/pypy/documentation/conftest.py
==============================================================================
--- pypy/dist/pypy/documentation/conftest.py	(original)
+++ pypy/dist/pypy/documentation/conftest.py	Sun May 15 19:48:03 2005
@@ -1,3 +1,26 @@
+import py
+from py.__.documentation.conftest import Directory, DoctestText, ReSTChecker
 
-from py.__.documentation.conftest import * 
+class PyPyDoctestText(DoctestText): 
+    def execute(self, module, docstring): 
+        # XXX execute PyPy prompts as well 
+        l = []
+        for line in docstring.split('\n'): 
+            if line.find('>>>>') != -1: 
+                line = "" 
+            l.append(line) 
+        text = "\n".join(l) 
+        super(PyPyDoctestText, self).execute(module, text) 
 
+        #mod = py.std.types.ModuleType(self.fspath.basename, text) 
+        #self.mergescopes(mod, scopes) 
+        #failed, tot = py.std.doctest.testmod(mod, verbose=1)
+        #if failed:
+        #    py.test.fail("doctest %s: %s failed out of %s" %(
+        #                 self.fspath, failed, tot))
+
+class PyPyReSTChecker(ReSTChecker): 
+    DoctestText = PyPyDoctestText 
+    
+class Directory(Directory): 
+    ReSTChecker = PyPyReSTChecker 

Modified: pypy/dist/pypy/documentation/getting_started.txt
==============================================================================
--- pypy/dist/pypy/documentation/getting_started.txt	(original)
+++ pypy/dist/pypy/documentation/getting_started.txt	Sun May 15 19:48:03 2005
@@ -189,6 +189,9 @@
 
         >>> t = Translator(test.is_perfect_number)
         >>> t.view()
+        
+.. >>> from pypy.translator.translator import Translator 
+.. >>> from pypy.translator.test import snippet as test 
 
 4. We have a type annotator that can completely infer types for functions like
    ``is_perfect_number``::



More information about the Pypy-commit mailing list