Repository navigation
Description
What's the problem this feature will solve?
I just had an assert output the following:
> assert expected == out
E AssertionError: assert '/home/h/Git/...ocess, ...)` ' == '/home/h/Git/...cess, ...)`\n'
E Skipping 160 identical leading characters in diff, use -v to show
E - ess, ...)`
E ? ^
E + ess, ...)`
E ? ^
very helpfully pointing out that ... my space is not a good space? In fact I had a space instead of a newline, but this message certainly isn't terribly helpful in showing that. Throwing on more -v's also doesn't make a difference. This is particularly egregious if it's at the end of the string, but you get unhelpful messages in other cases as well.
In the "short test summary info" it is actually shown, but only if it's at the end or is a short string - and I personally only noticed that when looking closer at the output while writing this issue.
EDIT: I also now saw that in the first line with the AssertionError it's also shown. So it is only the supposedly helpful extra printout that doesn't have it.
=================================== short test summary info ===================================
FAILED tests/test_flake8_trio.py::test_anyio_from_config - AssertionError: assert '/home/h/Git/...ocess, ...)` ' == '/home/h/Git/...cess, ...)`\n'
Describe the solution you'd like
Print the repr (or \t/\n) in the AssertionError diff printout - at least if that's among the characters that differ.
This only took me a second to figure out personally in this case, and maybe that's the case in the vast majority of the cases it happens such that it's not worth the effort to implement / overly noisy. But I figured it's worth considering - esp as it's inconsistent with the other printouts.
Additional context
$ pytest --version
pytest 7.2.1
No flags, and pretty sure I have no pytest configuration playing into this.
Activity
HSamiul commentedon Apr 16, 2023
I will try to implement the proposed solution in my own fork and hopefully make a PR for it. Is there any way to officially "claim" this issue?
jakkdl commentedon Apr 17, 2023
Awesome, good luck! ⭐
egwetzel commentedon May 2, 2023
Would you prefer that this ability to show spaces like \t and \n is activated by calling pytest with a new flag or that it is always implemented when running pytest?
jakkdl commentedon May 3, 2023
I think this should be default behaviour