On 11/02/2010 22:03, Ben Finney wrote:
Michael Foord<fuzzy...@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.

Before:

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

After:

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

There is a newline between the testname and the first line of the docstring. If there is no docstring behaviour is completely unchanged. This is how it was in the 2.7 codebase before I made the change and is unchanged. The only difference is that you don't lose this behaviour by overriding TestCase.shortDescription().

(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.

shortDescription itself is now unchanged from Python 2.6.

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
description.

Well, it *is* the TextTestResult that does the reporting. Don't believe me - look at the code. Test results are reported (written to the output stream) by the TextTestResult. Actually my description above was slightly incorrect - it is only TextTestResult that has a getDescription method, so custom TestResult implementations that inherit directly from TestResult will now also have unchanged behavior from 2.6 in this regard.

Michael

--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of 
your employer, to release me from all obligations and waivers arising from any 
and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, 
clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and 
acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your 
employer, its partners, licensors, agents and assigns, in perpetuity, without 
prejudice to my ongoing rights and privileges. You further represent that you 
have the authority to release me from any BOGUS AGREEMENTS on behalf of your 
employer.


_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to