def run_single_test(test, exit_on_failure=False): suite = unittest.TestSuite() suite.addTest(test) s = unittest.TextTestRunner(verbosity=2).run(suite) if exit_on_failure and not s.wasSuccessful(): sys.exit(1) return s
def run_tests(modulename, classes=[], exit_on_failure=False): rank = getMPIRankWorld() stream = sys.stderr #default verb = 2 if rank > 0: stream = open(os.devnull, 'w') verb = 0 suite = unittest.TestSuite() if len(classes) == 0: __add_tests(suite, modulename) else: for test_class in classes: suite.addTest(unittest.makeSuite(test_class)) s = unittest.TextTestRunner(stream=stream, verbosity=verb).run(suite) if exit_on_failure and not s.wasSuccessful(): sys.stderr.flush() MPIBarrierWorld() sys.exit(1) return s
self.runModel(model, PERIODS, TOL=1.e-1) def test_RhoBDataFailed(self): """ resistivity set on elements, no value on boundary but interpolation is not possible fixed bottom """ PERIODS = np.logspace(2, 3, num=3, endpoint=True, base=10.0, dtype=float) rho = self.airLayerMaskCenter * 9999999 + ( 1 - self.airLayerMaskCenter) * self.RHO0 model = MT2DTMModel(self.domain, fixBottom=False, airLayer=self.DEPTH - self.AIR_LAYER, useFastSolver=self.USEFASTSOLVER) self.assertEqual(0, Lsup(model.airLayer - self.airLayerMask)) self.assertRaises(RuntimeError, model.setResistivity, *(rho, )) if __name__ == '__main__': mySuite = unittest.TestSuite() mySuite.addTest(unittest.makeSuite(TestMT2DTE)) mySuite.addTest(unittest.makeSuite(TestMT2DTMNoAirLayer)) mySuite.addTest(unittest.makeSuite(TestMT2DTMWithAirLayer)) runner = unittest.TextTestRunner(verbosity=2) runner.run(mySuite)