diff --git a/tests/run-tests.py b/tests/run-tests.py index 092b16448994353f1e97a8ce6cf93581ff9831e8_dGVzdHMvcnVuLXRlc3RzLnB5..9a3b4f795f62c5ea00393e33c0ebe5c08ea8f978_dGVzdHMvcnVuLXRlc3RzLnB5 100755 --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -377,6 +377,9 @@ if self._threadtmp and not self._options.keep_tmpdir: shutil.rmtree(self._threadtmp, True) + def setUp(self): + """Tasks to perform before run().""" + def run(self): """Run this test instance. @@ -506,6 +509,9 @@ return res + def tearDown(self): + """Tasks to perform after run().""" + def _run(self, testtmp, replacements, env): # This should be implemented in child classes to run tests. return self._skip('unknown test type') @@ -1352,6 +1358,15 @@ # with it. def run(self, result): try: + t.setUp() + except (KeyboardInterrupt, SystemExit): + raise + except Exception: + result.addError(self, sys.exc_info()) + return + + success = False + try: self.runTest() except KeyboardInterrupt: raise @@ -1366,6 +1381,17 @@ except Exception: result.addError(self, sys.exc_info()) else: + success = True + + try: + t.tearDown() + except (KeyboardInterrupt, SystemExit): + raise + except Exception: + result.addError(self, sys.exc_info()) + success = False + + if success: result.addSuccess(self) def runTest(self):