MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_multipage_metadata

Function test_multipage_metadata

lib/matplotlib/tests/test_backend_pdf.py:179–213  ·  view source on GitHub ↗
(monkeypatch)

Source from the content-addressed store, hash-verified

177
178
179def test_multipage_metadata(monkeypatch):
180 pikepdf = pytest.importorskip('pikepdf')
181 monkeypatch.setenv('SOURCE_DATE_EPOCH', '0')
182
183 fig, ax = plt.subplots()
184 ax.plot(range(5))
185
186 md = {
187 'Author': 'me',
188 'Title': 'Multipage PDF',
189 'Subject': 'Test page',
190 'Keywords': 'test,pdf,multipage',
191 'ModDate': datetime.datetime(
192 1968, 8, 1, tzinfo=datetime.timezone(datetime.timedelta(0))),
193 'Trapped': 'True'
194 }
195 buf = io.BytesIO()
196 with PdfPages(buf, metadata=md) as pdf:
197 pdf.savefig(fig)
198 pdf.savefig(fig)
199
200 with pikepdf.Pdf.open(buf) as pdf:
201 info = {k: str(v) for k, v in pdf.docinfo.items()}
202
203 assert info == {
204 '/Author': 'me',
205 '/CreationDate': 'D:19700101000000Z',
206 '/Creator': f'Matplotlib v{mpl.__version__}, https://matplotlib.org',
207 '/Keywords': 'test,pdf,multipage',
208 '/ModDate': 'D:19680801000000Z',
209 '/Producer': f'Matplotlib pdf backend v{mpl.__version__}',
210 '/Subject': 'Test page',
211 '/Title': 'Multipage PDF',
212 '/Trapped': '/True',
213 }
214
215
216def test_text_urls():

Callers

nothing calls this directly

Calls 5

PdfPagesClass · 0.90
subplotsMethod · 0.45
plotMethod · 0.45
savefigMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…