@@ -292,31 +292,25 @@ def mock_psconvert(*args, **kwargs): # pylint: disable=unused-argument
292292 }
293293
294294
295- @pytest .mark .parametrize ("fmt" , [".bmp" , ".jpg" , ".pdf" , ".png" , ".tif" ])
296295def test_figure_savefig_worldfile (fmt ):
297296 """
298- Check if a world file is created when requested.
297+ Check if a world file is created when supported and raise an error when not
298+ supported.
299299 """
300300 fig = Figure ()
301301 fig .basemap (region = [0 , 1 , 0 , 1 ], projection = "X1c/1c" , frame = True )
302- with GMTTempFile (prefix = "pygmt-worldfile" , suffix = fmt ) as imgfile :
303- fig .savefig (fname = imgfile .name , worldfile = True )
304- assert Path (imgfile .name ).stat ().st_size > 0
305- worldfile_suffix = "." + fmt [1 ] + fmt [3 ] + "w"
306- assert Path (imgfile .name ).with_suffix (worldfile_suffix ).stat ().st_size > 0
307-
308-
309- @pytest .mark .parametrize ("fmt" , [".tiff" , ".kml" ])
310- def test_figure_savefig_worldfile_unsupported_format (fmt ):
311- """
312- Figure.savefig should raise an error when a world file is requested for an
313- unsupported format.
314- """
315- fig = Figure ()
316- fig .basemap (region = [0 , 1 , 0 , 1 ], projection = "X1c/1c" , frame = True )
317- with GMTTempFile (prefix = "pygmt-worldfile" , suffix = fmt ) as imgfile :
318- with pytest .raises (GMTInvalidInput ):
302+ # supported formats
303+ for fmt in [".bmp" , ".jpg" , ".png" , ".tif" ]:
304+ with GMTTempFile (prefix = "pygmt-worldfile" , suffix = fmt ) as imgfile :
319305 fig .savefig (fname = imgfile .name , worldfile = True )
306+ assert Path (imgfile .name ).stat ().st_size > 0
307+ worldfile_suffix = "." + fmt [1 ] + fmt [3 ] + "w"
308+ assert Path (imgfile .name ).with_suffix (worldfile_suffix ).stat ().st_size > 0
309+ # unsupported formats
310+ for fmt in [".eps" , ".kml" , ".pdf" , ".tiff" ]:
311+ with GMTTempFile (prefix = "pygmt-worldfile" , suffix = fmt ) as imgfile :
312+ with pytest .raises (GMTInvalidInput ):
313+ fig .savefig (fname = imgfile .name , worldfile = True )
320314
321315
322316@pytest .mark .skipif (IPython is None , reason = "run when IPython is installed" )
0 commit comments