]> granicus.if.org Git - python/commitdiff
Shortened diff output for unified & context diffs
authorEdward Loper <edloper@gradient.cis.upenn.edu>
Thu, 26 Aug 2004 01:31:56 +0000 (01:31 +0000)
committerEdward Loper <edloper@gradient.cis.upenn.edu>
Thu, 26 Aug 2004 01:31:56 +0000 (01:31 +0000)
Lib/doctest.py
Lib/test/test_doctest.py

index dfa18480a7beae57ed45a9a6b444d17acd03cda0..9a88b7a880bde622d0853e93e2ff2761c4d27b3d 100644 (file)
@@ -1618,13 +1618,13 @@ class OutputChecker:
             got_lines = [l+'\n' for l in got.split('\n')]
             # Use difflib to find their differences.
             if optionflags & UNIFIED_DIFF:
-                diff = difflib.unified_diff(want_lines, got_lines, n=2,
-                                            fromfile='Expected', tofile='Got')
-                kind = 'unified diff'
+                diff = difflib.unified_diff(want_lines, got_lines, n=2)
+                diff = list(diff)[2:] # strip the diff header
+                kind = 'unified diff with -expected +actual'
             elif optionflags & CONTEXT_DIFF:
-                diff = difflib.context_diff(want_lines, got_lines, n=2,
-                                            fromfile='Expected', tofile='Got')
-                kind = 'context diff'
+                diff = difflib.context_diff(want_lines, got_lines, n=2)
+                diff = list(diff)[2:] # strip the diff header
+                kind = 'context diff with expected followed by actual'
             elif optionflags & NDIFF_DIFF:
                 engine = difflib.Differ(charjunk=difflib.IS_CHARACTER_JUNK)
                 diff = list(engine.compare(want_lines, got_lines))
index 7884c045dd23dc371279dff2c97a0d1f39b13864..29c3ec2fe37970e3a26e5b82912c50b0f644922d 100644 (file)
@@ -971,9 +971,7 @@ and actual outputs to be displayed using a unified diff:
     Line 2, in f
     Failed example:
         print '\n'.join('abcdefg')
-    Differences (unified diff):
-        --- Expected
-        +++ Got
+    Differences (unified diff with -expected +actual):
         @@ -1,8 +1,8 @@
          a
         -B
@@ -998,9 +996,7 @@ and actual outputs to be displayed using a context diff:
     Line 2, in f
     Failed example:
         print '\n'.join('abcdefg')
-    Differences (context diff):
-        *** Expected
-        --- Got
+    Differences (context diff with expected followed by actual):
         ***************
         *** 1,8 ****
           a