code: simplify Code construction

This commit is contained in:
Ran Benita
2020-10-27 16:07:03 +02:00
parent 6506f016ac
commit 531416cc5a
7 changed files with 40 additions and 45 deletions

View File

@@ -1647,7 +1647,7 @@ class Function(PyobjMixin, nodes.Item):
def _prunetraceback(self, excinfo: ExceptionInfo[BaseException]) -> None:
if hasattr(self, "_obj") and not self.config.getoption("fulltrace", False):
code = _pytest._code.Code(get_real_func(self.obj))
code = _pytest._code.Code.from_function(get_real_func(self.obj))
path, firstlineno = code.path, code.firstlineno
traceback = excinfo.traceback
ntraceback = traceback.cut(path=path, firstlineno=firstlineno)