Skip to content

Commit 55d2a00

Browse files
tests/test_pixmap.py:test_4435(): expect alloc failure on pyodide.
1 parent 1dd8583 commit 55d2a00

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/test_pixmap.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import os
1212
import platform
13+
import re
1314
import subprocess
1415
import sys
1516
import tempfile
@@ -521,7 +522,21 @@ def test_4435():
521522
with pymupdf.open(path) as document:
522523
page = document[2]
523524
print(f'Calling page.get_pixmap().', flush=1)
524-
pixmap = page.get_pixmap(alpha=False, dpi=120)
525+
if os.environ.get('PYODIDE_ROOT'):
526+
# 2025-11-07: Expect alloc failure.
527+
try:
528+
pixmap = page.get_pixmap(alpha=False, dpi=120)
529+
except Exception as e:
530+
print(f'Received exception: {type(e)=}: {e}')
531+
assert isinstance(e, pymupdf.mupdf.FzErrorSystem), f'Unrecognised {type(e)=}'
532+
m = re.match('code=2: malloc [(][0-9]+ bytes[)] failed', str(e))
533+
assert m, f'Unrecognised exception text: {e}'
534+
return
535+
else:
536+
# Hopefully this means that mupdf has been fixed.
537+
assert 0, 'Expected alloc failure on pyodide'
538+
else:
539+
pixmap = page.get_pixmap(alpha=False, dpi=120)
525540
print(f'Called page.get_pixmap().', flush=1)
526541
if pymupdf.mupdf_version_tuple < (1, 27):
527542
assert pymupdf.TOOLS.mupdf_warnings() == 'bogus font ascent/descent values (0 / 0)\n... repeated 9 times...'

0 commit comments

Comments
 (0)