Mercurial > hg
changeset 21445:092b16448994
run-tests: fail tests by raising an exception
When in unittest mode, Test.run() will now raise for all non-success
cases. This makes it behave like TestCase.run().
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 14:34:03 -0700 |
parents | 2b7d364690d8 |
children | 9a3b4f795f62 |
files | tests/run-tests.py |
diffstat | 1 files changed, 7 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Sun Apr 20 14:32:03 2014 -0700 +++ b/tests/run-tests.py Sun Apr 20 14:34:03 2014 -0700 @@ -607,6 +607,10 @@ if self._unittest: if warned: raise WarnTest(msg) + else: + # unittest differentiates between errored and failed. + # Failed is denoted by AssertionError (by default at least). + raise AssertionError(msg) return warned and '~' or '!', self.name, msg @@ -1347,8 +1351,6 @@ # Need to stash away the TestResult since we do custom things # with it. def run(self, result): - self._result = result - try: self.runTest() except KeyboardInterrupt: @@ -1369,13 +1371,9 @@ def runTest(self): code, tname, msg = t.run() - if code == '!': - self._result.failures.append((self, msg)) - # Codes handled in run(). - elif code in ('.', 's', 'i', '~'): - pass - else: - self.fail('Unknown test result code: %s' % code) + # All non-success conditions should be exceptions and should + # be caught in run(). + assert code == '.' # We need this proxy until tearDown() is implemented. def cleanup(self):