8000 Add test for invalid PDF metadata warnings. · matplotlib/matplotlib@1970ce3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1970ce3

Browse files
committed
Add test for invalid PDF metadata warnings.
1 parent 3ab7f84 commit 1970ce3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/matplotlib/tests/test_backend_pdf.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,22 @@ def test_savefig_metadata(monkeypatch):
161161
}
162162

163163

164+
def test_invalid_metadata(monkeypatch):
165+
fig, ax = plt.subplots()
166+
167+
with pytest.warns(UserWarning,
168+
match='not an instance of datetime.datetime.'):
169+
fig.savefig(io.BytesIO(), format='pdf',
170+
metadata={'ModDate': '1968-08-01'})
171+
172+
with pytest.warns(UserWarning,
173+
match='not one of {"True", "False", "Unknown"}'):
174+
fig.savefig(io.BytesIO(), format='pdf', metadata={'Trapped': 'foo'})
175+
176+
with pytest.warns(UserWarning, match='not an instance of str.'):
177+
fig.savefig(io.BytesIO(), format='pdf', metadata={'Title': 1234})
178+
179+
164180
def test_multipage_metadata(monkeypatch):
165181
pikepdf = pytest.importorskip('pikepdf')
166182
monkeypatch.setenv('SOURCE_DATE_EPOCH', '0')

0 commit comments

Comments
 (0)
0