[issue35955] difflib reports incorrect location of mismatch

Karthikeyan Singaravelan report at bugs.python.org
Mon Feb 11 14:04:34 EST 2019


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

Thanks for the explanation. This seems to give the desired diff with charjunk=None passed to multiline string comparison helper. I am not sure how useful it would be to pass it to sequence and dict comparison that also use ndiff. I can open a PR if it's okay with the set of strings in the report as a test case. There are no test case failures in existing unittest folder test suite so this seems like a safe change to me.


# With patch charjunk=None

./python.exe ../backups/bpo35955_1.py
F
======================================================================
FAIL: test_foo (__main__.FooTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../backups/bpo35955_1.py", line 6, in test_foo
    self.assertEqual("drwxrwxr-x 2 2000  2000\n", "drwxr-xr-x 2 2000  2000\n")
AssertionError: 'drwxrwxr-x 2 2000  2000\n' != 'drwxr-xr-x 2 2000  2000\n'
- drwxrwxr-x 2 2000  2000
?      ^
+ drwxr-xr-x 2 2000  2000
?      ^


----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (failures=1)

# Without patch

➜  cpython git:(master) ✗ python3.7 ../backups/bpo35955_1.py
F
======================================================================
FAIL: test_foo (__main__.FooTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "../backups/bpo35955_1.py", line 6, in test_foo
    self.assertEqual("drwxrwxr-x 2 2000  2000\n", "drwxr-xr-x 2 2000  2000\n")
AssertionError: 'drwxrwxr-x 2 2000  2000\n' != 'drwxr-xr-x 2 2000  2000\n'
- drwxrwxr-x 2 2000  2000
?  ---
+ drwxr-xr-x 2 2000  2000
?        +++


----------------------------------------------------------------------
Ran 1 test in 0.002s

FAILED (failures=1)

----------

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


More information about the Python-bugs-list mailing list