Mercurial > hg
changeset 21448:f2dbbcacc763
run-tests: keep track of test start and stop in MercurialTest.run()
This brings run() more compatible with unittest.TestCase.run()
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 14:55:33 -0700 |
parents | f8c5b8a288c5 |
children | aedf18bcde11 |
files | tests/run-tests.py |
diffstat | 1 files changed, 36 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Apr 20 14:52:57 2014 -0700 +++ b/tests/run-tests.py Sun Apr 20 14:55:33 2014 -0700 @@ -1364,42 +1364,46 @@ # Need to stash away the TestResult since we do custom things # with it. def run(self, result): - try: - t.setUp() - except (KeyboardInterrupt, SystemExit): - raise - except Exception: - result.addError(self, sys.exc_info()) - return - - success = False + result.startTest(self) try: - self.runTest() - except KeyboardInterrupt: - raise - except SkipTest, e: - result.addSkip(self, str(e)) - except IgnoreTest, e: - result.addIgnore(self, str(e)) - except WarnTest, e: - result.addWarn(self, str(e)) - except self.failureException: - result.addFailure(self, sys.exc_info()) - except Exception: - result.addError(self, sys.exc_info()) - else: - success = True + try: + t.setUp() + except (KeyboardInterrupt, SystemExit): + raise + except Exception: + result.addError(self, sys.exc_info()) + return - try: - t.tearDown() - except (KeyboardInterrupt, SystemExit): - raise - except Exception: - result.addError(self, sys.exc_info()) success = False + try: + self.runTest() + except KeyboardInterrupt: + raise + except SkipTest, e: + result.addSkip(self, str(e)) + except IgnoreTest, e: + result.addIgnore(self, str(e)) + except WarnTest, e: + result.addWarn(self, str(e)) + except self.failureException: + result.addFailure(self, sys.exc_info()) + except Exception: + result.addError(self, sys.exc_info()) + else: + success = True - if success: - result.addSuccess(self) + try: + t.tearDown() + except (KeyboardInterrupt, SystemExit): + raise + except Exception: + result.addError(self, sys.exc_info()) + success = False + + if success: + result.addSuccess(self) + finally: + result.stopTest(self) def runTest(self): code, tname, msg = t.run()