-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow printing show_versions() to in-memory buffer to enable testing (#…
…2399) To increase code coverage of `__init__.py`, check the output of `pygmt.show_versions()` that is printed to an in-memory string buffer instead of stdout. Adapted from https://github.com/xarray-contrib/xbatcher/blob/v0.2.0/xbatcher/tests/test_print_versions.py
- Loading branch information
Showing
2 changed files
with
31 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
Test functions in __init__. | ||
""" | ||
import io | ||
|
||
import pygmt | ||
|
||
|
||
def test_show_versions(): | ||
""" | ||
Check that pygmt.show_versions() reports version information from 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() |