@@ -214,48 +214,30 @@ def test_bbox_inches():
214214 tol = 0 )
215215
216216
217- @needs_pdflatex
218217@pytest .mark .style ('default' )
219218@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 ):
221225 rc_pdflatex = {
222226 'font.family' : 'serif' ,
223227 'pgf.rcfonts' : False ,
224- 'pgf.texsystem' : 'pdflatex' ,
228+ 'pgf.texsystem' : system ,
225229 }
226230 mpl .rcParams .update (rc_pdflatex )
227231
228- fig1 = plt .figure ()
229- ax1 = fig1 .add_subplot (1 , 1 , 1 )
232+ fig1 , ax1 = plt .subplots ()
230233 ax1 .plot (range (5 ))
231234 fig1 .tight_layout ()
232235
233- fig2 = plt .figure (figsize = (3 , 2 ))
234- ax2 = fig2 .add_subplot (1 , 1 , 1 )
236+ fig2 , ax2 = plt .subplots (figsize = (3 , 2 ))
235237 ax2 .plot (range (5 ))
236238 fig2 .tight_layout ()
237239
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' )
259241 md = {
260242 'Author' : 'me' ,
261243 'Title' : 'Multipage PDF with pgf' ,
@@ -265,41 +247,14 @@ def test_pdf_pages_metadata():
265247 'Trapped' : 'Unknown'
266248 }
267249
268- path = os .path .join (result_dir , 'pdfpages_meta.pdf' )
269-
270250 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 )
274254
275255 assert pdf .get_pagecount () == 3
276256
277257
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-
303258@needs_xelatex
304259def test_tex_restart_after_error ():
305260 fig = plt .figure ()
0 commit comments