Line | |
---|
1 | """Regression testing framework |
---|
2 | This module will search for scripts in the same directory named |
---|
3 | test_*.py. Each such script should be a test suite that tests a |
---|
4 | module through PyUnit. This script will aggregate all |
---|
5 | found test suites into one big test suite and run them all at once. |
---|
6 | """ |
---|
7 | |
---|
8 | # Author: Mark Pilgrim |
---|
9 | # Modified by Ole Nielsen |
---|
10 | |
---|
11 | import unittest |
---|
12 | |
---|
13 | def regressionTest(): |
---|
14 | import sys, os, re, unittest |
---|
15 | path = os.path.split(sys.argv[0])[0] or os.getcwd() |
---|
16 | files = os.listdir(path) |
---|
17 | test = re.compile("^test_[\w]*.py$", re.IGNORECASE) |
---|
18 | files = filter(test.search, files) |
---|
19 | |
---|
20 | try: |
---|
21 | files.remove(__file__) #Remove self from list (Ver 2.3. or later) |
---|
22 | except: |
---|
23 | files.remove('test_all.py') |
---|
24 | |
---|
25 | filenameToModuleName = lambda f: os.path.splitext(f)[0] |
---|
26 | moduleNames = map(filenameToModuleName, files) |
---|
27 | modules = map(__import__, moduleNames) |
---|
28 | load = unittest.defaultTestLoader.loadTestsFromModule |
---|
29 | return unittest.TestSuite(map(load, modules)) |
---|
30 | |
---|
31 | if __name__ == "__main__": |
---|
32 | unittest.main(defaultTest="regressionTest") |
---|
33 | |
---|
Note: See
TracBrowser
for help on using the repository browser.