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

Last change on this file since 438 was 434, checked in by ole, 20 years ago

Added exclude list

File size: 1.5 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
14
15#List files that should be excluded from the testing process.
16#E.g. if they are known to fail and under development
17exclude = ['test_least_squares.py', 'test_cg_solve.py',
18           'test_interpolate_sww.py']
19
20
21def regressionTest():
22    import sys, os, re, unittest   
23    path = os.path.split(sys.argv[0])[0] or os.getcwd()
24    files = os.listdir(path)
25    test = re.compile('^test_[\w]*.py$', re.IGNORECASE)
26    files = filter(test.search, files)
27
28    try:
29        files.remove(__file__)  #Remove self from list (Ver 2.3. or later)
30    except:
31        files.remove('test_all.py') 
32
33
34    for file in exclude:
35        files.remove(file)
36        print 'WARNING: File '+ file + ' excluded from testing'
37       
38
39    filenameToModuleName = lambda f: os.path.splitext(f)[0]
40    moduleNames = map(filenameToModuleName, files)
41    modules = map(__import__, moduleNames)
42    load = unittest.defaultTestLoader.loadTestsFromModule
43    return unittest.TestSuite(map(load, modules))
44
45if __name__ == '__main__':
46
47    os.system('python compile.py') #Attempt to compile all extensions
48   
49    unittest.main(defaultTest='regressionTest')
50   
Note: See TracBrowser for help on using the repository browser.