322 for existing destination support. |
322 for existing destination support. |
323 """ |
323 """ |
324 shutil.copy(src, dst) |
324 shutil.copy(src, dst) |
325 os.remove(src) |
325 os.remove(src) |
326 |
326 |
|
327 _unified_diff = difflib.unified_diff |
|
328 if sys.version_info[0] > 2: |
|
329 import functools |
|
330 _unified_diff = functools.partial(difflib.diff_bytes, difflib.unified_diff) |
|
331 |
327 def getdiff(expected, output, ref, err): |
332 def getdiff(expected, output, ref, err): |
328 servefail = False |
333 servefail = False |
329 lines = [] |
334 lines = [] |
330 for line in difflib.unified_diff(expected, output, ref, err): |
335 for line in _unified_diff(expected, output, ref, err): |
331 if line.startswith('+++') or line.startswith('---'): |
336 if line.startswith(b'+++') or line.startswith(b'---'): |
332 line = line.replace('\\', '/') |
337 line = line.replace(b'\\', b'/') |
333 if line.endswith(' \n'): |
338 if line.endswith(b' \n'): |
334 line = line[:-2] + '\n' |
339 line = line[:-2] + b'\n' |
335 lines.append(line) |
340 lines.append(line) |
336 if not servefail and line.startswith( |
341 if not servefail and line.startswith( |
337 '+ abort: child process failed to start'): |
342 b'+ abort: child process failed to start'): |
338 servefail = True |
343 servefail = True |
339 |
344 |
340 return servefail, lines |
345 return servefail, lines |
341 |
346 |
342 verbose = False |
347 verbose = False |