Package mvpa :: Package tests :: Module main
[hide private]
[frames] | no frames]

Source Code for Module mvpa.tests.main

 1  # emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*- 
 2  # vi: set ft=python sts=4 ts=4 sw=4 et: 
 3  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 4  # 
 5  #   See COPYING file distributed along with the PyMVPA package for the 
 6  #   copyright and license terms. 
 7  # 
 8  ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## 
 9  """Unit test console interface for PyMVPA""" 
10   
11  import unittest 
12  import sys 
13  import numpy as np 
14   
15  from mvpa import _random_seed, cfg 
16  from mvpa.base import externals, warning 
17  from mvpa.tests import collectTestSuites 
18   
19   
20 -def main():
21 if __debug__: 22 from mvpa.base import debug 23 # Lets add some targets which provide additional testing 24 debug.active += ['CHECK_.*'] 25 # NOTE: it had to be done here instead of test_clf.py for 26 # instance, since for CHECK_RETRAIN it has to be set before object 27 # gets created, ie while importing clfs.warehouse 28 29 suites = collectTestSuites() 30 31 # and make global test suite 32 ts = unittest.TestSuite(suites.values()) 33 34 35 class TextTestRunnerPyMVPA(unittest.TextTestRunner): 36 """Extend TextTestRunner to print out random seed which was 37 used in the case of failure""" 38 def run(self, test): 39 result = super(TextTestRunnerPyMVPA, self).run(test) 40 if not result.wasSuccessful(): 41 print "MVPA_SEED=%s" % _random_seed 42 sys.exit(1) 43 return result
44 45 verbosity = int(cfg.get('tests', 'verbosity', default=1)) 46 47 if verbosity < 3: 48 # no MVPA warnings during whole testsuite (but restore handlers later on) 49 handler_backup = warning.handlers 50 warning.handlers = [] 51 52 # No python warnings (like ctypes version for slmr) 53 import warnings 54 warnings.simplefilter('ignore') 55 56 # No numpy 57 np_errsettings = np.geterr() 58 np.seterr(**dict([(x, 'ignore') for x in np_errsettings])) 59 60 61 # finally run it 62 TextTestRunnerPyMVPA(verbosity=verbosity).run(ts) 63 64 if verbosity < 3: 65 # restore warning handlers 66 warning.handlers = handler_backup 67 np.seterr(**np_errsettings) 68 69 70 if __name__ == '__main__': 71 main() 72