(
left: Iterable[Any], right: Iterable[Any], verbose: int = 0
)
| 285 | |
| 286 | |
| 287 | def _compare_eq_iterable( |
| 288 | left: Iterable[Any], right: Iterable[Any], verbose: int = 0 |
| 289 | ) -> List[str]: |
| 290 | if not verbose and not running_on_ci(): |
| 291 | return ["Use -v to get the full diff"] |
| 292 | # dynamic import to speedup pytest |
| 293 | import difflib |
| 294 | |
| 295 | left_formatting = pprint.pformat(left).splitlines() |
| 296 | right_formatting = pprint.pformat(right).splitlines() |
| 297 | |
| 298 | # Re-format for different output lengths. |
| 299 | lines_left = len(left_formatting) |
| 300 | lines_right = len(right_formatting) |
| 301 | if lines_left != lines_right: |
| 302 | left_formatting = _pformat_dispatch(left).splitlines() |
| 303 | right_formatting = _pformat_dispatch(right).splitlines() |
| 304 | |
| 305 | if lines_left > 1 or lines_right > 1: |
| 306 | _surrounding_parens_on_own_lines(left_formatting) |
| 307 | _surrounding_parens_on_own_lines(right_formatting) |
| 308 | |
| 309 | explanation = ["Full diff:"] |
| 310 | # "right" is the expected base against which we compare "left", |
| 311 | # see https://github.com/pytest-dev/pytest/issues/3333 |
| 312 | explanation.extend( |
| 313 | line.rstrip() for line in difflib.ndiff(right_formatting, left_formatting) |
| 314 | ) |
| 315 | return explanation |
| 316 | |
| 317 | |
| 318 | def _compare_eq_sequence( |
no test coverage detected