[Zodb-checkins] CVS: ZODB3 - test.py:1.21

Jeremy Hylton jeremy@zope.com
Fri, 3 Jan 2003 17:06:57 -0500


Update of /cvs-repository/ZODB3
In directory cvs.zope.org:/tmp/cvs-serv20965

Modified Files:
	test.py 
Log Message:
Add -D option


=== ZODB3/test.py 1.20 => 1.21 ===
--- ZODB3/test.py:1.20	Fri Oct  4 20:38:12 2002
+++ ZODB3/test.py	Fri Jan  3 17:06:54 2003
@@ -29,6 +29,9 @@
     Unfortunately, the debug harness doesn't print the name of the
     test, so Use With Care.
 
+-D  debugger
+    Works like -d, except that it loads pdb when an exception occurs.
+
 -v  verbose
     With one -v, unittest prints a dot (".") for each test run.  With
     -vv, unittest prints the name of each test (for some definition of
@@ -82,6 +85,7 @@
 
 import gc
 import os
+import pdb
 import re
 import sys
 import traceback
@@ -262,7 +266,13 @@
             if test_filter is not None:
                 s = filter_testcases(s, test_filter)
             suite.addTest(s)
-    r = runner.run(suite)
+    try:
+        r = runner.run(suite)
+    except:
+        if debugger:
+            pdb.post_mortem(sys.exc_info()[2])
+        else:
+            raise
 
 def remove_stale_bytecode(arg, dirname, names):
     names = map(os.path.normcase, names)
@@ -296,6 +306,7 @@
     global VERBOSE
     global LOOP
     global debug
+    global debugger
     global build
     global gcthresh
     global gcdebug
@@ -305,12 +316,13 @@
     VERBOSE = 0
     LOOP = 0
     debug = 0 # Don't collect test results; simply let tests crash
+    debugger = 0
     build = 0
     gcthresh = None
     gcdebug = 0
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], 'vdLbhCg:G:',
+        opts, args = getopt.getopt(sys.argv[1:], 'DvdLbhCg:G:',
                                    ['help'])
     except getopt.error, msg:
         print msg
@@ -322,6 +334,9 @@
             VERBOSE += 1
         elif k == '-d':
             debug = 1
+        elif k == '-D':
+            debug = 1
+            debugger = 1
         elif k == '-L':
             LOOP = 1
         elif k == '-b':