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

Function test_2788

tests/test_toc.py:106–136  ·  view source on GitHub ↗

Check handling of Document.get_toc() when toc item has kind=4.

()

Source from the content-addressed store, hash-verified

104 new_doc.get_toc()
105
106def test_2788():
107 '''
108 Check handling of Document.get_toc() when toc item has kind=4.
109 '''
110 if not hasattr(pymupdf, 'mupdf'):
111 # Classic implementation does not have fix for this test.
112 print(f'Not running test_2788 on classic implementation.')
113 return
114 path = os.path.abspath(f'{__file__}/../../tests/resources/test_2788.pdf')
115 document = pymupdf.open(path)
116 toc0 = [[1, 'page2', 2, {'kind': 4, 'xref': 14, 'page': 1, 'to': pymupdf.Point(100.0, 760.0), 'zoom': 0.0, 'nameddest': 'page.2'}]]
117 toc1 = document.get_toc(simple=False)
118 print(f'{toc0=}')
119 print(f'{toc1=}')
120 assert toc1 == toc0
121
122 doc.set_toc(toc0)
123 toc2 = document.get_toc(simple=False)
124 print(f'{toc0=}')
125 print(f'{toc2=}')
126 assert toc2 == toc0
127
128 # Also test Page.get_links() bugfix from #2817.
129 for page in document:
130 page.get_links()
131 wt = pymupdf.TOOLS.mupdf_warnings()
132 assert wt == (
133 "syntax error: expected 'obj' keyword (0 3 ?)\n"
134 "trying to repair broken xref\n"
135 "repairing PDF document"
136 ), f'{wt=}'
137
138
139def test_toc_count():

Callers

nothing calls this directly

Calls 4

get_tocMethod · 0.80
set_tocMethod · 0.80
get_linksMethod · 0.80
mupdf_warningsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…