From: <pe...@ce...> - 2006-10-19 10:33:55
|
On Thu, 19 Oct 2006, David Cournapeau wrote: > Hi, > > Is there a simple way to execute tests inherited from NumpyTest > conditionally ? I have something like that for now: > > class test_c_implementation(NumpyTestCase): > def _check(self, level, decimal = 12): > try: > from foo import bar > Y = bar() > except ImportError, inst: > print "Error while importing bar, not tested" > print " -> (Import error was %s)" % inst > > And all checking functions of the class call _check. The problem is > that if there are 10 check functions, there are 10 errors reported, > which is a bit stupid, One approach is demonstrated in scipy/Lib/lib/blas/tests/test_fblas.py. In your case: class base_test_c_implementation: def check_bar(self, level, decimal=12): Y = bar() try: from foo import bar class test_c_implementation(base_test_c_implementation,NumpyTestCase): pass except ImportError, inst: print "Error while importing bar, not tested" print " -> (Import error was %s)" % inst Pearu |