diff --git a/pygmt/figure.py b/pygmt/figure.py index 1f44e0b4ad8..f8b631e7102 100644 --- a/pygmt/figure.py +++ b/pygmt/figure.py @@ -306,7 +306,7 @@ def savefig( fname = Path(fname) prefix, suffix = fname.with_suffix("").as_posix(), fname.suffix - ext = suffix[1:] # Remove the . + ext = suffix[1:].lower() # Remove the . and normalize to lowercase # alias jpeg to jpg if ext == "jpeg": ext = "jpg" diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index d895c08785d..f01df85f942 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -83,11 +83,13 @@ def test_figure_savefig_exists(): fig = Figure() fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") prefix = "test_figure_savefig_exists" - for fmt in "png pdf jpg jpeg bmp eps tif".split(): + for fmt in "png pdf jpg jpeg bmp eps tif PNG JPG JPEG Png".split(): fname = ".".join([prefix, fmt]) fig.savefig(fname) - assert os.path.exists(fname) - os.remove(fname) + + fname = Path(fname) + assert fname.exists() + fname.unlink() def test_figure_savefig_directory_nonexists():