MCPcopy
hub / github.com/pytest-dev/pytest / _compare_eq_iterable

Function _compare_eq_iterable

src/_pytest/assertion/_compare_sequence.py:13–37  ·  view source on GitHub ↗
(
    left: Iterable[object],
    right: Iterable[object],
    highlighter: _HighlightFunc,
    verbose: int = 0,
)

Source from the content-addressed store, hash-verified

11
12
13def _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
40def _compare_eq_sequence(

Callers 1

_compare_eq_anyFunction · 0.90

Calls 4

running_on_ciFunction · 0.90
PrettyPrinterClass · 0.90
pformatMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…