Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(14298)

Unified Diff: Lib/test/test_doctest.py

Issue 24746: doctest 'fancy diff' formats incorrectly strip trailing whitespace
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/doctest.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/test/test_doctest.py mar ago 11 18:51:00 2015 -0700
+++ b/Lib/test/test_doctest.py dom ago 16 20:56:43 2015 -0300
@@ -1393,6 +1393,32 @@
g
TestResults(failed=1, attempted=1)
+The fancy reports had a bug for a long time where any trailing whitespace on
+the reported diff lines was stripped, making it impossible to see the
+differences in line reported as different that differed only in the amount of
+trailing whitespace. The whitespace still isn't particularly visible unless
+you use NDIFF, but at least it is now there to be found.
+
+ >>> def f(x):
+ ... r'''
+ ... >>> print('\n'.join(['a ', 'b']))
+ ... a
+ ... b
+ ... '''
+
+ >>> test = doctest.DocTestFinder().find(f)[0]
+ >>> flags = doctest.REPORT_NDIFF
+ >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
+ ... # doctest: +ELLIPSIS
+ **********************************************************************
+ File ..., line 3, in f
+ Failed example:
+ print('\n'.join(['a ', 'b']))
+ Differences (ndiff with -expected +actual):
+ - a
+ + a
+ b
+ TestResults(failed=1, attempted=1)
The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm
used by the popular ndiff.py utility. This does intraline difference
@@ -2445,7 +2471,7 @@
Differences (ndiff with -expected +actual):
a
- <BLANKLINE>
- +
+ +
b
<BLANKLINE>
<BLANKLINE>
« no previous file with comments | « Lib/doctest.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+