[Zope3-checkins] SVN: zope.testing/branches/colorized-output/src/zope/testing/testrunner-colors.txt Tests for colorizing all sorts of doctest failures.

Marius Gedminas marius at pov.lt
Sat Jul 14 17:54:23 EDT 2007


Log message for revision 77980:
  Tests for colorizing all sorts of doctest failures.
  
  

Changed:
  U   zope.testing/branches/colorized-output/src/zope/testing/testrunner-colors.txt

-=-
Modified: zope.testing/branches/colorized-output/src/zope/testing/testrunner-colors.txt
===================================================================
--- zope.testing/branches/colorized-output/src/zope/testing/testrunner-colors.txt	2007-07-14 21:53:29 UTC (rev 77979)
+++ zope.testing/branches/colorized-output/src/zope/testing/testrunner-colors.txt	2007-07-14 21:54:23 UTC (rev 77980)
@@ -166,6 +166,61 @@
     {normal}Total: {green}413{normal} tests, {boldred}3{normal} failures, {boldred}1{normal} errors{normal}
     True
 
+The expected and actual outputs of failed doctests are shown in different
+colors:
+
+    >>> sys.argv = 'test --tests-pattern ^pledge$ -c'.split()
+    >>> _ = testrunner.run(defaults)
+    {normal}Running unit tests:{normal}
+    <BLANKLINE>
+    <BLANKLINE>
+    {boldred}Failure in test pledge (pledge){normal}
+    Failed doctest test for pledge.pledge
+      File "testrunner-ex/pledge.py", line 24, in pledge
+    <BLANKLINE>
+    ----------------------------------------------------------------------
+    {normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
+    Failed example:
+    {cyan}    print pledge_template % ('and earthling', 'planet'),{normal}
+    Expected:
+    {green}    I give my pledge, as an earthling,{normal}
+    {green}    to save, and faithfully, to defend from waste,{normal}
+    {green}    the natural resources of my planet.{normal}
+    {green}    It's soils, minerals, forests, waters, and wildlife.{normal}
+    Got:
+    {red}    I give my pledge, as and earthling,{normal}
+    {red}    to save, and faithfully, to defend from waste,{normal}
+    {red}    the natural resources of my planet.{normal}
+    {red}    It's soils, minerals, forests, waters, and wildlife.{normal}
+    <BLANKLINE>
+    {normal}  Ran {green}1{normal} tests with {boldred}1{normal} failures and {green}0{normal} errors in {green}0.002{normal} seconds.{normal}
+
+Diffs are highlighted so you can easily tell the context and the mismatches
+apart:
+
+    >>> sys.argv = 'test --tests-pattern ^pledge$ --ndiff -c'.split()
+    >>> _ = testrunner.run(defaults)
+    {normal}Running unit tests:{normal}
+    <BLANKLINE>
+    <BLANKLINE>
+    {boldred}Failure in test pledge (pledge){normal}
+    Failed doctest test for pledge.pledge
+      File "testrunner-ex/pledge.py", line 24, in pledge
+    <BLANKLINE>
+    ----------------------------------------------------------------------
+    {normal}File testrunner-ex/pledge.py{normal}", line {boldred}26{normal}, in {boldcyan}pledge.pledge{normal}
+    Failed example:
+    {cyan}    print pledge_template % ('and earthling', 'planet'),{normal}
+    Differences (ndiff with -expected +actual):
+    {green}    - I give my pledge, as an earthling,{normal}
+    {red}    + I give my pledge, as and earthling,{normal}
+    {magenta}    ?                        +{normal}
+    {normal}      to save, and faithfully, to defend from waste,{normal}
+    {normal}      the natural resources of my planet.{normal}
+    {normal}      It's soils, minerals, forests, waters, and wildlife.{normal}
+    <BLANKLINE>
+    {normal}  Ran {green}1{normal} tests with {boldred}1{normal} failures and {green}0{normal} errors in {green}0.003{normal} seconds.{normal}
+
 Clean up:
 
     >>> sys.stdout = real_stdout



More information about the Zope3-Checkins mailing list