Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ test:
coverage:
# Run a tmp folder to make sure the tests are run on the installed version
mkdir -p $(TESTDIR)
cd $(TESTDIR); python -c "import gmt; gmt.print_libgmt_info()"
@echo ""
cd $(TESTDIR); pytest $(PYTEST_COV_ARGS) --cov=gmt $(PYTEST_ARGS) gmt
cp $(TESTDIR)/.coverage* .
rm -r $(TESTDIR)
Expand Down
26 changes: 26 additions & 0 deletions gmt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,29 @@
_atexit.register(_end)


def print_libgmt_info():
"""
Print information about the currently loaded GMT shared library.

Includes the GMT version, default values for parameters, the path to the
``libgmt`` shared library, and GMT directories.
"""
import shutil
from .clib import LibGMT

columns = shutil.get_terminal_size().columns
title = "Currently loaded libgmt"
left = (columns - len(title) - 2)//2
right = left + (columns - (2*left + len(title) + 2))
header = ' '.join(['='*left, title, '='*right])

with LibGMT() as lib:
lines = [header]
for key in sorted(lib.info):
lines.append('{}: {}'.format(key, lib.info[key]))
print('\n'.join(lines))


def test(doctest=True, verbose=True, coverage=False, figures=True):
"""
Run the test suite.
Expand Down Expand Up @@ -62,6 +85,9 @@ def test(doctest=True, verbose=True, coverage=False, figures=True):

"""
import pytest

print_libgmt_info()

args = []
if verbose:
args.append('-vv')
Expand Down