[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner add support for --hide-secondary-failures and --show-secondary-failures

Fred L. Drake, Jr. fdrake at gmail.com
Fri May 18 14:51:03 EDT 2007


Log message for revision 75845:
  add support for --hide-secondary-failures and --show-secondary-failures
  https://bugs.launchpad.net/zope3/+bug/115454
  

Changed:
  U   zope.testing/trunk/src/zope/testing/testrunner-errors.txt
  U   zope.testing/trunk/src/zope/testing/testrunner.py

-=-
Modified: zope.testing/trunk/src/zope/testing/testrunner-errors.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-05-18 18:02:21 UTC (rev 75844)
+++ zope.testing/trunk/src/zope/testing/testrunner-errors.txt	2007-05-18 18:51:02 UTC (rev 75845)
@@ -590,6 +590,94 @@
       Ran 1 tests with 1 failures and 0 errors in 0.001 seconds.
     True
 
+The --hide-secondary-failures option is an alias for -1:
+
+    >>> sys.argv = (
+    ...     'test --tests-pattern ^sampletests_1$'
+    ...     ' --hide-secondary-failures'
+    ...     ).split()
+    >>> testrunner.run(defaults) # doctest:
+    Running unit tests:
+    <BLANKLINE>
+    <BLANKLINE>
+    Failure in test eek (sample2.sampletests_1)
+    Failed doctest test for sample2.sampletests_1.eek
+      File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
+    <BLANKLINE>
+    ----------------------------------------------------------------------
+    File "testrunner-ex/sample2/sampletests_1.py", line 19,
+         in sample2.sampletests_1.eek
+    Failed example:
+        x = y
+    Exception raised:
+        Traceback (most recent call last):
+          File ".../doctest.py", line 1256, in __run
+            compileflags, 1) in test.globs
+          File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
+            x = y
+        NameError: name 'y' is not defined
+    <BLANKLINE>
+      Ran 1 tests with 1 failures and 0 errors in 0.001 seconds.
+    True
+
+The --show-secondary-failures option counters -1 (or it's alias),
+causing the second and subsequent errors to be shown.  This is useful
+if -1 is provided by a test script by inserting it ahead of
+command-line options in sys.argv.
+
+    >>> sys.argv = (
+    ...     'test --tests-pattern ^sampletests_1$'
+    ...     ' --hide-secondary-failures --show-secondary-failures'
+    ...     ).split()
+    >>> testrunner.run(defaults) # doctest: +NORMALIZE_WHITESPACE
+    Running unit tests:
+    <BLANKLINE>
+    <BLANKLINE>
+    Failure in test eek (sample2.sampletests_1)
+    Failed doctest test for sample2.sampletests_1.eek
+      File "testrunner-ex/sample2/sampletests_1.py", line 17, in eek
+    <BLANKLINE>
+    ----------------------------------------------------------------------
+    File "testrunner-ex/sample2/sampletests_1.py", line 19,
+         in sample2.sampletests_1.eek
+    Failed example:
+        x = y
+    Exception raised:
+        Traceback (most recent call last):
+          File ".../doctest.py", line 1256, in __run
+            compileflags, 1) in test.globs
+          File "<doctest sample2.sampletests_1.eek[0]>", line 1, in ?
+            x = y
+        NameError: name 'y' is not defined
+    ----------------------------------------------------------------------
+    File "testrunner-ex/sample2/sampletests_1.py", line 21,
+         in sample2.sampletests_1.eek
+    Failed example:
+        x
+    Exception raised:
+        Traceback (most recent call last):
+          File ".../doctest.py", line 1256, in __run
+            compileflags, 1) in test.globs
+          File "<doctest sample2.sampletests_1.eek[1]>", line 1, in ?
+            x
+        NameError: name 'x' is not defined
+    ----------------------------------------------------------------------
+    File "testrunner-ex/sample2/sampletests_1.py", line 24,
+         in sample2.sampletests_1.eek
+    Failed example:
+        z = x + 1
+    Exception raised:
+        Traceback (most recent call last):
+          File ".../doctest.py", line 1256, in __run
+            compileflags, 1) in test.globs
+          File "<doctest sample2.sampletests_1.eek[2]>", line 1, in ?
+            z = x + 1
+        NameError: name 'x' is not defined
+    <BLANKLINE>
+      Ran 1 tests with 1 failures and 0 errors in 0.002 seconds.
+    True
+
+
 Getting diff output for doctest failures
 ----------------------------------------
 

Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py	2007-05-18 18:02:21 UTC (rev 75844)
+++ zope.testing/trunk/src/zope/testing/testrunner.py	2007-05-18 18:51:02 UTC (rev 75845)
@@ -1529,13 +1529,22 @@
 """)
 
 reporting.add_option(
-    '-1', action="store_true", dest='report_only_first_failure',
+    '-1', '--hide-secondary-failures',
+    action="store_true", dest='report_only_first_failure',
     help="""\
 Report only the first failure in a doctest. (Examples after the
 failure are still executed, in case they do any cleanup.)
 """)
 
 reporting.add_option(
+    '--show-secondary-failures',
+    action="store_false", dest='report_only_first_failure',
+    help="""\
+Report all failures in a doctest.  This is the default, but can
+be used to counter a default use of -1 or --hide-secondary-failures.
+""")
+
+reporting.add_option(
     '--ndiff', action="store_true", dest="ndiff",
     help="""\
 When there is a doctest failure, show it as a diff using the ndiff.py utility.



More information about the Zope3-Checkins mailing list