-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Weird output for long string equality assert diffs #7127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
No fix there in the PR but a test anyways in the suite. |
I traced this down to a pytest/src/_pytest/_io/saferepr.py Lines 64 to 72 in b7ad4c2
Python 3.8.2 (default, Mar 7 2020, 20:18:24)
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pprint
>>> s26 = 's\n' * 26
>>> s27 = 's\n' * 27
>>> pprint.pformat(s26)
"'s\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\ns\\n'"
>>> pprint.pformat(s27)
"('s\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n'\n 's\\n')" |
So, one probably bad idea would be to special case strings. Or perhaps I'm looking at the wrong thing as the error and it's not that And of course the situation I really care about is PyCharm's diff link so I'll have to dig into what that actually supports. |
Good:
Bad:
Difference: The strings being compared are one character longer in the bad case.
This came up while asserting equality of GitHub Actions config files (
str
s) in PyCharm and noting that it wasn't showing the handy<Click to see difference>
link (https://youtrack.jetbrains.com/issue/PY-42076). To be clear, the captures below were taken from a shell so as to avoid PyCharm messing things up. The PyCharm issue happens at larger lengths than this does.This issue was referred to in #6757 but that ticket seems focused on other aspects of the output.
altendky@p1:~/repos/ciborg$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 19.10 Release: 19.10 Codename: eoan
altendky@p1:~/repos/ciborg$ venv/bin/pip list Package Version Location --------------------- ----------------------- ------------------------------- appdirs 1.4.3 attrs 19.3.0 ciborg 0.1 /home/altendky/repos/ciborg/src click 7.1.1 coverage 5.1 distlib 0.3.0 filelock 3.0.12 importlib-resources 1.4.0 marshmallow 3.5.1 marshmallow-polyfield 5.9 more-itertools 8.2.0 mypy 0.770 mypy-extensions 0.4.3 packaging 20.3 pep517 0.8.2 pip 20.0.2 pluggy 0.13.1 py 1.8.1 pyparsing 2.4.7 pyrsistent 0.16.0 pytest 5.4.1.dev146+g9bf3efb8e pytest-cov 2.8.1 PyYAML 5.3.1 setuptools 45.2.0 six 1.14.0 toml 0.10.0 tox 3.14.6 typed-ast 1.4.1 typing-extensions 3.7.4.2 virtualenv 20.0.18 wcwidth 0.1.9 wheel 0.34.2
The text was updated successfully, but these errors were encountered: