unittest: how to specify which suites to run with unittest.main()?
Fernando Perez
fperez528 at yahoo.com
Tue Feb 11 18:19:22 EST 2003
More information about the Python-list mailing list
Tue Feb 11 18:19:22 EST 2003
- Previous message (by thread): ANNOUNCE: SCons 0.11 (build tool in Python) is now available
- Next message (by thread): unittest: how to specify which suites to run with unittest.main()?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi all, I have a unittest question for which my current solution looks very ugly. I need to build some test classes based on a subclass of TestCase: # pseudo-code follows: class testBase(TestCase): pass class test1(testBase): pass class test2(testBase): pass Now I want to build a test suite which uses all the test* methdods in test1 and test2, but NOT in testBase. testBase is meant to be used only to provide common functionality to other test classes, not to be used by itself. Further, I want to have a way of using unittest.main() to call this test suite. I tried mysuite = makeSuite(test1) mysuite.addTests(makeSuite(test2)) but that doesn't work. Furthermore, main() seems to want to run _all_ subclasses of TestCase. My solution was to make testBase a mix-in which doesn't inherit from TestCase so that it 'flies under the radar' of main(), but I find that rather kludgy: class testBase(): pass class test1(testBase,TestCase): pass class test2(testBase,TestCase): pass Are there any better solutions? I read the code for unittest.main() and I guess I can just re-implement it myself by putting just what I want in, but I'm sure what I'm trying to accomplish is routine enough that a standard solution must exist. Thanks in advance for any input. Cheers, f.
- Previous message (by thread): ANNOUNCE: SCons 0.11 (build tool in Python) is now available
- Next message (by thread): unittest: how to specify which suites to run with unittest.main()?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list