source: inundation/ga/storm_surge/pyvolution/test_all.py @ 333

Last change on this file since 333 was 195, checked in by ole, 20 years ago
File size: 1.1 KB
Line 
1"""Regression testing framework
2This module will search for scripts in the same directory named
3test_*.py.  Each such script should be a test suite that tests a
4module through PyUnit. This script will aggregate all
5found 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
11import unittest
12
13def 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
31if __name__ == "__main__":
32    unittest.main(defaultTest="regressionTest")
33   
Note: See TracBrowser for help on using the repository browser.