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

Jeremy Hylton jeremy at zope.com
Wed Apr 23 16:59:31 EDT 2003


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

Modified Files:
	test.py 
Log Message:
Backport the much improved test.py from Zope3.


=== ZODB3/test.py 1.22 => 1.23 === (744/844 lines abridged)
--- ZODB3/test.py:1.22	Mon Jan 13 19:03:57 2003
+++ ZODB3/test.py	Wed Apr 23 15:59:30 2003
@@ -1,18 +1,19 @@
+#! /usr/bin/env python2.2
 ##############################################################################
 #
 # Copyright (c) 2001, 2002 Zope Corporation and Contributors.
 # All Rights Reserved.
-# 
+#
 # This software is subject to the provisions of the Zope Public License,
 # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
-# 
+#
 ##############################################################################
 """
-test.py [-abCdgGLvvt] [modfilter [testfilter]]
+test.py [-aBbcdDfgGhLmprtTuv] [modfilter [testfilter]]
 
 Test harness.
 
@@ -23,10 +24,16 @@
     The default is to run tests at level 1.  --all is a shortcut for -a 0.
 
 -b
-    Run "python setup.py -q build" before running tests, where "python"
+    Run "python setup.py build" before running tests, where "python"
     is the version of python used to run test.py.  Highly recommended.
+    Tests will be run from the build directory.  (Note: In Python < 2.3
+    the -q flag is added to the setup.py command line.)
+
+-B
+    Run "python setup.py build_ext -i" before running tests.  Tests will be
+    run from the source directory.
 
--C  use pychecker
+-c  use pychecker
 
 -d
     Instead of the normal test harness, run a debug version which
@@ -38,15 +45,8 @@
 -D
     Works like -d, except that it loads pdb when an exception occurs.
 
--v
-    With one -v, unittest prints a dot (".") for each test run.  With

[-=- -=- -=- 744 lines omitted -=- -=- -=-]

+        # Python 2.3 is more sane in its non -q output
+        if sys.hexversion >= 0x02030000:
+            qflag = ""
+        else:
+            qflag = "-q"
+        cmd = sys.executable + " setup.py " + qflag + " build"
+        if build_inplace:
+            cmd += "_ext -i"
         if VERBOSE:
             print cmd
         sts = os.system(cmd)
@@ -418,19 +738,33 @@
             sys.exit(1)
 
     if VERBOSE:
+        kind = functional and "functional" or "unit"
         if level == 0:
-            print 'Running tests at all levels'
+            print "Running %s tests at all levels" % kind
         else:
-            print 'Running tests at level', level
+            print "Running %s tests at level %d" % (kind, level)
 
     if args:
         if len(args) > 1:
             test_filter = args[1]
         module_filter = args[0]
     try:
-        bad = main(module_filter, test_filter)
-        if bad:
-            sys.exit(1)
+        if TRACE:
+            # if the trace module is used, then we don't exit with
+            # status if on a false return value from main.
+            coverdir = os.path.join(os.getcwd(), "coverage")
+            import trace
+            tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix],
+                                 trace=0, count=1)
+
+            tracer.runctx("main(module_filter, test_filter, libdir)",
+                          globals=globals(), locals=vars())
+            r = tracer.results()
+            r.write_results(show_missing=True, summary=True, coverdir=coverdir)
+        else:
+            bad = main(module_filter, test_filter, libdir)
+            if bad:
+                sys.exit(1)
     except ImportError, err:
         print err
         print sys.path




More information about the Zodb-checkins mailing list