Mercurial > piecrust2
diff tests/conftest.py @ 365:a9929e0b8f66
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.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 03 May 2015 18:40:05 -0700 |
parents | 1f22d4b10fef |
children | 2d5f2289885a |
line wrap: on
line diff
--- 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,