unittest: how to specify which suites to run with unittest.main()?
Fernando Perez
fperez528 at yahoo.com
Wed Feb 12 12:32:12 EST 2003
Chad Netzer wrote:
>> > 1. Don't name any method of testBase test*--or am I missing something?
>>
>> Well, that doesn't work because I want to run those methods, but only
>> from
>> the test1/test2 instances. These guys override the setUp() method to
>> configure the tests with different parameters, but otherwise need to run
>> exactly the same tests. So having them inherit all the test* methods
>> from testBase actually makes perfect sense: they inherit all the tests,
>> configure the setUp() call differently, and go on happily. So that
>> solution doesn't work.
>
> I think the mix-in approach you gave is perfectly fine. That is exactly
> what multiple inheritence is for. test1 and test2 ARE both a testBase
> and a TestCase, and a TestCase is by definition what you want unittest
> to run.
Thanks for your input, but I think I'll go with the solution proposed by
Peter Hansen. It allows me to build my classes with a cleaner structure
(no unnecessary mixins which add typing and clutter), and to tell
unittest.main() exactly what I want it to run.
Best regards,
Fernando.
More information about the Python-list
mailing list