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

Function test_page_clean_contents

tests/test_general.py:96–110  ·  view source on GitHub ↗

Assert that page contents cleaning actually is invoked.

()

Source from the content-addressed store, hash-verified

94
95
96def test_page_clean_contents():
97 """Assert that page contents cleaning actually is invoked."""
98 doc = pymupdf.open()
99 page = doc.new_page()
100
101 # draw two rectangles - will lead to two /Contents objects
102 page.draw_rect((10, 10, 20, 20))
103 page.draw_rect((20, 20, 30, 30))
104 assert len(page.get_contents()) == 2
105 assert page.read_contents().startswith(b"q") == False
106
107 # clean / consolidate into one /Contents object
108 page.clean_contents()
109 assert len(page.get_contents()) == 1
110 assert page.read_contents().startswith(b"q") == True
111
112
113def test_annot_clean_contents():

Callers

nothing calls this directly

Calls 5

new_pageMethod · 0.80
get_contentsMethod · 0.80
read_contentsMethod · 0.80
draw_rectMethod · 0.45
clean_contentsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…