[pypy-svn] r64215 - pypy/trunk/lib-python
afa at codespeak.net
afa at codespeak.net
Fri Apr 17 10:23:47 CEST 2009
Author: afa
Date: Fri Apr 17 10:23:46 2009
New Revision: 64215
Modified:
pypy/trunk/lib-python/conftest.py
Log:
test.regrtest.reportdiff was deleted in CPython2.6
(as an "implementation detail": python2.6 tests don't compare output any more)
Blindly copy the function from a 2.5 version.
Modified: pypy/trunk/lib-python/conftest.py
==============================================================================
--- pypy/trunk/lib-python/conftest.py (original)
+++ pypy/trunk/lib-python/conftest.py Fri Apr 17 10:23:46 2009
@@ -14,7 +14,6 @@
# the following adds command line options as a side effect!
from pypy.conftest import gettestobjspace, option as pypy_option
-from test.regrtest import reportdiff
from test import pystone
from pypy.tool.pytest import appsupport
@@ -698,6 +697,49 @@
lst.append('core')
return lst
+# test.regrtest.reportdiff was deleted in CPython2.6
+def reportdiff(expected, output):
+ import difflib
+ print "*" * 70
+ a = expected.splitlines(1)
+ b = output.splitlines(1)
+ sm = difflib.SequenceMatcher(a=a, b=b)
+ tuples = sm.get_opcodes()
+
+ def pair(x0, x1):
+ # x0:x1 are 0-based slice indices; convert to 1-based line indices.
+ x0 += 1
+ if x0 >= x1:
+ return "line " + str(x0)
+ else:
+ return "lines %d-%d" % (x0, x1)
+
+ for op, a0, a1, b0, b1 in tuples:
+ if op == 'equal':
+ pass
+
+ elif op == 'delete':
+ print "***", pair(a0, a1), "of expected output missing:"
+ for line in a[a0:a1]:
+ print "-", line,
+
+ elif op == 'replace':
+ print "*** mismatch between", pair(a0, a1), "of expected", \
+ "output and", pair(b0, b1), "of actual output:"
+ for line in difflib.ndiff(a[a0:a1], b[b0:b1]):
+ print line,
+
+ elif op == 'insert':
+ print "***", pair(b0, b1), "of actual output doesn't appear", \
+ "in expected output after line", str(a1)+":"
+ for line in b[b0:b1]:
+ print "+", line,
+
+ else:
+ print "get_opcodes() returned bad tuple?!?!", (op, a0, a1, b0, b1)
+
+ print "*" * 70
+
#
# Sanity check (could be done more nicely too)
#
More information about the Pypy-commit
mailing list