MCPcopy Index your code
hub / github.com/pymupdf/PyMuPDF / test_2108

Function test_2108

tests/test_general.py:365–403  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

363
364
365def test_2108():
366 doc = pymupdf.open(f'{scriptdir}/resources/test_2108.pdf')
367 page = doc[0]
368 areas = page.search_for("{sig}")
369 rect = areas[0]
370 page.add_redact_annot(rect)
371 page.apply_redactions()
372 text = page.get_text()
373
374 text_expected = b'Frau\nClaire Dunphy\nTeststra\xc3\x9fe 5\n12345 Stadt\nVertragsnummer: 12345\nSehr geehrte Frau Dunphy,\nText\nMit freundlichen Gr\xc3\xbc\xc3\x9fen\nTestfirma\nVertrag:\n 12345\nAnsprechpartner:\nJay Pritchet\nTelefon:\n123456\nE-Mail:\ntest@test.de\nDatum:\n07.12.2022\n'.decode('utf8')
375
376 if 1:
377 # Verbose info.
378 print(f'test_2108(): text is:\n{text}')
379 print(f'')
380 print(f'test_2108(): repr(text) is:\n{text!r}')
381 print(f'')
382 print(f'test_2108(): repr(text.encode("utf8")) is:\n{text.encode("utf8")!r}')
383 print(f'')
384 print(f'test_2108(): text_expected is:\n{text_expected}')
385 print(f'')
386 print(f'test_2108(): repr(text_expected) is:\n{text_expected!r}')
387 print(f'')
388 print(f'test_2108(): repr(text_expected.encode("utf8")) is:\n{text_expected.encode("utf8")!r}')
389
390 ok1 = (text == text_expected)
391 ok2 = (text.encode("utf8") == text_expected.encode("utf8"))
392 ok3 = (repr(text.encode("utf8")) == repr(text_expected.encode("utf8")))
393
394 print(f'')
395 print(f'ok1={ok1}')
396 print(f'ok2={ok2}')
397 print(f'ok3={ok3}')
398
399 print(f'')
400
401 print(f'{pymupdf.mupdf_version_tuple=}')
402 print('Asserting text==text_expected')
403 assert text == text_expected
404
405
406def test_2238():

Callers

nothing calls this directly

Calls 4

search_forMethod · 0.80
add_redact_annotMethod · 0.80
apply_redactionsMethod · 0.80
get_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…