[Python-Dev] unittest: shortDescription, _TextTestResult and other issues

Ben Finney ben+python at benfinney.id.au
Thu Feb 11 23:03:11 CET 2010

Michael Foord <fuzzyman at voidspace.org.uk> writes:

> It is done. The slight disadvantage is that overriding
> shortDescription on your own TestCase no longer removes the test name
> from being added to the short description.

That's a significant disadvantage; it can easily double the length of
the reported description for a test case.


    The Wodget should spangulate with the specified doohickey... ok


    test_zwickyblatt.MechakuchaWidget.test_spangulates_with_specified_doohickey: The Wodget should spangulate with the specified doohickey... ok

(if I have the new description incorrect feel free to correct me, but I
think the point is clear about adding the test name to the description).

Reports that before would mostly stay within a standard 80-column
terminal will now almost always be line-wrapping, making the output much
harder to read.

> On the other hand if you do override shortDescription you don't have
> to add the test name yourself

The problem isn't only with overridden shortDescription. The problem is
the breakage in the existing behaviour of shortDescription, even in
cases that never needed to override shortDescription.

> and using a custom TestResult (overriding getDescription) is much
> easier now that the TextTestRunner takes a resultclass argument in the
> constructor.

Again, it seems that adding this to the output is the job of the thing
which does the reporting, *if* wanted. The (long!) name isn't part of
the TestCase description, so shouldn't be bolted onto the TestResult

 \       Moriarty: “Forty thousand million billion dollars? That money |
  `\            must be worth a fortune!” —The Goon Show, _The Sale of |
_o__)                                                       Manhattan_ |
Ben Finney

More information about the Python-Dev mailing list