Skip to content

Commit

Permalink
Fixed issue shadowing error when missing argument on teardown_method
Browse files Browse the repository at this point in the history
When the method argument is missing on teardown_method, the traceback is
100% internal to pytest, which with default options get pruned. Then
that traceback is empty, leading to a new exception as a traceback shall
not be empty.

This PR fixes that issue by pushing back the last stack on the
traceback, when the stacktrace is empty after pruning. Then the output
is still pruned, but gives meaningful information with the item where it
failed on the stack.

* fixes issue #1604

Signed-off-by: Guyzmo <[email protected]>
  • Loading branch information
guyzmo committed Jun 11, 2016
1 parent 577cce2 commit ab91a8f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _pytest/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,10 @@ def _repr_failure_py(self, excinfo, style=None):
if self.config.option.fulltrace:
style="long"
else:
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
self._prunetraceback(excinfo)
if len(excinfo.traceback) == 0:
excinfo.traceback = tb
tbfilter = False # prunetraceback already does it
if style == "auto":
style = "long"
Expand Down

0 comments on commit ab91a8f

Please sign in to comment.