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

Side by Side Diff: Lib/test/test_doctest.py

Issue 24746: doctest 'fancy diff' formats incorrectly strip trailing whitespace
Patch Set: Created 4 years, 7 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « Lib/doctest.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """ 1 """
2 Test script for doctest. 2 Test script for doctest.
3 """ 3 """
4 4
5 from test import support 5 from test import support
6 import doctest 6 import doctest
7 import os 7 import os
8 import sys 8 import sys
9 9
10 10
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 --- 1,7 ---- 1385 --- 1,7 ----
1386 a 1386 a
1387 ! b 1387 ! b
1388 c 1388 c
1389 d 1389 d
1390 + e 1390 + e
1391 f 1391 f
1392 g 1392 g
1393 TestResults(failed=1, attempted=1) 1393 TestResults(failed=1, attempted=1)
1394 1394
1395 The fancy reports had a bug for a long time where any trailing whitespace on
1396 the reported diff lines was stripped, making it impossible to see the
1397 differences in line reported as different that differed only in the amount of
1398 trailing whitespace. The whitespace still isn't particularly visible unless
1399 you use NDIFF, but at least it is now there to be found.
1400
1401 >>> def f(x):
1402 ... r'''
1403 ... >>> print('\n'.join(['a ', 'b']))
1404 ... a
1405 ... b
1406 ... '''
1407
1408 >>> test = doctest.DocTestFinder().find(f)[0]
1409 >>> flags = doctest.REPORT_UDIFF
1410 >>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
1411 ... # doctest: +ELLIPSIS
1412 **********************************************************************
1413 File ..., line 3, in f
1414 Failed example:
1415 print('\n'.join(['a ', 'b']))
1416 Differences (context diff with expected followed by actual):
1417 @@ -1,7 +1,7 @@
1418 -a
1419 +a
1420 b
1421 TestResults(failed=1, attempted=1)
1422
1423 NOTE: there is significant trailing whitespace on the +a line above;
1424 *DO NOT STRIP IT* when editing this file.
1395 1425
1396 The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm 1426 The REPORT_NDIFF flag causes failures to use the difflib.Differ algorithm
1397 used by the popular ndiff.py utility. This does intraline difference 1427 used by the popular ndiff.py utility. This does intraline difference
1398 marking, as well as interline differences. 1428 marking, as well as interline differences.
1399 1429
1400 >>> def f(x): 1430 >>> def f(x):
1401 ... r''' 1431 ... r'''
1402 ... >>> print("a b c d e f g h i j k l m") 1432 ... >>> print("a b c d e f g h i j k l m")
1403 ... a b c d e f g h i j k 1 m 1433 ... a b c d e f g h i j k 1 m
1404 ... ''' 1434 ... '''
(...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after
2942 r = tracer.results() 2972 r = tracer.results()
2943 print('Writing coverage results...') 2973 print('Writing coverage results...')
2944 r.write_results(show_missing=True, summary=True, 2974 r.write_results(show_missing=True, summary=True,
2945 coverdir=coverdir) 2975 coverdir=coverdir)
2946 2976
2947 if __name__ == '__main__': 2977 if __name__ == '__main__':
2948 if '-c' in sys.argv: 2978 if '-c' in sys.argv:
2949 test_coverage('/tmp/doctest.cover') 2979 test_coverage('/tmp/doctest.cover')
2950 else: 2980 else:
2951 test_main() 2981 test_main()
OLDNEW
« 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+