# HG changeset patch # User Gregory Szorc # Date 1398029643 25200 # Node ID 092b16448994353f1e97a8ce6cf93581ff9831e8 # Parent 2b7d364690d87a50716b6c303ab073911ccc0282 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(). diff -r 2b7d364690d8 -r 092b16448994 tests/run-tests.py --- 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):