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

Function _split_explanation

src/_pytest/assertion/util.py:50–64  ·  view source on GitHub ↗

r"""Return a list of individual lines in the explanation. This will return a list of lines split on '\n{', '\n}' and '\n~'. Any other newlines will be escaped and appear in the line as the literal '\n' characters.

(explanation: str)

Source from the content-addressed store, hash-verified

48
49
50def _split_explanation(explanation: str) -> List[str]:
51 r"""Return a list of individual lines in the explanation.
52
53 This will return a list of lines split on '\n{', '\n}' and '\n~'.
54 Any other newlines will be escaped and appear in the line as the
55 literal '\n' characters.
56 """
57 raw_lines = (explanation or "").split("\n")
58 lines = [raw_lines[0]]
59 for values in raw_lines[1:]:
60 if values and values[0] in ["{", "}", "~", ">"]:
61 lines.append(values)
62 else:
63 lines[-1] += "\\n" + values
64 return lines
65
66
67def _format_lines(lines: Sequence[str]) -> List[str]:

Callers 1

format_explanationFunction · 0.85

Calls 1

appendMethod · 0.80

Tested by

no test coverage detected