Skip to content

Commit d1acfb4

Browse files
tests/test_annots.py: fix test_2270() with mupdf 1.25.x - no FZ_STEXT_CLIP_RECT yet.
1 parent f077edd commit d1acfb4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

tests/test_annots.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,24 +287,26 @@ def test_2270():
287287
assert textBox.get_textbox(textBox.rect) == 'abc123'
288288
assert textBox.info['content'] == 'abc123'
289289

290-
if hasattr(pymupdf, 'mupdf'):
291-
# Additional check that Annot.get_textpage() returns a
292-
# TextPage that works with page.get_text() - prior to
293-
# 2024-01-30 the TextPage had no `.parent` member.
294-
textpage = textBox.get_textpage()
295-
text = page.get_text()
296-
print(f'{text=}')
297-
text = page.get_text(textpage=textpage)
298-
print(f'{text=}')
299-
print(f'{getattr(textpage, "parent")=}')
300-
290+
# Additional check that Annot.get_textpage() returns a
291+
# TextPage that works with page.get_text() - prior to
292+
# 2024-01-30 the TextPage had no `.parent` member.
293+
textpage = textBox.get_textpage()
294+
text = page.get_text()
295+
print(f'{text=}')
296+
text = page.get_text(textpage=textpage)
297+
print(f'{text=}')
298+
print(f'{getattr(textpage, "parent")=}')
299+
300+
if pymupdf.mupdf_version_tuple >= (1, 26):
301301
# Check Annotation.get_textpage()'s <clip> arg.
302302
clip = textBox.rect
303303
clip.x1 = clip.x0 + (clip.x1 - clip.x0) / 3
304304
textpage2 = textBox.get_textpage(clip=clip)
305305
text = textpage2.extractText()
306306
print(f'With {clip=}: {text=}')
307307
assert text == 'ab\n'
308+
else:
309+
assert not hasattr(pymupdf.mupdf, 'FZ_STEXT_CLIP_RECT')
308310

309311

310312
def test_2934_add_redact_annot():

0 commit comments

Comments
 (0)