diff --git a/tests/test_page_boxes.py b/tests/test_page_boxes.py index ad428a6f..c033609e 100644 --- a/tests/test_page_boxes.py +++ b/tests/test_page_boxes.py @@ -6,6 +6,8 @@ from __future__ import annotations import pikepdf import pytest +from ocrmypdf._exec import verapdf + from .conftest import check_ocrmypdf page_rect = [0, 0, 612, 792] @@ -14,12 +16,14 @@ wh_rect = [0, 0, 412, 592] neg_rect = [-100, -100, 512, 692] +# When speculative PDF/A succeeds (verapdf available), MediaBox is preserved. +# Ghostscript would normalize MediaBox to start at origin, but speculative +# conversion bypasses Ghostscript. +_pdfa_inset_expected = inset_rect if verapdf.available() else wh_rect + mediabox_testdata = [ - # When speculative PDF/A succeeds (verapdf available), MediaBox is preserved. - # Ghostscript would normalize MediaBox to start at origin, but speculative - # conversion bypasses Ghostscript. - ('fpdf2', 'pdfa', 'ccitt.pdf', None, inset_rect, inset_rect), - ('sandwich', 'pdfa', 'ccitt.pdf', None, inset_rect, inset_rect), + ('fpdf2', 'pdfa', 'ccitt.pdf', None, inset_rect, _pdfa_inset_expected), + ('sandwich', 'pdfa', 'ccitt.pdf', None, inset_rect, _pdfa_inset_expected), ('fpdf2', 'pdf', 'ccitt.pdf', None, inset_rect, inset_rect), ('sandwich', 'pdf', 'ccitt.pdf', None, inset_rect, inset_rect), ( @@ -68,7 +72,7 @@ def test_media_box( with pikepdf.open(outdir / 'processed.pdf') as pdf: page = pdf.pages[0] - assert page.mediabox == crop_expected + assert [float(x) for x in page.mediabox] == crop_expected cropbox_testdata = [ @@ -122,4 +126,4 @@ def test_crop_box( with pikepdf.open(outdir / 'processed.pdf') as pdf: page = pdf.pages[0] - assert page.cropbox == crop_expected + assert [float(x) for x in page.cropbox] == crop_expected