Skip to content

Commit

Permalink
tests/: added test_2907() for segfault bug in classic.
Browse files Browse the repository at this point in the history
This is for pymupdf#2907, 'segfault trying to call clean_contents on certain pdfs with
python 3.12'.

We are not intending to fix this bug, so actually this test only runs on
rebased.
  • Loading branch information
julian-smith-artifex-com committed Dec 20, 2023
1 parent f2f8ad0 commit 4b4840d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Binary file added tests/resources/test_2907.pdf
Binary file not shown.
18 changes: 18 additions & 0 deletions tests/test_2907.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import fitz

import os.path
import pathlib

def test_2907():
# This test is for a bug in classic 'segfault trying to call clean_contents
# on certain pdfs with python 3.12', which we are not going to fix.
if not hasattr(fitz, 'mupdf'):
print('test_2907(): not running on classic because known to fail.')
return
path = os.path.abspath(f'{__file__}/../../tests/resources/test_2907.pdf')
pdf_file = pathlib.Path(path).read_bytes()
fitz_document = fitz.open(stream=pdf_file, filetype="application/pdf")

pdf_pages = list(fitz_document.pages())
(page,) = pdf_pages
page.clean_contents()

0 comments on commit 4b4840d

Please sign in to comment.