Mercurial > piecrust2
diff tests/conftest.py @ 665:5dc13c816045
tests: Fix logic for making time-based tests not fail randomly.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Thu, 03 Mar 2016 08:19:28 -0800 |
parents | 1eda551ee681 |
children | 81d9c3a3a0b5 |
line wrap: on
line diff
--- a/tests/conftest.py Wed Mar 02 20:46:00 2016 -0800 +++ b/tests/conftest.py Thu Mar 03 08:19:28 2016 -0800 @@ -462,7 +462,12 @@ else: break + skip_for = -1 for i in range(min(len(left), len(right))): + if skip_for > 0: + skip_for -= 1 + continue + if i in left_time_indices: # This is where the time starts. Let's compare that the time # values are within a few seconds of each other (usually 0 or 1). @@ -473,7 +478,7 @@ print("Got time difference: %d" % difference) if abs(difference) <= 2: print("(good enough, moving to end of timestamp)") - i += len(test_time_iso8601) + skip_for = len(test_time_iso8601) - 1 if left[i] != right[i]: start = max(0, i - 15) @@ -502,11 +507,13 @@ "Difference:", l_str, (' ' * l_offset + '^'), r_str, (' ' * r_offset + '^')] + if len(left) > len(right): return ["Left is longer.", "Left '%s': " % ctx.path, left, "Right '%s': " % ctx.path, right, "Extra items: %r" % left[len(right):]] + if len(right) > len(left): return ["Right is longer.", "Left '%s': " % ctx.path, left,