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

Last change on this file since 342 was 336, checked in by ole, 21 years ago

Added compilation to testing

File size: 1.2 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
12import os
13
14def regressionTest():
15    import sys, os, re, unittest   
16    path = os.path.split(sys.argv[0])[0] or os.getcwd()
17    files = os.listdir(path)
18    test = re.compile('^test_[\w]*.py$', re.IGNORECASE)
19    files = filter(test.search, files)
20
21    try:
22        files.remove(__file__)  #Remove self from list (Ver 2.3. or later)
23    except:
24        files.remove('test_all.py') 
25
26    filenameToModuleName = lambda f: os.path.splitext(f)[0]
27    moduleNames = map(filenameToModuleName, files)
28    modules = map(__import__, moduleNames)
29    load = unittest.defaultTestLoader.loadTestsFromModule
30    return unittest.TestSuite(map(load, modules))
31
32if __name__ == '__main__':
33
34    os.system('python compile.py') #Attempt to compile all extensions
35   
36    unittest.main(defaultTest='regressionTest')
37   
Note: See TracBrowser for help on using the repository browser.