Skip to content

Commit 7ea264e

Browse files
committed
Add one test
1 parent 0045fa5 commit 7ea264e

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

pygmt/tests/test_figure.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import pytest
1212
from pygmt import Figure, set_display
1313
from pygmt.exceptions import GMTError, GMTInvalidInput
14-
from pygmt.figure import _get_default_display_method
14+
from pygmt.figure import SHOW_CONFIG, _get_default_display_method
1515
from pygmt.helpers import GMTTempFile
1616

1717
try:
@@ -373,12 +373,28 @@ def test_figure_display_external():
373373
fig.show(method="external")
374374

375375

376-
def test_figure_set_display_invalid():
376+
class TestSetDisplay:
377377
"""
378-
Test to check if an error is raised when an invalid method is passed to set_display.
378+
Test the pygmt.set_display method.
379379
"""
380-
with pytest.raises(GMTInvalidInput):
381-
set_display(method="invalid")
380+
381+
def test_set_display(self):
382+
"""
383+
Test pygmt.set_display.
384+
"""
385+
current_method = SHOW_CONFIG["method"]
386+
for method in ("notebook", "external", "none"):
387+
set_display(method=method)
388+
assert SHOW_CONFIG["method"] == method
389+
set_display(method=None)
390+
assert SHOW_CONFIG["method"] == current_method
391+
392+
def test_invalid_method(self):
393+
"""
394+
Test if an error is raised when an invalid method is passed.
395+
"""
396+
with pytest.raises(GMTInvalidInput):
397+
set_display(method="invalid")
382398

383399

384400
def test_figure_unsupported_xshift_yshift():

0 commit comments

Comments
 (0)