[Zope3-checkins] CVS: Zope3 - test.py:1.14

Jim Fulton jim@zope.com
Thu, 3 Oct 2002 16:15:54 -0400


Update of /cvs-repository/Zope3
In directory cvs.zope.org:/tmp/cvs-serv31220

Modified Files:
	test.py 
Log Message:
Added a debug function to facilitate post-mortem debugging of failed
tests. 


=== Zope3/test.py 1.13 => 1.14 ===
--- Zope3/test.py:1.13	Wed Sep 18 11:05:50 2002
+++ Zope3/test.py	Thu Oct  3 16:15:53 2002
@@ -434,3 +434,25 @@
 if __name__ == "__main__":
     process_args()
 
+# The following method is for debugging unit tests from a Python prompt:
+def debug(args=""):
+    """Debug your unit tests with the post mortem debugger.
+
+    Just run the debug function with a string containing command-line
+    arguments. (The function uses a cheesy parser, aka split. ;)
+
+    For example, to debug the tests in package Zope.App.DublinCore::
+
+      import test
+      test.debug('Zope.App.DublinCore')
+
+    At the first failure or error, an exception will be raised. At
+    that point, you can use pdb's post-mortem debugger::
+
+      import pdb
+      pdb.pm()
+
+    """    
+    
+    process_args(["", "-d"] + args.split())
+