Skip to content

Commit d596c65

Browse files
tests/test_annots.py: test_1645(): use gentle_compare.pixmaps_rms() instead of direct comparison.
Avoids spurious failures from harmless mupdf changes.
1 parent 8d0ad7d commit d596c65

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/test_annots.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,13 @@ def test_1645():
257257
)
258258
doc.save(path_out, garbage=1, deflate=True, no_new_id=True)
259259
print(f'Have created {path_out}. comparing with {path_expected}.')
260-
with open( path_out, 'rb') as f:
261-
out = f.read()
262-
with open( path_expected, 'rb') as f:
263-
expected = f.read()
264-
assert out == expected, f'Files differ: {path_out} {path_expected}'
260+
with pymupdf.open(path_expected) as doc_expected, pymupdf.open(path_out) as doc_out:
261+
rms = gentle_compare.pixmaps_rms(
262+
doc_expected[0].get_pixmap(),
263+
doc_out[0].get_pixmap(),
264+
)
265+
print(f'test_1645: {rms=}')
266+
assert rms < 0.1, f'Pixmaps differ: {path_expected=} {path_out=}'
265267
finally:
266268
# Restore annot_stem.
267269
pymupdf.TOOLS.set_annot_stem(annot_stem)

0 commit comments

Comments
 (0)