[Checkins] SVN: manuel/trunk/src/manuel/sphinx. Use the same doctest defaults as Sphinx does

Lennart Regebro regebro at gmail.com
Sun Jan 3 15:12:34 EST 2010


Log message for revision 107601:
  Use the same doctest defaults as Sphinx does

Changed:
  U   manuel/trunk/src/manuel/sphinx.py
  U   manuel/trunk/src/manuel/sphinx.txt

-=-
Modified: manuel/trunk/src/manuel/sphinx.py
===================================================================
--- manuel/trunk/src/manuel/sphinx.py	2010-01-03 19:51:17 UTC (rev 107600)
+++ manuel/trunk/src/manuel/sphinx.py	2010-01-03 20:12:34 UTC (rev 107601)
@@ -5,7 +5,7 @@
 doctest = __import__('doctest')
 import manuel.doctest
 
-BLOCK_START = re.compile(r'^\.\. test(setup|code|output)::(.*?)\n\n',
+BLOCK_START = re.compile(r'^\.\. test(setup|code|output)::(.*?)\n\s*\n',
                          re.MULTILINE|re.DOTALL)
 BLOCK_END = re.compile(r'(\n\Z|\n(?=\S))')
 
@@ -126,14 +126,19 @@
         if match:
             exc_msg = match.group('msg')
             
+    test_options = {doctest.ELLIPSIS: True,
+                    doctest.IGNORE_EXCEPTION_DETAIL: True,
+                    doctest.DONT_ACCEPT_TRUE_FOR_1: True,
+                    }        
     options = region.parsed.options
     if options:
-        import pdb;pdb.set_trace()
-        options = dict([(eval('doctest.' + x.strip()[1:]), True) for x in options.split(',')])
-        
-        
+        for x in options.split(','):
+            x = x.strip()
+            sign = x[0]
+            value = eval('doctest.' + x[1:])
+            test_options[value] = sign == '+'        
     example = doctest.Example(region.parsed.code, output, exc_msg=exc_msg,
-                              lineno=region.lineno, options=options)
+                              lineno=region.lineno, options=test_options)
     test = doctest.DocTest([example], globs, test_name, document.location,
                            region.lineno-1, None)
     runner = doctest.DocTestRunner()

Modified: manuel/trunk/src/manuel/sphinx.txt
===================================================================
--- manuel/trunk/src/manuel/sphinx.txt	2010-01-03 19:51:17 UTC (rev 107600)
+++ manuel/trunk/src/manuel/sphinx.txt	2010-01-03 20:12:34 UTC (rev 107601)
@@ -44,7 +44,8 @@
     ...     print lyrics
     ...
     ... .. testoutput::
-    ...
+    ...     :hide:
+    ...    
     ...     Da doo ron ron
     ...
     ... """



More information about the checkins mailing list