Skip to content

Commit

Permalink
Add one test
Browse files Browse the repository at this point in the history
  • Loading branch information
seisman committed Aug 30, 2024
1 parent 0045fa5 commit 7ea264e
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions pygmt/tests/test_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import pytest
from pygmt import Figure, set_display
from pygmt.exceptions import GMTError, GMTInvalidInput
from pygmt.figure import _get_default_display_method
from pygmt.figure import SHOW_CONFIG, _get_default_display_method
from pygmt.helpers import GMTTempFile

try:
Expand Down Expand Up @@ -373,12 +373,28 @@ def test_figure_display_external():
fig.show(method="external")


def test_figure_set_display_invalid():
class TestSetDisplay:
"""
Test to check if an error is raised when an invalid method is passed to set_display.
Test the pygmt.set_display method.
"""
with pytest.raises(GMTInvalidInput):
set_display(method="invalid")

def test_set_display(self):
"""
Test pygmt.set_display.
"""
current_method = SHOW_CONFIG["method"]
for method in ("notebook", "external", "none"):
set_display(method=method)
assert SHOW_CONFIG["method"] == method
set_display(method=None)
assert SHOW_CONFIG["method"] == current_method

def test_invalid_method(self):
"""
Test if an error is raised when an invalid method is passed.
"""
with pytest.raises(GMTInvalidInput):
set_display(method="invalid")


def test_figure_unsupported_xshift_yshift():
Expand Down

0 comments on commit 7ea264e

Please sign in to comment.