[issue35955] unittest assertEqual reports incorrect location of mismatch

Karthikeyan Singaravelan report at bugs.python.org
Sun Feb 10 09:58:27 EST 2019


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

Sorry to comment on a closed issue. I see the following behavior with difflib.ndiff which is used under the hood by unittest. The strings that differ by '-' and 'w' generate different output compared to 'a' and 'w'. I find the output for diff using '-' and 'w' little confusing and is this caused due to '-' which is also used as a marker in difflib?

$ ./python.exe
Python 3.8.0a1+ (heads/master:8a03ff2ff4, Feb  9 2019, 10:42:29)
[Clang 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import difflib
>>> print(''.join(difflib.ndiff(["drwxrwxr-x 2 2000  2000\n"], ["drwxr-xr-x 2 2000  2000\n"])))
- drwxrwxr-x 2 2000  2000
?  ---
+ drwxr-xr-x 2 2000  2000
?        +++

>>> print(''.join(difflib.ndiff(["drwxrwxr-x 2 2000  2000\n"], ["drwxraxr-x 2 2000  2000\n"])))
- drwxrwxr-x 2 2000  2000
?      ^
+ drwxraxr-x 2 2000  2000
?      ^

----------
nosy: +xtreak

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue35955>
_______________________________________


More information about the Python-bugs-list mailing list