Remove newlines from left/right operands with '-vv' (#9743)
The left/right operands produced when `verbose > 1` should not contain newlines, because they are used to build the `summary` string. The `assertrepr_compare` function returns a list of lines, and the summary is one of those lines and should not contain newlines itself. Fix #9742 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
This commit is contained in:
@@ -1695,3 +1695,18 @@ def test_assertion_location_with_coverage(pytester: Pytester) -> None:
|
||||
"*= 1 failed in*",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def test_reprcompare_verbose_long() -> None:
|
||||
a = {f"v{i}": i for i in range(11)}
|
||||
b = a.copy()
|
||||
b["v2"] += 10
|
||||
lines = callop("==", a, b, verbose=2)
|
||||
assert lines is not None
|
||||
assert lines[0] == (
|
||||
"{'v0': 0, 'v1': 1, 'v2': 2, 'v3': 3, 'v4': 4, 'v5': 5, "
|
||||
"'v6': 6, 'v7': 7, 'v8': 8, 'v9': 9, 'v10': 10}"
|
||||
" == "
|
||||
"{'v0': 0, 'v1': 1, 'v2': 12, 'v3': 3, 'v4': 4, 'v5': 5, "
|
||||
"'v6': 6, 'v7': 7, 'v8': 8, 'v9': 9, 'v10': 10}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user