MCPcopy Create free account
hub / github.com/pytest-dev/pytest / _prunetraceback

Method _prunetraceback

src/_pytest/python.py:1723–1742  ·  view source on GitHub ↗
(self, excinfo: ExceptionInfo[BaseException])

Source from the content-addressed store, hash-verified

1721 self._request._fillfixtures()
1722
1723 def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
1724 if hasattr(self, "_obj") and not self.config.getoption("fulltrace", False):
1725 code = _pytest._code.Code.from_function(get_real_func(self.obj))
1726 path, firstlineno = code.path, code.firstlineno
1727 traceback = excinfo.traceback
1728 ntraceback = traceback.cut(path=path, firstlineno=firstlineno)
1729 if ntraceback == traceback:
1730 ntraceback = ntraceback.cut(path=path)
1731 if ntraceback == traceback:
1732 ntraceback = ntraceback.filter(filter_traceback)
1733 if not ntraceback:
1734 ntraceback = traceback
1735
1736 excinfo.traceback = ntraceback.filter()
1737 # issue364: mark all but first and last frames to
1738 # only show a single-line message for each frame.
1739 if self.config.getoption("tbstyle", "auto") == "auto":
1740 if len(excinfo.traceback) > 2:
1741 for entry in excinfo.traceback[1:-1]:
1742 entry.set_repr_style("short")
1743
1744 # TODO: Type ignored -- breaks Liskov Substitution.
1745 def repr_failure( # type: ignore[override]

Callers

nothing calls this directly

Calls 6

get_real_funcFunction · 0.90
from_functionMethod · 0.80
cutMethod · 0.80
set_repr_styleMethod · 0.80
getoptionMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected