|
5 | 5 | import io
|
6 | 6 |
|
7 | 7 | import pygmt
|
| 8 | +import pytest |
8 | 9 |
|
9 | 10 |
|
10 | 11 | def test_show_versions():
|
11 | 12 | """
|
12 |
| - Check that pygmt.show_versions() reports version information from PyGMT, the |
13 |
| - operating system, dependencies and the GMT library. |
| 13 | + Check that pygmt.show_versions reports version information of PyGMT, the operating |
| 14 | + system, dependencies and the GMT library. |
14 | 15 | """
|
15 | 16 | buf = io.StringIO()
|
16 | 17 | pygmt.show_versions(file=buf)
|
17 |
| - assert "PyGMT information:" in buf.getvalue() |
18 |
| - assert "System information:" in buf.getvalue() |
19 |
| - assert "Dependency information:" in buf.getvalue() |
20 |
| - assert "GMT library information:" in buf.getvalue() |
| 18 | + output = buf.getvalue() |
| 19 | + |
| 20 | + assert "PyGMT information:" in output |
| 21 | + assert "System information:" in output |
| 22 | + assert "Dependency information:" in output |
| 23 | + assert "GMT library information:" in output |
| 24 | + assert "WARNING:" not in output # No GMT-Ghostscript incompatibility warnings. |
| 25 | + |
| 26 | + |
| 27 | +@pytest.mark.parametrize( |
| 28 | + ("gs_version", "gmt_version"), |
| 29 | + [ |
| 30 | + ("9.52", "6.4.0"), |
| 31 | + ("10.01", "6.4.0"), |
| 32 | + ("10.02", "6.4.0"), |
| 33 | + (None, "6.5.0"), |
| 34 | + ], |
| 35 | +) |
| 36 | +def test_show_versions_ghostscript_warnings(gs_version, gmt_version, monkeypatch): |
| 37 | + """ |
| 38 | + Check that pygmt.show_versions reports warnings for GMT-Ghostscript incompatibility. |
| 39 | + """ |
| 40 | + monkeypatch.setattr("pygmt._show_versions.__gmt_version__", gmt_version) |
| 41 | + monkeypatch.setattr( |
| 42 | + "pygmt._show_versions._get_ghostscript_version", lambda: gs_version |
| 43 | + ) |
| 44 | + |
| 45 | + buf = io.StringIO() |
| 46 | + pygmt.show_versions(file=buf) |
| 47 | + assert "WARNING:" in buf.getvalue() |
0 commit comments