Skip to content

Commit

Permalink
Run tearDown and flush logged errors even when a test fails.
Browse files Browse the repository at this point in the history
trial's documentation claims tearDown runs even when tests fail:

http://twistedmatrix.com/documents/17.5.0/core/howto/trial.html#factoring-out-common-test-logic

This commit makes that true.

If logged failures aren't flushed from a test that fails, then a
subsequent test will fail.  This commit adds an additional failure to
the failed test.
  • Loading branch information
markrwilliams committed Aug 23, 2017
1 parent 741e356 commit 14ba918
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/twisted/trial/_synctest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1345,25 +1345,23 @@ def _runFixturesAndTest(self, result):

todo = self.getTodo()
method = getattr(self, self._testMethodName)
if self._run(suppress, todo, method, result):
return
failed = self._run(suppress, todo, method, result)
finally:
self._runCleanups(result)

if todo:
if todo and not failed:
result.addUnexpectedSuccess(self, todo)

if self._run(suppress, None, self.tearDown, result):
return
failed = True

passed = True
for error in self._observer.getErrors():
result.addError(self, error)
passed = False
failed = True
self._observer.flushErrors()
self._removeObserver()

if passed and not todo:
if not (failed or todo):
result.addSuccess(self)


Expand Down

0 comments on commit 14ba918

Please sign in to comment.