A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-February/097622.html below:

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

[Python-Dev] unittest: shortDescription, _TextTestResult and other issuesMichael Foord fuzzyman at voidspace.org.uk
Fri Feb 12 01:43:29 CET 2010
On 11/02/2010 22:03, Ben Finney wrote:
> 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.
>
> 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.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4