MCPcopy Create free account
hub / github.com/pymupdf/PyMuPDF / test_parent

Function test_parent

tests/test_annots.py:459–474  ·  view source on GitHub ↗

Test invalidating parent on page re-assignment.

()

Source from the content-addressed store, hash-verified

457
458
459def test_parent():
460 """Test invalidating parent on page re-assignment."""
461 doc = pymupdf.open()
462 page = doc.new_page()
463 a = page.add_highlight_annot(page.rect) # insert annotation on page 0
464 page = doc.new_page() # make a new page, should orphanate annotation
465 try:
466 print(a) # should raise
467 except Exception as e:
468 if platform.system() == 'OpenBSD':
469 assert isinstance(e, pymupdf.mupdf.FzErrorBase), f'Incorrect {type(e)=}.'
470 else:
471 assert isinstance(e, pymupdf.mupdf.FzErrorArgument), f'Incorrect {type(e)=}.'
472 assert str(e) == 'code=4: annotation not bound to any page', f'Incorrect error text {str(e)=}.'
473 else:
474 assert 0, f'Failed to get expected exception.'
475
476def test_4047():
477 path = os.path.normpath(f'{__file__}/../../tests/resources/test_4047.pdf')

Callers

nothing calls this directly

Calls 2

new_pageMethod · 0.80
add_highlight_annotMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…