Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/test_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_4457():
('https://github.com/user-attachments/files/20862922/test_4457_b.pdf', 'test_4457_b.pdf', None, 9),
)
for url, name, size, rms_old_after_max in files:
path = util.download(url, name, size)
path = util.download(url, name, size=size)

with pymupdf.open(path) as document:
page = document[0]
Expand Down
32 changes: 32 additions & 0 deletions tests/test_pixmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,7 @@ def test_natural():
pix=pymupdf.Pixmap(pm)
print(f"{pix=}")


def text_pixmap_transpositions():
"""Test that flip_rotate() is consistent with repeated applications."""
path = os.path.normpath(f'{__file__}/../../tests/resources/test_natural.pdf')
Expand All @@ -777,3 +778,34 @@ def text_pixmap_transpositions():
for _ in range(repeat):
new = new.flip_rotate(mode)
assert new.samples == samples0, "Failed for mode %s" % mode


def test_5082():
print()
path = util.download(
'https://www.city.toyota.aichi.jp/_res/projects/default_project/_page_/001/057/466/01.pdf',
'test_5082.pdf',
headers={'user-agent': 'pymupdf-test'}, # Avoids html 403 failure.
)
print(f'test_5082(): {pymupdf.mupdf_version=}.')
print(f'test_5082(): calling page.get_pixmap() in child process.')
timeout = False
try:
cp = subprocess.run(
[
sys.executable,
'-c',
f'import pymupdf; document=pymupdf.open({path!r}); page = document[0]; page.get_pixmap()',
],
check=1,
timeout=10,
)
except subprocess.TimeoutExpired:
timeout = True
print(f'test_5082(): {timeout=}')
# As of 2026-08-18 we expect timeout with 1.28.x (currently 1.28.3) and
# earlier.
if pymupdf.mupdf_version_tuple <= (1, 28, 3):
assert timeout, f'Expected timeout from {pymupdf.mupdf_version=}.'
else:
assert not timeout, f'Unexpected timeout from {pymupdf.mupdf_version=}.'
4 changes: 2 additions & 2 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import subprocess


def download(url, name, size=None):
def download(url, name, *, timeout=10, size=None, headers=None):
'''
Downloads from <url> to a local file and returns its path.

Expand All @@ -18,7 +18,7 @@ def download(url, name, size=None):
print(f'Downloading from {url=}.')
subprocess.run(f'pip install -U requests', check=1, shell=1)
import requests
r = requests.get(url, path, timeout=10)
r = requests.get(url, path, timeout=10, headers=headers)
r.raise_for_status()
if size is not None:
assert len(r.content) == size
Expand Down
Loading