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

Function format_explanation

src/_pytest/assertion/util.py:35–47  ·  view source on GitHub ↗

r"""Format an explanation. Normally all embedded newlines are escaped, however there are three exceptions: \n{, \n} and \n~. The first two are intended cover nested explanations, see function and attribute explanations for examples (.visit_Call(), visit_Attribute()). The last one

(explanation: str)

Source from the content-addressed store, hash-verified

33
34
35def format_explanation(explanation: str) -> str:
36 r"""Format an explanation.
37
38 Normally all embedded newlines are escaped, however there are
39 three exceptions: \n{, \n} and \n~. The first two are intended
40 cover nested explanations, see function and attribute explanations
41 for examples (.visit_Call(), visit_Attribute()). The last one is
42 for when one explanation needs to span multiple lines, e.g. when
43 displaying diffs.
44 """
45 lines = _split_explanation(explanation)
46 result = _format_lines(lines)
47 return "\n".join(result)
48
49
50def _split_explanation(explanation: str) -> List[str]:

Callers

nothing calls this directly

Calls 2

_split_explanationFunction · 0.85
_format_linesFunction · 0.85

Tested by

no test coverage detected