[Zope-Checkins] CVS: Zope - test.py:1.2
Jeremy Hylton
jeremy@zope.com
Wed, 11 Jun 2003 13:18:17 -0400
Update of /cvs-repository/Zope
In directory cvs.zope.org:/tmp/cvs-serv21250
Added Files:
test.py
Log Message:
Add version of test.py for Zope2.
With current CVS, the test runner reports:
Ran 2135 tests in 569.700s
OK
=== Zope/test.py 1.1 => 1.2 === (710/810 lines abridged)
--- /dev/null Wed Jun 11 13:18:17 2003
+++ Zope/test.py Wed Jun 11 13:18:17 2003
@@ -0,0 +1,807 @@
+#! /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 [-abcdDfgGhLmprtTuv] [modfilter [testfilter]]
+
+Test harness.
+
+-a level
+--all
+ Run the tests at the given level. Any test at a level at or below this is
+ run, any test at a level above this is not run. Level 0 runs all tests.
+ The default is to run tests at level 1. --all is a shortcut for -a 0.
+
+-b
+ Run "python setup.py build_ext -i" 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.)
+
+-c use pychecker
+
+-d
+ Instead of the normal test harness, run a debug version which
+ doesn't catch any exceptions. This is occasionally handy when the
+ unittest code catching the exception doesn't work right.
+ Unfortunately, the debug harness doesn't print the name of the
+ test, so Use With Care.
+
+--dir directory
+ Option to limit where tests are searched for. This is
+ important when you *really* want to limit the code that gets run.
+ For example, if refactoring interfaces, you don't want to see the way
+ you have broken setups for tests in other packages. You *just* want to
+ run the interface tests.
[-=- -=- -=- 710 lines omitted -=- -=- -=-]
+ if build:
+ # 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_ext -i"
+ if VERBOSE:
+ print cmd
+ sts = os.system(cmd)
+ if sts:
+ print "Build failed", hex(sts)
+ sys.exit(1)
+
+ if VERBOSE:
+ kind = functional and "functional" or "unit"
+ if level == 0:
+ print "Running %s tests at all levels" % kind
+ else:
+ print "Running %s tests at level %d" % (kind, level)
+
+ if args:
+ if len(args) > 1:
+ test_filter = args[1]
+ module_filter = args[0]
+ try:
+ 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
+ raise
+
+
+if __name__ == "__main__":
+ process_args()