summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-21 21:06:22 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-21 21:06:22 (GMT)
commitcf691935bb1a59bd7ff680b26b0b0040b7e25449 (patch)
tree2eedbd0466edcc43e26288040f429c3d8008f2c1
parent0a07639779beb496f3d68021fef28e77dbe13af9 (diff)
downloadcpython-cf691935bb1a59bd7ff680b26b0b0040b7e25449.zip
cpython-cf691935bb1a59bd7ff680b26b0b0040b7e25449.tar.gz
cpython-cf691935bb1a59bd7ff680b26b0b0040b7e25449.tar.bz2
reportdiff(): print a "plain diff" style diff.
XXX This should really be a unified diff, but I can't be bothered.
-rwxr-xr-xLib/test/regrtest.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
index c8c9167..79ee3b1 100755
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -351,10 +351,36 @@ def runtest(test, generate, verbose, quiet, testdir = None):
def reportdiff(expected, output):
print "*" * 70
import difflib
- a = expected.splitlines(1)
- b = output.splitlines(1)
- diff = difflib.ndiff(a, b)
- print ''.join(diff),
+ a = expected.splitlines()
+ b = output.splitlines()
+ sm = difflib.SequenceMatcher(a=a, b=b)
+ tuples = sm.get_opcodes()
+ def pair(x0, x1):
+ x0 += 1
+ if x0 >= x1:
+ return str(x0)
+ else:
+ return "%d,%d" % (x0, x1)
+ for op, a0, a1, b0, b1 in tuples:
+ if op == 'equal':
+ pass
+ elif op == 'delete':
+ print pair(a0, a1) + "d" + pair(b0, b1)
+ for line in a[a0:a1]:
+ print "<", line
+ elif op == 'replace':
+ print pair(a0, a1) + "c" + pair(b0, b1)
+ for line in a[a0:a1]:
+ print "<", line
+ print "---"
+ for line in b[b0:b1]:
+ print ">", line
+ elif op == 'insert':
+ print str(a0) + "a" + pair(b0, b1)
+ for line in b[b0:b1]:
+ print ">", line
+ else:
+ print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1)
print "*" * 70
def findtestdir():