Skip to content

Commit

Permalink
pygmt.show_versions: Add a test to check GMT-Ghostscript warnings (#3433
Browse files Browse the repository at this point in the history
)
  • Loading branch information
seisman authored Sep 12, 2024
1 parent 6c6bb43 commit be8c450
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions pygmt/tests/test_show_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,43 @@
import io

import pygmt
import pytest


def test_show_versions():
"""
Check that pygmt.show_versions() reports version information from PyGMT, the
operating system, dependencies and the GMT library.
Check that pygmt.show_versions reports version information of PyGMT, the operating
system, dependencies and the GMT library.
"""
buf = io.StringIO()
pygmt.show_versions(file=buf)
assert "PyGMT information:" in buf.getvalue()
assert "System information:" in buf.getvalue()
assert "Dependency information:" in buf.getvalue()
assert "GMT library information:" in buf.getvalue()
output = buf.getvalue()

assert "PyGMT information:" in output
assert "System information:" in output
assert "Dependency information:" in output
assert "GMT library information:" in output
assert "WARNING:" not in output # No GMT-Ghostscript incompatibility warnings.


@pytest.mark.parametrize(
("gs_version", "gmt_version"),
[
("9.52", "6.4.0"),
("10.01", "6.4.0"),
("10.02", "6.4.0"),
(None, "6.5.0"),
],
)
def test_show_versions_ghostscript_warnings(gs_version, gmt_version, monkeypatch):
"""
Check that pygmt.show_versions reports warnings for GMT-Ghostscript incompatibility.
"""
monkeypatch.setattr("pygmt._show_versions.__gmt_version__", gmt_version)
monkeypatch.setattr(
"pygmt._show_versions._get_ghostscript_version", lambda: gs_version
)

buf = io.StringIO()
pygmt.show_versions(file=buf)
assert "WARNING:" in buf.getvalue()

0 comments on commit be8c450

Please sign in to comment.