Revision 4
(checked in by cbc, 17 years ago)
|
testing
|
Line | |
---|
1 |
import unittest,os,sys |
---|
2 |
|
---|
3 |
def runalltests(subset=''): |
---|
4 |
sys.path.append(os.path.dirname(__file__)) |
---|
5 |
testlist = os.listdir(os.path.dirname(__file__)) |
---|
6 |
tests = [test[:-3] for test in testlist if test.startswith('test'+subset) and test.endswith('.py')] |
---|
7 |
suite = unittest.TestSuite() |
---|
8 |
for test in tests: |
---|
9 |
testmod = __import__(test) |
---|
10 |
if hasattr(testmod, 'test_suite'): |
---|
11 |
suite.addTest(testmod.test_suite()) |
---|
12 |
TestRunner = unittest.TextTestRunner |
---|
13 |
TestRunner().run(suite) |
---|
14 |
|
---|
15 |
if __name__ == '__main__': |
---|
16 |
runalltests() |
---|