[Zope3-checkins] SVN: zope.testing/branches/regebro-doctest-patching/src/zope/testing/ The tests pass!
Lennart Regebro
regebro at gmail.com
Tue Apr 20 04:39:28 EDT 2010
Log message for revision 111164:
The tests pass!
Changed:
U zope.testing/branches/regebro-doctest-patching/src/zope/testing/doctest/__init__.py
U zope.testing/branches/regebro-doctest-patching/src/zope/testing/testrunner/testrunner-errors.txt
-=-
Modified: zope.testing/branches/regebro-doctest-patching/src/zope/testing/doctest/__init__.py
===================================================================
--- zope.testing/branches/regebro-doctest-patching/src/zope/testing/doctest/__init__.py 2010-04-20 08:26:48 UTC (rev 111163)
+++ zope.testing/branches/regebro-doctest-patching/src/zope/testing/doctest/__init__.py 2010-04-20 08:39:28 UTC (rev 111164)
@@ -113,5 +113,40 @@
doctest.DocTestCase.__init__ = _patched_init
doctest.DocTestCase.tearDown = _patched_tearDown
+
+# Patch so you can set REPORT_ONLY_FIRST_FAILURE even if you have a DIFF flag
+# on the test.
+import sys
+from StringIO import StringIO
+
+def _patched_runTest(self):
+ test = self._dt_test
+ old = sys.stdout
+ new = StringIO()
+ optionflags = self._dt_optionflags
+
+ if not (optionflags & doctest.REPORTING_FLAGS):
+ # The option flags don't include any reporting flags,
+ # so add the default reporting flags
+ optionflags |= doctest._unittest_reportflags
+
+ # This should work even if you have a diff flag:
+ if doctest._unittest_reportflags & doctest.REPORT_ONLY_FIRST_FAILURE:
+ optionflags |= doctest.REPORT_ONLY_FIRST_FAILURE
+
+ runner = DocTestRunner(optionflags=optionflags,
+ checker=self._dt_checker, verbose=False)
+
+ try:
+ runner.DIVIDER = "-"*70
+ failures, tries = runner.run(
+ test, out=new.write, clear_globs=False)
+ finally:
+ sys.stdout = old
+
+ if failures:
+ raise self.failureException(self.format_failure(new.getvalue()))
+doctest.DocTestCase.runTest = _patched_runTest
+
from doctest import *
Modified: zope.testing/branches/regebro-doctest-patching/src/zope/testing/testrunner/testrunner-errors.txt
===================================================================
--- zope.testing/branches/regebro-doctest-patching/src/zope/testing/testrunner/testrunner-errors.txt 2010-04-20 08:26:48 UTC (rev 111163)
+++ zope.testing/branches/regebro-doctest-patching/src/zope/testing/testrunner/testrunner-errors.txt 2010-04-20 08:39:28 UTC (rev 111164)
@@ -207,15 +207,14 @@
Running zope.testing.testrunner.layer.UnitTests tests:
Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
Running:
- 1/56 (1.8%)
+ 1/47 (2.1%)
<BLANKLINE>
Failure in test eek (sample2.sampletests_e)
Failed doctest test for sample2.sampletests_e.eek
File "testrunner-ex/sample2/sampletests_e.py", line 28, in eek
<BLANKLINE>
----------------------------------------------------------------------
- File "testrunner-ex/sample2/sampletests_e.py", line 30,
- in sample2.sampletests_e.eek
+ File "testrunner-ex/sample2/sampletests_e.py", line 30, in sample2.sampletests_e.eek
Failed example:
f()
Exception raised:
@@ -231,11 +230,11 @@
- __traceback_info__: I don't know what Y should be.
NameError: global name 'y' is not defined
<BLANKLINE>
- 2/56 (3.6%)##r##
- ##r##
- 3/56 (5.4%)##r##
- ##r##
- 4/56 (7.1%)
+ 2/47 (4.3%)\r
+ \r
+ 3/47 (6.4%)\r
+ \r
+ 4/47 (8.5%)
<BLANKLINE>
Error in test test3 (sample2.sampletests_e.Test)
Traceback (most recent call last):
@@ -248,11 +247,11 @@
- __traceback_info__: I don't know what Y should be.
NameError: global name 'y' is not defined
<BLANKLINE>
- 5/56 (8.9%)##r##
- ##r##
- 6/56 (10.7%)##r##
- ##r##
- 7/56 (12.5%)
+ 5/47 (10.6%)\r
+ \r
+ 6/47 (12.8%)\r
+ \r
+ 7/47 (14.9%)
<BLANKLINE>
Failure in test testrunner-ex/sample2/e.txt
Failed doctest test for e.txt
@@ -272,7 +271,7 @@
return x
NameError: global name 'x' is not defined
<BLANKLINE>
- 8/56 (14.3%)
+ 8/47 (17.0%)
<BLANKLINE>
Failure in test test (sample2.sampletests_f.Test)
Traceback (most recent call last):
@@ -282,85 +281,86 @@
raise self.failureException, \
AssertionError: 1 != 0
<BLANKLINE>
- 9/56 (16.1%)##r##
- ##r##
- 10/56 (17.9%)##r##
- ##r##
- 11/56 (19.6%)##r##
- ##r##
- 12/56 (21.4%)##r##
- ##r##
- 13/56 (23.2%)##r##
- ##r##
- 14/56 (25.0%)##r##
- ##r##
- 15/56 (26.8%)##r##
- ##r##
- 16/56 (28.6%)##r##
- ##r##
- 17/56 (30.4%)##r##
- ##r##
- 18/56 (32.1%)##r##
- ##r##
- 19/56 (33.9%)##r##
- ##r##
- 20/56 (35.7%)##r##
- ##r##
- 24/56 (42.9%)##r##
- ##r##
- 25/56 (44.6%)##r##
- ##r##
- 26/56 (46.4%)##r##
- ##r##
- 27/56 (48.2%)##r##
- ##r##
- 28/56 (50.0%)##r##
- ##r##
- 29/56 (51.8%)##r##
- ##r##
- 30/56 (53.6%)##r##
- ##r##
- 31/56 (55.4%)##r##
- ##r##
- 32/56 (57.1%)##r##
- ##r##
- 33/56 (58.9%)##r##
- ##r##
- 34/56 (60.7%)##r##
- ##r##
- 35/56 (62.5%)##r##
- ##r##
- 36/56 (64.3%)##r##
- ##r##
- 40/56 (71.4%)##r##
- ##r##
- 41/56 (73.2%)##r##
- ##r##
- 42/56 (75.0%)##r##
- ##r##
- 43/56 (76.8%)##r##
- ##r##
- 44/56 (78.6%)##r##
- ##r##
- 45/56 (80.4%)##r##
- ##r##
- 46/56 (82.1%)##r##
- ##r##
- 47/56 (83.9%)##r##
- ##r##
- 48/56 (85.7%)##r##
- ##r##
- 49/56 (87.5%)##r##
- ##r##
- 50/56 (89.3%)##r##
- ##r##
- 51/56 (91.1%)##r##
- ##r##
- 52/56 (92.9%)##r##
- ##r##
- 56/56 (100.0%)##r##
- ##r##
- Ran 56 tests with 3 failures and 1 errors in 0.054 seconds.
+ 9/47 (19.1%)\r
+ \r
+ 10/47 (21.3%)\r
+ \r
+ 11/47 (23.4%)\r
+ \r
+ 12/47 (25.5%)\r
+ \r
+ 13/47 (27.7%)\r
+ \r
+ 14/47 (29.8%)\r
+ \r
+ 15/47 (31.9%)\r
+ \r
+ 16/47 (34.0%)\r
+ \r
+ 17/47 (36.2%)\r
+ \r
+ 18/47 (38.3%)\r
+ \r
+ 19/47 (40.4%)\r
+ \r
+ 20/47 (42.6%)\r
+ \r
+ 21/47 (44.7%)\r
+ \r
+ 22/47 (46.8%)\r
+ \r
+ 23/47 (48.9%)\r
+ \r
+ 24/47 (51.1%)\r
+ \r
+ 25/47 (53.2%)\r
+ \r
+ 26/47 (55.3%)\r
+ \r
+ 27/47 (57.4%)\r
+ \r
+ 28/47 (59.6%)\r
+ \r
+ 29/47 (61.7%)\r
+ \r
+ 30/47 (63.8%)\r
+ \r
+ 31/47 (66.0%)\r
+ \r
+ 32/47 (68.1%)\r
+ \r
+ 33/47 (70.2%)\r
+ \r
+ 34/47 (72.3%)\r
+ \r
+ 35/47 (74.5%)\r
+ \r
+ 36/47 (76.6%)\r
+ \r
+ 37/47 (78.7%)\r
+ \r
+ 38/47 (80.9%)\r
+ \r
+ 39/47 (83.0%)\r
+ \r
+ 40/47 (85.1%)\r
+ \r
+ 41/47 (87.2%)\r
+ \r
+ 42/47 (89.4%)\r
+ \r
+ 43/47 (91.5%)\r
+ \r
+ 44/47 (93.6%)\r
+ \r
+ 45/47 (95.7%)\r
+ \r
+ 46/47 (97.9%)\r
+ \r
+ 47/47 (100.0%)\r
+ \r
+ <BLANKLINE>
+ Ran 47 tests with 3 failures and 1 errors in 0.054 seconds.
Tearing down left over layers:
Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
True
More information about the Zope3-Checkins
mailing list