mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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.
This commit is contained in:
parent
4085f030bd
commit
e7edcb8e22
2 changed files with 5 additions and 9 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue