(
self,
excinfo: ExceptionInfo[BaseException],
style: TracebackStyle | None = None,
)
| 398 | return excinfo.traceback |
| 399 | |
| 400 | def _repr_failure_py( |
| 401 | self, |
| 402 | excinfo: ExceptionInfo[BaseException], |
| 403 | style: TracebackStyle | None = None, |
| 404 | ) -> TerminalRepr: |
| 405 | from _pytest.fixtures import FixtureLookupError |
| 406 | |
| 407 | if isinstance(excinfo.value, ConftestImportFailure): |
| 408 | excinfo = ExceptionInfo.from_exception(excinfo.value.cause) |
| 409 | if isinstance(excinfo.value, fail.Exception): |
| 410 | if not excinfo.value.pytrace: |
| 411 | style = "value" |
| 412 | if isinstance(excinfo.value, FixtureLookupError): |
| 413 | return excinfo.value.formatrepr() |
| 414 | |
| 415 | tbfilter: bool | Callable[[ExceptionInfo[BaseException]], Traceback] |
| 416 | if self.config.getoption("fulltrace", False): |
| 417 | style = "long" |
| 418 | tbfilter = False |
| 419 | else: |
| 420 | tbfilter = self._traceback_filter |
| 421 | if style == "auto": |
| 422 | style = "long" |
| 423 | # XXX should excinfo.getrepr record all data and toterminal() process it? |
| 424 | if style is None: |
| 425 | if self.config.getoption("tbstyle", "auto") == "short": |
| 426 | style = "short" |
| 427 | else: |
| 428 | style = "long" |
| 429 | |
| 430 | if self.config.get_verbosity() > 1: |
| 431 | truncate_locals = False |
| 432 | else: |
| 433 | truncate_locals = True |
| 434 | |
| 435 | truncate_args = False if self.config.get_verbosity() > 2 else True |
| 436 | |
| 437 | # excinfo.getrepr() formats paths relative to the CWD if `abspath` is False. |
| 438 | # It is possible for a fixture/test to change the CWD while this code runs, which |
| 439 | # would then result in the user seeing confusing paths in the failure message. |
| 440 | # To fix this, if the CWD changed, always display the full absolute path. |
| 441 | # It will be better to just always display paths relative to invocation_dir, but |
| 442 | # this requires a lot of plumbing (#6428). |
| 443 | try: |
| 444 | abspath = Path(os.getcwd()) != self.config.invocation_params.dir |
| 445 | except OSError: |
| 446 | abspath = True |
| 447 | |
| 448 | return excinfo.getrepr( |
| 449 | funcargs=True, |
| 450 | abspath=abspath, |
| 451 | showlocals=self.config.getoption("showlocals", False), |
| 452 | style=style, |
| 453 | tbfilter=tbfilter, |
| 454 | truncate_locals=truncate_locals, |
| 455 | truncate_args=truncate_args, |
| 456 | ) |
| 457 |
no test coverage detected