@@ -161,6 +161,26 @@ def test_savefig_metadata(monkeypatch):
161
161
}
162
162
163
163
164
+ def test_invalid_metadata (monkeypatch ):
165
+ fig , ax = plt .subplots ()
166
+
167
+ with pytest .warns (UserWarning ,
168
+ match = "Unknown infodict keyword: 'foobar'." ):
169
+ fig .savefig (io .BytesIO (), format = 'pdf' , metadata = {'foobar' : 'invalid' })
170
+
171
+ with pytest .warns (UserWarning ,
172
+ match = 'not an instance of datetime.datetime.' ):
173
+ fig .savefig (io .BytesIO (), format = 'pdf' ,
174
+ metadata = {'ModDate' : '1968-08-01' })
175
+
176
+ with pytest .warns (UserWarning ,
177
+ match = 'not one of {"True", "False", "Unknown"}' ):
178
+ fig .savefig (io .BytesIO (), format = 'pdf' , metadata = {'Trapped' : 'foo' })
179
+
180
+ with pytest .warns (UserWarning , match = 'not an instance of str.' ):
181
+ fig .savefig (io .BytesIO (), format = 'pdf' , metadata = {'Title' : 1234 })
182
+
4D0F
td>
183
+
164
184
def test_multipage_metadata (monkeypatch ):
165
185
pikepdf = pytest .importorskip ('pikepdf' )
166
186
monkeypatch .setenv ('SOURCE_DATE_EPOCH' , '0' )
0 commit comments