[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/tests/test.py Added
an option to show only the first failure in failing doctest
Jim Fulton
jim at zope.com
Sat Sep 11 12:58:09 EDT 2004
Log message for revision 27497:
Added an option to show only the first failure in failing doctest
tests.
Also, suppress the extra printing of errors unless the verbosty level
is 2 or higher.
Changed:
U Zope3/trunk/src/zope/app/tests/test.py
-=-
Modified: Zope3/trunk/src/zope/app/tests/test.py
===================================================================
--- Zope3/trunk/src/zope/app/tests/test.py 2004-09-11 16:27:14 UTC (rev 27496)
+++ Zope3/trunk/src/zope/app/tests/test.py 2004-09-11 16:58:09 UTC (rev 27497)
@@ -150,6 +150,12 @@
Look for refcount problems.
This requires that Python was built --with-pydebug.
+-1
+--report-only-first-doctest-failure
+
+ Report only the first failure in a doctest. (Examples after the
+ failure are still executed, in case they do any cleanup.)
+
-t
--top-fifty
Time the individual tests and print a list of the top 50, sorted from
@@ -394,6 +400,11 @@
test, self.failures)
def printErrors(self):
+ if VERBOSE < 2:
+ # We'be output errors as they occured. Outputing them a second
+ # time is just annoying.
+ return
+
if self._progress and not (self.dots or self.showAll):
self.stream.writeln()
self.__super_printErrors()
@@ -933,6 +944,7 @@
global RUN_UNIT
global RUN_FUNCTIONAL
global PYCHECKER
+ global REPORT_ONLY_FIRST_DOCTEST_FAILURE
if argv is None:
argv = sys.argv
@@ -962,6 +974,7 @@
TEST_DIRS = []
PROFILE = False
PYCHECKER = False
+ REPORT_ONLY_FIRST_DOCTEST_FAILURE = False
config_filename = 'test.config'
# import the config file
@@ -972,7 +985,7 @@
try:
opts, args = getopt.getopt(argv[1:],
- "a:bBcdDfFg:G:hkl:LmMPprs:tTuUvN:",
+ "a:bBcdDfFg:G:hkl:LmMPprs:tTuUvN:1",
["all", "help", "libdir=", "times=",
"keepbytecode", "dir=", "build",
"build-inplace",
@@ -982,7 +995,8 @@
"loop", "gui", "minimal-gui",
"test=", "module=",
"profile", "progress", "refcount", "trace",
- "top-fifty", "verbose", "repeat="
+ "top-fifty", "verbose", "repeat=",
+ "report-only-first-doctest-failure",
])
# fixme: add the long names
# fixme: add the extra documentation
@@ -1055,6 +1069,8 @@
TIMETESTS = 50
elif k in ("-U", "--gui"):
GUI = 1
+ elif k in ("-1", "--report-only-first-doctest-failure"):
+ REPORT_ONLY_FIRST_DOCTEST_FAILURE = True
elif k in ("-v", "--verbose"):
VERBOSE += 1
elif k == "--times":
@@ -1086,6 +1102,14 @@
Zope3 needs Python 2.3.4 or greater. You are running:""" + sys.version
sys.exit(1)
+ if REPORT_ONLY_FIRST_DOCTEST_FAILURE:
+ import zope.testing.doctest
+ zope.testing.doctest.set_unittest_reportflags(
+ zope.testing.doctest.REPORT_ONLY_FIRST_FAILURE)
+ import doctest
+ if hasattr(doctest, 'REPORT_ONLY_FIRST_FAILURE'):
+ doctest.set_unittest_reportflags(doctest.REPORT_ONLY_FIRST_FAILURE)
+
if GC_THRESHOLD is not None:
if GC_THRESHOLD == 0:
gc.disable()
More information about the Zope3-Checkins
mailing list