From a041b9cdc6ad0eba26d6333040333bf6ad87040a Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 28 Jan 2021 21:23:43 +0000 Subject: [PATCH] Add tests for GMTInvalidInput for figure.py (#810) * Add test for savefig invalid file extension * Add test for invalid show method passed --- pygmt/tests/test_figure.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pygmt/tests/test_figure.py b/pygmt/tests/test_figure.py index f4ef5e02ee6..99cb7d8e73e 100644 --- a/pygmt/tests/test_figure.py +++ b/pygmt/tests/test_figure.py @@ -65,6 +65,19 @@ def test_figure_savefig_exists(): os.remove(fname) +def test_figure_savefig_unknown_extension(): + """ + Check that an error is raised when an unknown extension is passed. + """ + fig = Figure() + fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") + prefix = "test_figure_savefig_unknown_extension" + fmt = "test" + fname = ".".join([prefix, fmt]) + with pytest.raises(GMTInvalidInput): + fig.savefig(fname) + + def test_figure_savefig_transparent(): """ Check if fails when transparency is not supported. @@ -150,3 +163,14 @@ def test_shift_origin(): fig.shift_origin(xshift="-4i", yshift="6i") fig.basemap(region="10/70/-300/300", projection="X3i/5i", frame="af") return fig + + +def test_figure_show_invalid_method(): + """ + Test to check if an error is raised when an invalid method is passed to + show. + """ + fig = Figure() + fig.basemap(region="10/70/-300/800", projection="X3i/5i", frame="af") + with pytest.raises(GMTInvalidInput): + fig.show(method="test")