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

Function test_2596

tests/test_general.py:595–613  ·  view source on GitHub ↗

Confirm correctly abandoning cache when reloading a page.

()

Source from the content-addressed store, hash-verified

593
594
595def test_2596():
596 """Confirm correctly abandoning cache when reloading a page."""
597 if platform.python_implementation() == 'GraalVM':
598 print(f'test_2596(): not running on Graal.')
599 return
600 doc = pymupdf.Document(f"{scriptdir}/resources/test_2596.pdf")
601 page = doc[0]
602 pix0 = page.get_pixmap() # render the page
603 _ = doc.tobytes(garbage=3) # save with garbage collection
604
605 # Note this will invalidate cache content for this page.
606 # Reloading the page now empties the cache, so rendering
607 # will deliver the same pixmap
608 page = doc.reload_page(page)
609 pix1 = page.get_pixmap()
610 assert pix1.samples == pix0.samples
611 if pymupdf.mupdf_version_tuple < (1, 26, 6):
612 wt = pymupdf.TOOLS.mupdf_warnings()
613 assert wt == 'too many indirections (possible indirection cycle involving 24 0 R)'
614
615
616def test_2730():

Callers

nothing calls this directly

Calls 4

tobytesMethod · 0.95
reload_pageMethod · 0.95
mupdf_warningsMethod · 0.80
get_pixmapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…