Skip to content

Commit ab91a8f

Browse files
committed
Fixed issue shadowing error when missing argument on teardown_method
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]>
1 parent 577cce2 commit ab91a8f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

_pytest/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,10 @@ def _repr_failure_py(self, excinfo, style=None):
392392
if self.config.option.fulltrace:
393393
style="long"
394394
else:
395+
tb = _pytest._code.Traceback([excinfo.traceback[-1]])
395396
self._prunetraceback(excinfo)
397+
if len(excinfo.traceback) == 0:
398+
excinfo.traceback = tb
396399
tbfilter = False # prunetraceback already does it
397400
if style == "auto":
398401
style = "long"

0 commit comments

Comments
 (0)