(
left: Iterable[object],
right: Iterable[object],
highlighter: _HighlightFunc,
verbose: int = 0,
)
| 11 | |
| 12 | |
| 13 | def _compare_eq_iterable( |
| 14 | left: Iterable[object], |
| 15 | right: Iterable[object], |
| 16 | highlighter: _HighlightFunc, |
| 17 | verbose: int = 0, |
| 18 | ) -> Iterator[str]: |
| 19 | if verbose <= 0 and not running_on_ci(): |
| 20 | yield "Use -v to get more diff" |
| 21 | return |
| 22 | # dynamic import to speedup pytest |
| 23 | import difflib |
| 24 | |
| 25 | left_formatting = PrettyPrinter().pformat(left).splitlines() |
| 26 | right_formatting = PrettyPrinter().pformat(right).splitlines() |
| 27 | |
| 28 | yield "" |
| 29 | yield "Full diff:" |
| 30 | # "right" is the expected base against which we compare "left", |
| 31 | # see https://github.com/pytest-dev/pytest/issues/3333 |
| 32 | yield from highlighter( |
| 33 | "\n".join( |
| 34 | line.rstrip() for line in difflib.ndiff(right_formatting, left_formatting) |
| 35 | ), |
| 36 | lexer="diff", |
| 37 | ).splitlines() |
| 38 | |
| 39 | |
| 40 | def _compare_eq_sequence( |
no test coverage detected
searching dependent graphs…