# HG changeset patch # User jtrad@insus-PC8 # Date 1439769403 10800 # Node ID 3cd5dedc8a32e07c6fd6e8d438505ced84b02104 # Parent 13ceedb9292343bf33f88069184cc7b50b9827e3 doctest fancy diff white space remove bug diff -r 13ceedb92923 -r 3cd5dedc8a32 Lib/doctest.py --- a/Lib/doctest.py mar ago 11 18:51:00 2015 -0700 +++ b/Lib/doctest.py dom ago 16 20:56:43 2015 -0300 @@ -1681,8 +1681,6 @@ kind = 'ndiff with -expected +actual' else: assert 0, 'Bad diff option' - # Remove trailing whitespace on diff output. - diff = [line.rstrip() + '\n' for line in diff] return 'Differences (%s):\n' % kind + _indent(''.join(diff)) # If we're not using diff, then simply list the expected diff -r 13ceedb92923 -r 3cd5dedc8a32 Lib/test/test_doctest.py --- 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 - - + + + b