Skip to content

Commit

Permalink
Add tests for GMTInvalidInput for figure.py (GenericMappingTools#810)
Browse files Browse the repository at this point in the history
* Add test for savefig invalid file extension
* Add test for invalid show method passed
  • Loading branch information
willschlitzer authored and Josh Sixsmith committed Dec 21, 2022
1 parent 590b59b commit a041b9c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")

0 comments on commit a041b9c

Please sign in to comment.