source: inundation/pmesh/TestRunner.py @ 2261

Last change on this file since 2261 was 349, checked in by duncan, 20 years ago

adding pmesh

File size: 1012 bytes
Line 
1"""Regression testing framework
2This module will search for scripts in the same directory named
3XYZHarness.py.  Each such script should be a test suite that tests a
4module through PyUnit.  (As of Python 2.1, PyUnit is included in
5the standard library as "unittest".)  This script will aggregate all
6found test suites into one big test suite and run them all at once.
7"""
8
9# Author: Mark Pilgrim
10
11import unittest
12
13import sys, os, re, unittest
14
15def 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
26if __name__ == "__main__":
27    unittest.main(defaultTest="regressionTest")
28   
Note: See TracBrowser for help on using the repository browser.