Skip to content

Commit

Permalink
tests/test_annots.py: added test_3758().
Browse files Browse the repository at this point in the history
For #3758. Note that the input file is not public so this test does nothing if
it is not present.
  • Loading branch information
julian-smith-artifex-com committed Oct 28, 2024
1 parent 295116f commit 7d1dd31
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/test_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,3 +419,23 @@ def test_3863():
# We get small differences in sysinstall tests, where some
# thirdparty libraries can differ.
assert rms < 1

def test_3758():
# This test requires input file that is not public, so is usually not
# available.
path = os.path.normpath(f'{__file__}/../../../test_3758.pdf')
if not os.path.exists(path):
print(f'test_3758(): not running because does not exist: {path=}.')
return
import json
with pymupdf.open(path) as document:
for page in document:
info = json.loads(page.get_text('json', flags=pymupdf.TEXTFLAGS_TEXT))
for block_ind, block in enumerate(info['blocks']):
for line_ind, line in enumerate(block['lines']):
for span_ind, span in enumerate(line['spans']):
# print(span)
page.add_redact_annot(pymupdf.Rect(*span['bbox']))
page.apply_redactions()
wt = pymupdf.TOOLS.mupdf_warnings()
assert wt

0 comments on commit 7d1dd31

Please sign in to comment.