Skip to content

Commit be8c450

Browse files
authored
pygmt.show_versions: Add a test to check GMT-Ghostscript warnings (#3433)
1 parent 6c6bb43 commit be8c450

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

pygmt/tests/test_show_versions.py

+33-6
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,43 @@
55
import io
66

77
import pygmt
8+
import pytest
89

910

1011
def test_show_versions():
1112
"""
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.
1415
"""
1516
buf = io.StringIO()
1617
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

Comments
 (0)