# HG changeset patch # User Ludovic Chabant # Date 1430703605 25200 # Node ID a9929e0b8f6667cf5b491e411b18bd879fb545d6 # Parent 81480d0219baae004d95dc9826c371b1f5ef27eb tests: Changes to output report and hack for comparing outputs. * Still some problems with newlines and YAML so might as well strip both the actual and expected outputs. * More fancy output for comparing strings. diff -r 81480d0219ba -r a9929e0b8f66 tests/conftest.py --- a/tests/conftest.py Wed Apr 29 23:12:28 2015 -0700 +++ b/tests/conftest.py Sun May 03 18:40:05 2015 -0700 @@ -97,6 +97,7 @@ expected = expected_partial_files[key] # HACK because for some reason PyYAML adds a new line for those # and I have no idea why. + actual = actual.rstrip('\n') expected = expected.rstrip('\n') cmpres = _compare_str(expected, actual, key) if cmpres: @@ -188,14 +189,20 @@ return None for i in range(min(len(left), len(right))): if left[i] != right[i]: - start = max(0, i - 5) - lend = min(len(left), i + 5) - rend = min(len(right), i + 5) - return ["Items '%s' differ at index %d:" % (path, i), - left[start:lend], - (' ' * start + '^'), - right[start:rend], - (' ' * start + '^')] + start = max(0, i - 15) + marker_offset = min(15, (i - start)) + 3 + + lend = min(len(left), i + 15) + rend = min(len(right), i + 15) + + return ["Items '%s' differ at index %d:" % (path, i), '', + "Left:", left, '', + "Right:", right, '', + "Difference:", + repr(left[start:lend]), + (' ' * marker_offset + '^'), + repr(right[start:rend]), + (' ' * marker_offset + '^')] if len(left) > len(right): return ["Left is longer.", "Left '%s': " % path, left,