Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for GMTInvalidInput for figure.py #810

Merged
merged 2 commits into from
Jan 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")