[Patches] [ python-Patches-787789 ] unittest.py: Custom TestRunners and --verbose

SourceForge.net noreply at sourceforge.net
Wed Sep 10 10:20:11 EDT 2003


Patches item #787789, was opened at 2003-08-13 05:31
Message generated for change (Comment added) made by purcell
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=787789&group_id=5470

Category: Library (Lib)
Group: Python 2.3
Status: Open
Resolution: None
>Priority: 3
Submitted By: Matthew F. Barnes (mfbarnes)
Assigned to: Steve Purcell (purcell)
Summary: unittest.py: Custom TestRunners and --verbose

Initial Comment:
The unittest.TestProgram class accepts a "--verbose"

command-line argument.  But the setting only gets

applied if the testRunner argument to

unittest.TestProgram.__init__ is None.  There is no

clean way of creating a custom TestRunner class and

passing it to unittest.TestProgram such that the

correct verbosity is picked up.



This patch slightly alters the interface to

unittest.TestProgram.__init__ by allowing a class to be

passed as the testRunner argument (defaulting to

TextTestRunner instead of None).  Then the runTests

method of unittest.TestProgram checks whether

self.testRunner is a class, and if so creates an

instance of it, passing the correct verbosity setting

to the TestRunner class' __init__ method.



The patch should still allow a custom TestRunner class

_instance_ to be passed to unittest.TestProgram.__init__.

----------------------------------------------------------------------

>Comment By: Steve Purcell (purcell)
Date: 2003-09-10 18:20

Message:
Logged In: YES 
user_id=21477

I can see your point, but this requres every test runner to accept the 
'verbosity' keyword argument. I'm worried that this will break a large 
number of custom test runners. 
 
Another approach might be to change TextTestRunner so that 'verbosity' 
is an instance attribute that is set by TestProgram after the test runner 
instance is created. Then existing custom test runners will not break, 
unless they already have a 'verbosity' attribute, which is unlikely. 
 
I'll bear this patch in mind; I'm looking at a few pending minor changes 
to the module, and this area is one that I'm covering. 

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=787789&group_id=5470



More information about the Patches mailing list