Closed
Description
After #3962 the initial "AssertionError" line of error messages with -vv
includes escaped newlines \n
which makes the messages harder to read
Example:
import string
def test_foobar():
a = {string.ascii_letters[i]: i for i in range(26)}
b = a.copy()
a.pop('g')
assert a == b
running pytest -vv
gives:
> assert a == b
E AssertionError: assert {'a': 0,\n 'b': 1,\n 'c': 2,\n 'd': 3,\n 'e': 4,\n 'f': 5,\n 'h': 7,\n 'i': 8,\n 'j': 9,\n 'k': 10,\n 'l': 11,\n 'm': 12,\n 'n': 13,\n 'o': 14,\n 'p': 15,\n 'q': 16,\n 'r': 17,\n 's': 18,\n 't': 19,\n 'u': 20,\n 'v': 21,\n 'w': 22,\n 'x': 23,\n 'y': 24,\n 'z': 25} == {'a': 0,\n 'b': 1,\n 'c': 2,\n 'd': 3,\n 'e': 4,\n 'f': 5,\n 'g': 6,\n 'h': 7,\n 'i': 8,\n 'j': 9,\n 'k': 10,\n 'l': 11,\n 'm': 12,\n 'n': 13,\n 'o': 14,\n 'p': 15,\n 'q': 16,\n 'r': 17,\n 's': 18,\n 't': 19,\n 'u': 20,\n 'v': 21,\n 'w': 22,\n 'x': 23,\n 'y': 24,\n 'z': 25}
E Common items:
...
Clearly the many \n
s in the E AssertionError...
line do not help explain the error.
I will create a fix for this and see if it's accepted:
OS: Macos, Ubuntu, all
pytest: pytest 6.2.5
(and any recent version of pytest)
Activity
improve -vv repr, fix pytest-dev#9742
improve -vv repr, fix pytest-dev#9742
improve -vv repr, fix pytest-dev#9742
Remove newlines from left/right operands with '-vv' (#9743)
chore(deps): update dependency pytest to v7 (#3)