1
2
3
4
5
6
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
21 if __debug__:
22 from mvpa.base import debug
23
24 debug.active += ['CHECK_.*']
25
26
27
28
29 suites = collectTestSuites()
30
31
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
49 handler_backup = warning.handlers
50 warning.handlers = []
51
52
53 import warnings
54 warnings.simplefilter('ignore')
55
56
57 np_errsettings = np.geterr()
58 np.seterr(**dict([(x, 'ignore') for x in np_errsettings]))
59
60
61
62 TextTestRunnerPyMVPA(verbosity=verbosity).run(ts)
63
64 if verbosity < 3:
65
66 warning.handlers = handler_backup
67 np.seterr(**np_errsettings)
68
69
70 if __name__ == '__main__':
71 main()
72