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

Function test_4245

tests/test_textextract.py:498–521  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

496
497
498def test_4245():
499 path = os.path.normpath(f'{__file__}/../../tests/resources/test_4245.pdf')
500 with pymupdf.open(path) as document:
501 page = document[0]
502 regions = page.search_for('Bart Simpson')
503 print(f'{regions=}')
504 page.add_highlight_annot(regions)
505 with pymupdf.open(path) as document:
506 page = document[0]
507 regions = page.search_for('Bart Simpson')
508 for region in regions:
509 highlight = page.add_highlight_annot(region)
510 highlight.update()
511 pixmap = page.get_pixmap()
512 path_out = os.path.normpath(f'{__file__}/../../tests/resources/test_4245_out.png')
513 pixmap.save(path_out)
514
515 path_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_4245_expected.png')
516 rms = gentle_compare.pixmaps_rms(path_expected, pixmap)
517 pixmap_diff = gentle_compare.pixmaps_diff(path_expected, pixmap)
518 path_diff = os.path.normpath(f'{__file__}/../../tests/resources/test_4245_diff.png')
519 pixmap_diff.save(path_diff)
520 print(f'{rms=}')
521 assert rms < 0.01
522
523
524def test_4180():

Callers

nothing calls this directly

Calls 5

search_forMethod · 0.80
add_highlight_annotMethod · 0.80
updateMethod · 0.45
get_pixmapMethod · 0.45
saveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…