A better unittest

Terry Reedy tjreedy at udel.edu
Wed Apr 16 09:37:08 EDT 2003


"Thomas Heller" <theller at python.net> wrote in message
news:3ckier9a.fsf at python.net...
======================================================================
> FAIL: test_fail (__main__.FailingTests)
> --------------------------------------------------------------------
--
> Traceback (most recent call last):
>   File "C:\tss5\components\_Pythonlib\xunit\xunit.py", line 35, in
test_fail
>     self.fail("fail on purpose")
>   File "C:\Python22\lib\unittest.py", line 254, in fail
>     raise self.failureException, msg
> AssertionError: fail on purpose

<versus>

======================================================================
> FAIL: test_fail (__main__.FailingTests)
> --------------------------------------------------------------------
--
> Traceback (most recent call last):
>   File "C:\tss5\components\_Pythonlib\xunit\xunit.py", line 35, in
test_fail
>     self.fail("fail on purpose")
> AssertionError: fail on purpose

> What do people think? Is this a useful change, and should I submit a
> patch?

I plan to start using inittest Real Soon Now.  For normal use,  the
irrelevant display of inittest internals constitutes noise and I
believe I would prefer its suppression.  And yet, it is a bit
disconcerting: the last displayed line does *not* raise the displayed
exception.  So there is a visual 'mismatch'.  Two suggestions for
further revision.

1. The phrase 'most recent call last' is not longer true.  Substitute
'inittest internals suppressed' or somesuch.

2. Add some visual indicator of the omission, such as an ellipsis line
'...'.

Traceback (inittest internals suppressed):
  File "C:\tss5\components\_Pythonlib\xunit\xunit.py", line 35, in
test_fail
    self.fail("fail on purpose")
...
AssertionError: fail on purpose

Or maybe a prefix to the last line

>>AssertionError: fail on purpose

This patch effectively assumes that inittest works perfectly now and
after all future patches.  While I would make the suppression the
default, I suspect that normal tracebacks might sometimes be a needed
option.

Terry J. Reedy








More information about the Python-list mailing list