New submission from R. David Murray:

I got a doctest failure that when I wrote the output to a file showed two 
exactly identical lines reported as being different.  Turning off the fancy 
diff, I could see trailing whitespace on one of the lines.  It turns out that 
when a fancy diff is requested, doctest explicitly goes through and strips 
trailing whitespace from the diff lines returned by difflib.  This seems to me 
to be obviously incorrect.  There is no clue in the changelog why this was 
done...this goes back to a massive refactoring of doctest that was done for 
python 2.4, and the fancy diff was introduced at that point, complete with this 
strange behavior.

I tried to write a test for this but couldn't get it working in the time I was 
willing to devote to this (I've switched to NDIFF format, which shows the 
whitespace error even when the actual whitespace is stripped).  Perhaps testing 
this via doctest isn't the best idea anyway, since it will be far to easy for 
the trailing whitespace in the test to get accidentally stripped.  I've 
attached my work as a diff for reference if someone wants to work on this.

----------
components: Library (Lib)
files: doctest_fancy_diff_trailing_whitespace.diff
keywords: easy, patch
messages: 247552
nosy: r.david.murray
priority: normal
severity: normal
stage: test needed
status: open
title: doctest 'fancy diff' formats incorrectly strip trailing whitespace
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6
Added file: 
http://bugs.python.org/file40049/doctest_fancy_diff_trailing_whitespace.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24746>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to