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

Function test_2608

tests/test_font.py:61–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59 assert detected
60
61def test_2608():
62 flags = (pymupdf.TEXT_DEHYPHENATE | pymupdf.TEXT_MEDIABOX_CLIP)
63 with pymupdf.open(os.path.abspath(f'{__file__}/../../tests/resources/2201.00069.pdf')) as doc:
64 page = doc[0]
65 blocks = page.get_text_blocks(flags=flags)
66 text = blocks[10][4]
67 with open(os.path.abspath(f'{__file__}/../../tests/test_2608_out'), 'wb') as f:
68 f.write(text.encode('utf8'))
69 path_expected = os.path.normpath(f'{__file__}/../../tests/resources/test_2608_expected')
70 path_expected_1_26 = os.path.normpath(f'{__file__}/../../tests/resources/test_2608_expected_1.26')
71 if pymupdf.mupdf_version_tuple >= (1, 27):
72 path_expected2 = path_expected
73 else:
74 path_expected2 = path_expected_1_26
75 with open(path_expected2, 'rb') as f:
76 expected = f.read().decode('utf8')
77 # Github windows x32 seems to insert \r characters; maybe something to
78 # do with the Python installation's line endings settings.
79 expected = expected.replace('\r', '')
80 print(f'test_2608(): {text.encode("utf8")=}')
81 print(f'test_2608(): {expected.encode("utf8")=}')
82 assert text == expected
83
84def test_fontarchive():
85 if os.environ.get('PYODIDE_ROOT'):

Callers

nothing calls this directly

Calls 2

get_text_blocksMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…