Mercurial > hgrepos > Python2 > PyMuPDF
diff tests/test_2904.py @ 1:1d09e1dec1d9 upstream
ADD: PyMuPDF v1.26.4: the original sdist.
It does not yet contain MuPDF. This normally will be downloaded when
building PyMuPDF.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:37:51 +0200 |
| parents | |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/test_2904.py Mon Sep 15 11:37:51 2025 +0200 @@ -0,0 +1,40 @@ +import pymupdf + +import os +import sys + +def test_2904(): + print(f'test_2904(): {pymupdf.mupdf_version_tuple=}.') + path = os.path.abspath(f'{__file__}/../../tests/resources/test_2904.pdf') + pdf_docs = pymupdf.open(path) + for page_id, page in enumerate(pdf_docs): + page_imgs = page.get_images() + for i, img in enumerate(page_imgs): + if page_id == 5: + #print(f'{page_id=} {i=} {type(img)=} {img=}') + sys.stdout.flush() + e = None + try: + recs = page.get_image_rects(img, transform=True) + except Exception as ee: + print(f'Exception: {page_id=} {i=} {img=}: {ee}') + if 0 and hasattr(pymupdf, 'mupdf'): + print(f'pymupdf.exception_info:') + pymupdf.exception_info() + sys.stdout.flush() + e = ee + if page_id == 5: + print(f'{pymupdf.mupdf_version_tuple=}: {page_id=} {i=} {e=} {img=}:') + if page_id == 5 and i==3: + assert e + if hasattr(pymupdf, 'mupdf'): + # rebased. + assert str(e) == 'code=8: Failed to read JPX header' + else: + # classic + assert str(e) == 'Failed to read JPX header' + else: + assert not e + + # Clear warnings, as we will have generated many. + pymupdf.TOOLS.mupdf_warnings()
