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

Function test_4079

tests/test_annots.py:490–520  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

488 page.apply_redactions()
489
490def test_4079():
491 path = os.path.normpath(f'{__file__}/../../tests/resources/test_4079.pdf')
492 path_after = os.path.normpath(f'{__file__}/../../tests/resources/test_4079_after.pdf')
493
494 path_out = os.path.normpath(f'{__file__}/../../tests/test_4079_out')
495 with pymupdf.open(path_after) as document_after:
496 page = document_after[0]
497 pixmap_after_expected = page.get_pixmap()
498 with pymupdf.open(path) as document:
499 page = document[0]
500 rects = [
501 [164,213,282,227],
502 [282,213,397,233],
503 [434,209,525,243],
504 [169,228,231,243],
505 [377,592,440,607],
506 [373,611,444,626],
507 ]
508 for rect in rects:
509 page.add_redact_annot(rect, fill=(1,0,0))
510 page.draw_rect(rect, color=(0, 1, 0))
511 document.save(f'{path_out}_before.pdf')
512 page.apply_redactions(images=0)
513 pixmap_after = page.get_pixmap()
514 document.save(f'{path_out}_after.pdf')
515 rms = gentle_compare.pixmaps_rms(pixmap_after_expected, pixmap_after)
516 diff = gentle_compare.pixmaps_diff(pixmap_after_expected, pixmap_after)
517 path = os.path.normpath(f'{__file__}/../../tests/test_4079_diff.png')
518 diff.save(path)
519 print(f'{rms=}')
520 assert rms == 0
521
522def test_4254():
523 """Ensure that both annotations are fully created

Callers

nothing calls this directly

Calls 5

add_redact_annotMethod · 0.80
apply_redactionsMethod · 0.80
get_pixmapMethod · 0.45
draw_rectMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…