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

Function test_linebreaks

tests/test_linebreaks.py:6–16  ·  view source on GitHub ↗

Test avoidance of linebreaks.

()

Source from the content-addressed store, hash-verified

4
5
6def test_linebreaks():
7 """Test avoidance of linebreaks."""
8 path = os.path.abspath(f"{__file__}/../../tests/resources/test-linebreaks.pdf")
9 doc = pymupdf.open(path)
10 page = doc[0]
11 tp = page.get_textpage(flags=pymupdf.TEXTFLAGS_WORDS)
12 word_count = len(page.get_text("words", textpage=tp))
13 line_count1 = len(page.get_text(textpage=tp).splitlines())
14 line_count2 = len(page.get_text(sort=True, textpage=tp).splitlines())
15 assert word_count == line_count1
16 assert line_count2 < line_count1 / 2

Callers

nothing calls this directly

Calls 2

get_textpageMethod · 0.45
get_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…