This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: unittest.py: Custom TestRunners and --verbose
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: purcell Nosy List: georg.brandl, mfbarnes, purcell
Priority: low Keywords: patch

Created on 2003-08-13 03:31 by mfbarnes, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
unittest.py.diff mfbarnes, 2003-08-13 03:38
Messages (3)
msg44442 - (view) Author: Matthew Barnes (mfbarnes) Date: 2003-08-13 03:31
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__.
msg44443 - (view) Author: Steve Purcell (purcell) (Python triager) Date: 2003-09-10 16:20
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. 
msg44444 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2007-03-07 09:21
Thanks for the patch, committed a variant as rev. 54201.
History
Date User Action Args
2022-04-10 16:10:36adminsetgithub: 39053
2003-08-13 03:31:35mfbarnescreate