@@ -214,48 +214,30 @@ def test_bbox_inches():
214
214
tol = 0 )
215
215
216
216
217
- @needs_pdflatex
218
217
@pytest .mark .style ('default' )
219
218
@pytest .mark .backend ('pgf' )
220
- def test_pdf_pages ():
219
+ @pytest .mark .parametrize ('system' , [
220
+ pytest .param ('lualatex' , marks = [needs_lualatex ]),
221
+ pytest .param ('pdflatex' , marks = [needs_pdflatex ]),
222
+ pytest .param ('xelatex' , marks = [needs_xelatex ]),
223
+ ])
224
+ def test_pdf_pages (system ):
221
225
rc_pdflatex = {
222
226
'font.family' : 'serif' ,
223
227
'pgf.rcfonts' : False ,
224
- 'pgf.texsystem' : 'pdflatex' ,
228
+ 'pgf.texsystem' : system ,
225
229
}
226
230
mpl .rcParams .update (rc_pdflatex )
227
231
228
- fig1 = plt .figure ()
229
- ax1 = fig1 .add_subplot (1 , 1 , 1 )
232
+ fig1 , ax1 = plt .subplots ()
230
233
ax1 .plot (range (5 ))
231
234
fig1 .tight_layout ()
232
235
233
- fig2 = plt .figure (figsize = (3 , 2 ))
234
- ax2 = fig2 .add_subplot (1 , 1 , 1 )
236
+ fig2 , ax2 = plt .subplots (figsize = (3 , 2 ))
235
237
ax2 .plot (range (5 ))
236
238
fig2 .tight_layout ()
237
239
238
- with PdfPages (os .path .join (result_dir , 'pdfpages.pdf' )) as pdf :
239
- pdf .savefig (fig1 )
240
- pdf .savefig (fig2 )
241
-
242
-
243
- @needs_xelatex
244
- @pytest .mark .style ('default' )
245
- @pytest .mark .backend ('pgf' )
246
- def test_pdf_pages_metadata ():
247
- rc_pdflatex = {
248
- 'font.family' : 'serif' ,
249
- 'pgf.rcfonts' : False ,
250
- 'pgf.texsystem' : 'xelatex' ,
251
- }
252
- mpl .rcParams .update (rc_pdflatex )
253
-
254
- fig = plt .figure ()
255
- ax = fig .add_subplot (1 , 1 , 1 )
256
- ax .plot (range (5 ))
257
- fig .tight_layout ()
258
-
240
+ path = os .path .join (result_dir , f'pdfpages_{ system } .pdf' )
259
241
md = {
260
242
'Author' : 'me' ,
261
243
'Title' : 'Multipage PDF with pgf' ,
@@ -265,41 +247,14 @@ def test_pdf_pages_metadata():
265
247
'Trapped' : 'Unknown'
266
248
}
267
249
268
- path = os .path .join (result_dir , 'pdfpages_meta.pdf' )
269
-
270
250
with PdfPages (path , metadata = md ) as pdf :
271
- pdf .savefig (fig )
272
- pdf .savefig (fig )
273
- pdf .savefig (fig )
251
+ pdf .savefig (fig1 )
252
+ pdf .savefig (fig2 )
253
+ pdf .savefig (fig1 )
274
254
275
255
assert pdf .get_pagecount () == 3
276
256
277
257
278
- @needs_lualatex
279
- @pytest .mark .style ('default' )
280
- @pytest .mark .backend ('pgf' )
281
- def test_pdf_pages_lualatex ():
282
- rc_pdflatex = {
283
- 'font.family' : 'serif' ,
284
- 'pgf.rcfonts' : False ,
285
- 'pgf.texsystem' : 'lualatex'
286
- }
287
- mpl .rcParams .update (rc_pdflatex )
288
-
289
- fig = plt .figure ()
290
- ax = fig .add_subplot (1 , 1 , 1 )
291
- ax .plot (range (5 ))
292
- fig .tight_layout ()
293
-
294
- md = {'Author' : 'me' , 'Title' : 'Multipage PDF with pgf' }
295
- path = os .path .join (result_dir , 'pdfpages_lua.pdf' )
296
- with PdfPages (path , metadata = md ) as pdf :
297
- pdf .savefig (fig )
298
- pdf .savefig (fig )
299
-
300
- assert pdf .get_pagecount () == 2
301
-
302
-
303
258
@needs_xelatex
304
259
def test_tex_restart_after_error ():
305
260
fig = plt .figure ()
0 commit comments