_pytest.assertion.util module¶
Utilities for assertion debugging
-
format_explanation
(explanation: str) → str[source]¶ This formats an explanation
Normally all embedded newlines are escaped, however there are three exceptions:
{, } and ~. The first two are intended
cover nested explanations, see function and attribute explanations for examples (.visit_Call(), visit_Attribute()). The last one is for when one explanation needs to span multiple lines, e.g. when displaying diffs.
-
_split_explanation
(explanation: str) → List[str][source]¶ Return a list of individual lines in the explanation
This will return a list of lines split on ‘
{‘, ‘ }’ and ‘ ~’.
Any other newlines will be escaped and appear in the line as the literal ‘
‘ characters.
-
_format_lines
(lines: Sequence[str]) → List[str][source]¶ Format the individual lines
This will replace the ‘{‘, ‘}’ and ‘~’ characters of our mini formatting language with the proper ‘where …’, ‘and …’ and ‘ + …’ text, taking care of indentation along the way.
Return a list of formatted lines.
-
assertrepr_compare
(config, op: str, left: Any, right: Any) → Optional[List[str]][source]¶ Return specialised explanations for some operators/operands
-
_diff_text
(left: str, right: str, verbose: int = 0) → List[str][source]¶ Return the explanation for the diff between text.
Unless –verbose is used this will skip leading and trailing characters which are identical to keep the diff minimal.
-
_surrounding_parens_on_own_lines
(lines: List[str]) → None[source]¶ Move opening/closing parenthesis/bracket to own lines.
-
_compare_eq_iterable
(left: Iterable[Any], right: Iterable[Any], verbose: int = 0) → List[str][source]¶
-
_compare_eq_sequence
(left: Sequence[Any], right: Sequence[Any], verbose: int = 0) → List[str][source]¶
-
_compare_eq_set
(left: AbstractSet[Any], right: AbstractSet[Any], verbose: int = 0) → List[str][source]¶
-
_compare_eq_dict
(left: Mapping[Any, Any], right: Mapping[Any, Any], verbose: int = 0) → List[str][source]¶