[Python-checkins] python/dist/src/Lib doctest.py,1.90,1.91

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Thu Aug 26 07:44:29 CEST 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21813/Lib

Modified Files:
	doctest.py 
Log Message:
output_difference():  In fancy-diff cases, the way this split expected &
actual output into lines created spurious empty lines at the ends of
each.  Those matched, but the fancy diffs had surprising line counts (1
larger than expected), and tests kept having to slam <BLANKLINE> into the
expected output to account for this.  Using the splitlines() string method
with keepends=True instead accomplishes what was intended directly.


Index: doctest.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/doctest.py,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- doctest.py	26 Aug 2004 05:21:59 -0000	1.90
+++ doctest.py	26 Aug 2004 05:44:27 -0000	1.91
@@ -1629,8 +1629,8 @@
         # Check if we should use diff.
         if self._do_a_fancy_diff(want, got, optionflags):
             # Split want & got into lines.
-            want_lines = [l+'\n' for l in want.split('\n')]
-            got_lines = [l+'\n' for l in got.split('\n')]
+            want_lines = want.splitlines(True)  # True == keep line ends
+            got_lines = got.splitlines(True)
             # Use difflib to find their differences.
             if optionflags & REPORT_UDIFF:
                 diff = difflib.unified_diff(want_lines, got_lines, n=2)



More information about the Python-checkins mailing list