Title: Test creation in unittest.TestProgram should be done in one place
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.2, Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: michael.foord Nosy List: michael.foord
Priority: normal Keywords:

Created on 2009-09-21 10:54 by michael.foord, last changed 2009-09-27 19:16 by michael.foord. This issue is now closed.

Messages (2)
msg92929 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-09-21 10:54
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 =
>                 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.
msg93181 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2009-09-27 19:16
Committed in revision 75095.
Date User Action Args
2009-09-27 19:16:03michael.foordsetstatus: open -> closed
resolution: fixed
messages: + msg93181
2009-09-21 10:54:20michael.foordcreate