[Zodb-checkins] CVS: Zope3/src/zope/testing - doctestunit.py:1.7

Jim Fulton jim at zope.com
Tue Jan 6 14:50:44 EST 2004


Update of /cvs-repository/Zope3/src/zope/testing
In directory cvs.zope.org:/tmp/cvs-serv13690/src/zope/testing

Modified Files:
	doctestunit.py 
Log Message:
Added a post-mortem (pm) option to the debug function.
If given a true value, then the test will be run outside the debugger
until al error occurs, at which point, the error will be printed and
the user will be dropped into the post-mortem debugger.


=== Zope3/src/zope/testing/doctestunit.py 1.6 => 1.7 ===
--- Zope3/src/zope/testing/doctestunit.py:1.6	Mon Nov  3 16:37:50 2003
+++ Zope3/src/zope/testing/doctestunit.py	Tue Jan  6 14:50:43 2004
@@ -226,7 +226,7 @@
         ])
     return testsrc
 
-def debug(module, name):
+def debug(module, name, pm=False):
     """Debug a single doctest test doc string
 
     Provide the module (or dotted name of the module) containing the
@@ -240,9 +240,17 @@
     open(srcfilename, 'w').write(testsrc)
     globs = {}
     globs.update(module.__dict__)
+
     try:
-        # Note that %r is vital here.  '%s' instead can, e.g., cause
-        # backslashes to get treated as metacharacters on Windows.
-        pdb.run("execfile(%r)" % srcfilename, globs, globs)
+        if pm:
+            try:
+                execfile(srcfilename, globs, globs)
+            except:
+                print sys.exc_info()[1]
+                pdb.post_mortem(sys.exc_info()[2])
+        else:
+            # Note that %r is vital here.  '%s' instead can, e.g., cause
+            # backslashes to get treated as metacharacters on Windows.
+            pdb.run("execfile(%r)" % srcfilename, globs, globs)
     finally:
         os.remove(srcfilename)




More information about the Zodb-checkins mailing list