mirror of https://github.com/python/cpython
Shortened diff output for unified & context diffs
This commit is contained in:
parent
aacf083388
commit
5662929a42
|
@ -1618,13 +1618,13 @@ class OutputChecker:
|
||||||
got_lines = [l+'\n' for l in got.split('\n')]
|
got_lines = [l+'\n' for l in got.split('\n')]
|
||||||
# Use difflib to find their differences.
|
# Use difflib to find their differences.
|
||||||
if optionflags & UNIFIED_DIFF:
|
if optionflags & UNIFIED_DIFF:
|
||||||
diff = difflib.unified_diff(want_lines, got_lines, n=2,
|
diff = difflib.unified_diff(want_lines, got_lines, n=2)
|
||||||
fromfile='Expected', tofile='Got')
|
diff = list(diff)[2:] # strip the diff header
|
||||||
kind = 'unified diff'
|
kind = 'unified diff with -expected +actual'
|
||||||
elif optionflags & CONTEXT_DIFF:
|
elif optionflags & CONTEXT_DIFF:
|
||||||
diff = difflib.context_diff(want_lines, got_lines, n=2,
|
diff = difflib.context_diff(want_lines, got_lines, n=2)
|
||||||
fromfile='Expected', tofile='Got')
|
diff = list(diff)[2:] # strip the diff header
|
||||||
kind = 'context diff'
|
kind = 'context diff with expected followed by actual'
|
||||||
elif optionflags & NDIFF_DIFF:
|
elif optionflags & NDIFF_DIFF:
|
||||||
engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
|
engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
|
||||||
diff = list(engine.compare(want_lines, got_lines))
|
diff = list(engine.compare(want_lines, got_lines))
|
||||||
|
|
|
@ -971,9 +971,7 @@ and actual outputs to be displayed using a unified diff:
|
||||||
Line 2, in f
|
Line 2, in f
|
||||||
Failed example:
|
Failed example:
|
||||||
print '\n'.join('abcdefg')
|
print '\n'.join('abcdefg')
|
||||||
Differences (unified diff):
|
Differences (unified diff with -expected +actual):
|
||||||
--- Expected
|
|
||||||
+++ Got
|
|
||||||
@@ -1,8 +1,8 @@
|
@@ -1,8 +1,8 @@
|
||||||
a
|
a
|
||||||
-B
|
-B
|
||||||
|
@ -998,9 +996,7 @@ and actual outputs to be displayed using a context diff:
|
||||||
Line 2, in f
|
Line 2, in f
|
||||||
Failed example:
|
Failed example:
|
||||||
print '\n'.join('abcdefg')
|
print '\n'.join('abcdefg')
|
||||||
Differences (context diff):
|
Differences (context diff with expected followed by actual):
|
||||||
*** Expected
|
|
||||||
--- Got
|
|
||||||
***************
|
***************
|
||||||
*** 1,8 ****
|
*** 1,8 ****
|
||||||
a
|
a
|
||||||
|
|
Loading…
Reference in New Issue