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

Method exconly

src/_pytest/_code/code.py:577–591  ·  view source on GitHub ↗

Return the exception as a string. When 'tryshort' resolves to True, and the exception is an AssertionError, only the actual exception part of the exception representation is returned (so 'AssertionError: ' is removed from the beginning).

(self, tryshort: bool = False)

Source from the content-addressed store, hash-verified

575 )
576
577 def exconly(self, tryshort: bool = False) -> str:
578 """Return the exception as a string.
579
580 When 'tryshort' resolves to True, and the exception is an
581 AssertionError, only the actual exception part of the exception
582 representation is returned (so 'AssertionError: ' is removed from
583 the beginning).
584 """
585 lines = format_exception_only(self.type, self.value)
586 text = "".join(lines)
587 text = text.rstrip()
588 if tryshort:
589 if text.startswith(self._striptext):
590 text = text[len(self._striptext) :]
591 return text
592
593 def errisinstance(
594 self, exc: Union[Type[BaseException], Tuple[Type[BaseException], ...]]

Callers 7

_getreprcrashMethod · 0.95
_importtestmoduleMethod · 0.80
get_exconlyMethod · 0.80
mainFunction · 0.80
test_pytest_failFunction · 0.80
test_excinfo_exconlyFunction · 0.80

Calls

no outgoing calls

Tested by 3

test_pytest_failFunction · 0.64
test_excinfo_exconlyFunction · 0.64