Skip to content

Commit 53a3151

Browse files
committed
tests: workaround yadiff undeterministic behavior
1 parent 127bc67 commit 53a3151

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tests/test_yadiff.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,18 @@ def check_golden(golden_filename, got):
2929
with open(expected_path, "rb") as fh:
3030
expected = fh.read()
3131

32-
if expected != got:
33-
raise BaseException("\n" + "".join(difflib.unified_diff(expected.splitlines(1), got.splitlines(1), golden_filename, "got")))
32+
if expected == got:
33+
return
34+
35+
# yadiff is not deterministic anymore
36+
# so we want a small diff arbitrarily set at $max_lines lines
37+
max_lines = 100
38+
diff = "".join(difflib.unified_diff(expected.splitlines(1), got.splitlines(1), golden_filename, "got"))
39+
difflines = diff.splitlines(1)
40+
if len(difflines) < max_lines:
41+
return
42+
43+
raise BaseException("diff: %d lines\n%s" % (len(difflines), diff))
3444

3545
def check_yadiff_database(args):
3646
sys.path.append(os.path.join(args.bindir, "bin"))

0 commit comments

Comments
 (0)