I currently have a few unit tests which share a common set of tests. Here\'s an example:
import unittest
class BaseTest(unittest.TestCase):
def testCo
As of Python 3.2, you can add a test_loader function to a module to control which tests (if any) are found by the test discovery mechanism.
For example, the following will only load the original poster's SubTest1 and SubTest2 Test Cases, ignoring Base:
def load_tests(loader, standard_tests, pattern):
suite = TestSuite()
suite.addTests([SubTest1, SubTest2])
return suite
It ought to be possible to iterate over standard_tests (a TestSuite containing the tests the default loader found) and copy all but Base to suite instead, but the nested nature of TestSuite.__iter__ makes that a lot more complicated.