Rev | Line | |
---|
[349] | 1 | """Regression testing framework |
---|
| 2 | This module will search for scripts in the same directory named |
---|
| 3 | XYZHarness.py. Each such script should be a test suite that tests a |
---|
| 4 | module through PyUnit. (As of Python 2.1, PyUnit is included in |
---|
| 5 | the standard library as "unittest".) This script will aggregate all |
---|
| 6 | found test suites into one big test suite and run them all at once. |
---|
| 7 | """ |
---|
| 8 | |
---|
| 9 | # Author: Mark Pilgrim |
---|
| 10 | |
---|
| 11 | import unittest |
---|
| 12 | |
---|
| 13 | import sys, os, re, unittest |
---|
| 14 | |
---|
| 15 | def regressionTest(): |
---|
| 16 | path = os.path.split(sys.argv[0])[0] or os.getcwd() |
---|
| 17 | files = os.listdir(path) |
---|
| 18 | test = re.compile("Harness.py$", re.IGNORECASE) |
---|
| 19 | files = filter(test.search, files) |
---|
| 20 | filenameToModuleName = lambda f: os.path.splitext(f)[0] |
---|
| 21 | moduleNames = map(filenameToModuleName, files) |
---|
| 22 | modules = map(__import__, moduleNames) |
---|
| 23 | load = unittest.defaultTestLoader.loadTestsFromModule |
---|
| 24 | return unittest.TestSuite(map(load, modules)) |
---|
| 25 | |
---|
| 26 | if __name__ == "__main__": |
---|
| 27 | unittest.main(defaultTest="regressionTest") |
---|
| 28 | |
---|
Note: See
TracBrowser
for help on using the repository browser.