summaryrefslogtreecommitdiffstats
path: root/Lib/doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-08-26 05:44:27 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-08-26 05:44:27 (GMT)
commite7edcb8e22126f3afed3c9976a11bb5f58dcbba0 (patch)
treee1eb6c097801f80d144c2f992b72fb6dd439571f /Lib/doctest.py
parent4085f030bdc6245c9983e6c2ecc37d8f2fcd9f44 (diff)
downloadcpython-e7edcb8e22126f3afed3c9976a11bb5f58dcbba0.zip
cpython-e7edcb8e22126f3afed3c9976a11bb5f58dcbba0.tar.gz
cpython-e7edcb8e22126f3afed3c9976a11bb5f58dcbba0.tar.bz2
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.
Diffstat (limited to 'Lib/doctest.py')
-rw-r--r--Lib/doctest.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/Lib/doctest.py b/Lib/doctest.py
index 67de4c5..d8bc852 100644
--- a/Lib/doctest.py
+++ b/Lib/doctest.py
@@ -1629,8 +1629,8 @@ class OutputChecker:
# 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)