[Tutor] composing one test suite from two test cases

Tom Roche Tom_Roche at pobox.com
Mon Jan 11 04:44:31 CET 2010


How to create a single unittest test suite class that runs all methods
from multiple TestCase classes? Why I ask:

I'm trying to relearn TDD and learn Python by coding a simple app.
Currently the app has 2 simple functional classes, Pid and TallyPid,
and 2 very simple testcases, PidTests and TallyPidTests:

http://www.unc.edu/~tr/courses/ENVR400/Pid.py
http://www.unc.edu/~tr/courses/ENVR400/PidTests.py
http://www.unc.edu/~tr/courses/ENVR400/Tally.py
http://www.unc.edu/~tr/courses/ENVR400/TallyPidTests.py

I can run both testcases

> >python PidTests.py
> ....................
> ----------------------------------------------------------------------
> Ran 20 tests in 0.000s
> OK

> >python TallyPidTests.py
> .
> ----------------------------------------------------------------------
> Ran 1 test in 0.563s
> OK

Before I continue, I'd like to create a single suite, in a separate
cfile file/module (e.g. AllTests.py), that will run both testcases
(PidTests.py and TallyPidTests.py). Unfortunately I have not been able
to do this! which surprises me, since creating such a suite in JUnit
is trivial.  Can someone show me how to create this suite in python?
(FWIW the python version=2.5.2: downlevel, I know, but the box also
needs to run ArcGIS.)

TIA, Tom Roche <Tom_Roche at pobox.com>


More information about the Tutor mailing list