New submission from Michael Foord <mich...@voidspace.org.uk>:

Requested by Fernando Perez on the Testing in Python mailing list.

Test creation in TestProgram is done in both parseArgs and createTests.
It would be better if it was only done in createTests so that
controlling test creation only required the overloading of a single method.


> in TestProgram.parseArgs we have:
> 
>             if len(args) == 0 and self.defaultTest is None:
>                 self.test =
self.testLoader.loadTestsFromModule(self.module)
>                 return
> 
> and then later:
> 
>     def createTests(self):
>         self.test = self.testLoader.loadTestsFromNames(self.testNames,
>                                                        self.module)
> 
> So basically if you want to control how tests are created, you can't
just override createTests, because parseArgs also does test creation
> (but only sometimes, depending on certain conditions).

> I think that parseArgs should perhaps only parse args, and createTests
should only create tests, but I'm weird like that :)  For the case
> above, it could set a flag that createTests can then later use to
decide what to do, but parseArgs shouldn't be doing test creation IMO.

----------
assignee: michael.foord
components: Library (Lib)
messages: 92929
nosy: michael.foord
severity: normal
stage: needs patch
status: open
title: Test creation in unittest.TestProgram should be done in one place
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue6956>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to