# HG changeset patch # User Augie Fackler # Date 1429633474 14400 # Node ID 8a425c2eef5da3d997c61643d2d16081dae3c572 # Parent 9de94acfde8a2dadbf5f1cf15e4336d93f39fefa run-tests: use difflib.diff_bytes on Python 3 This method was introduced in Python 3.5 to satisfy our diffing-strings-of-bytes needs. diff -r 9de94acfde8a -r 8a425c2eef5d tests/run-tests.py --- a/tests/run-tests.py Sun Apr 12 16:14:07 2015 -0400 +++ b/tests/run-tests.py Tue Apr 21 12:24:34 2015 -0400 @@ -324,17 +324,22 @@ shutil.copy(src, dst) os.remove(src) +_unified_diff = difflib.unified_diff +if sys.version_info[0] > 2: + import functools + _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) + def getdiff(expected, output, ref, err): servefail = False lines = [] - for line in difflib.unified_diff(expected, output, ref, err): - if line.startswith('+++') or line.startswith('---'): - line = line.replace('\\', '/') - if line.endswith(' \n'): - line = line[:-2] + '\n' + for line in _unified_diff(expected, output, ref, err): + if line.startswith(b'+++') or line.startswith(b'---'): + line = line.replace(b'\\', b'/') + if line.endswith(b' \n'): + line = line[:-2] + b'\n' lines.append(line) if not servefail and line.startswith( - '+ abort: child process failed to start'): + b'+ abort: child process failed to start'): servefail = True return servefail, lines