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

Function test_2957_1

tests/test_general.py:801–824  ·  view source on GitHub ↗

Text following a redaction must not change coordinates.

()

Source from the content-addressed store, hash-verified

799
800
801def test_2957_1():
802 """Text following a redaction must not change coordinates."""
803 # test file with redactions
804 doc = pymupdf.open(os.path.join(scriptdir, "resources", "test_2957_1.pdf"))
805 page = doc[0]
806 # search for string that must not move by redactions
807 rects0 = page.search_for("6e9f73dfb4384a2b8af6ebba")
808 # sort rectangles vertically
809 rects0 = sorted(rects0, key=lambda r: r.y1)
810 assert len(rects0) == 2 # must be 2 redactions
811 page.apply_redactions()
812
813 # reload page to finalize updates
814 page = doc.reload_page(page)
815
816 # the two string must retain their positions (except rounding errors)
817 rects1 = page.search_for("6e9f73dfb4384a2b8af6ebba")
818 rects1 = sorted(rects1, key=lambda r: r.y1)
819
820 assert page.first_annot is None # make sure annotations have disappeared
821 for i in range(2):
822 r0 = rects0[i].irect # take rounded rects
823 r1 = rects1[i].irect
824 assert r0 == r1
825
826
827def test_2957_2():

Callers

nothing calls this directly

Calls 3

search_forMethod · 0.80
apply_redactionsMethod · 0.80
reload_pageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…