|
11 | 11 | import pytest |
12 | 12 | from pygmt import Figure, set_display |
13 | 13 | 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 |
15 | 15 | from pygmt.helpers import GMTTempFile |
16 | 16 |
|
17 | 17 | try: |
@@ -373,12 +373,28 @@ def test_figure_display_external(): |
373 | 373 | fig.show(method="external") |
374 | 374 |
|
375 | 375 |
|
376 | | -def test_figure_set_display_invalid(): |
| 376 | +class TestSetDisplay: |
377 | 377 | """ |
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. |
379 | 379 | """ |
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") |
382 | 398 |
|
383 | 399 |
|
384 | 400 | def test_figure_unsupported_xshift_yshift(): |
|
0 commit comments