A better unittest

Thomas Heller theller at python.net
Thu Apr 17 10:01:55 EDT 2003


Duncan Booth <duncan at NOSPAMrcp.co.uk> writes:

> Anyone fancy a patch that gives the output below? (I do hope it doesn't word wrap).
> 
> FFFF
> ======================================================================
> FAIL: test_failUnlessEqual (__main__.Test)
> ----------------------------------------------------------------------
> TestFailed: failUnlessEqual
> 'xxxxxxxxxxxxxxxxxx...xxxxyzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
>                    ...    ^
> 'xxxxxxxxxxxxxxxxxx...xxxxazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz...
>                    ...    ^
>   File "J:\temp\test.py", line 7, in test_failUnlessEqual
>     self.failUnlessEqual(s, t)
> 
[and so on]

This looks great, but has problems. It is slow. For some input, at
least.

I didn't have enough patience to wait for the output of your script,
instead I changed the 10000 character strings to 100 characters and then
it only took some seconds.

Maybe you should create a new method (failUnlessEqual_ShowDiff or so)
which will do the fancy formatting.

Maybe the diff formatting should be put into the TestReport, so that
at least the
    FFFF
line is printed more quickly, and the formatting doen afterwards.

Maybe a time limit should be introduced.

Thomas




More information about the Python-list mailing list