Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Session.call_module: Support passing a list of argument strings #3139

Merged
merged 11 commits into from
Mar 31, 2024
Prev Previous commit
Next Next commit
Add one more test to increase code coverage
  • Loading branch information
seisman committed Mar 26, 2024
commit fe84b29076b40f249e416990bdfd07290e06621d
2 changes: 2 additions & 0 deletions pygmt/clib/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,8 @@ def call_module(self, module: str, args: str | list[str]):

Raises
------
GMTInvalidInput
If the ``args`` argument is not a string or a list of strings.
GMTCLibError
If the returned status code of the function is non-zero.
"""
Expand Down
9 changes: 9 additions & 0 deletions pygmt/tests/test_clib.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ def test_call_module_empty_argument():
lib.call_module("defaults", [])


def test_call_module_invalid_argument_type():
"""
call_module only accepts a string or a list of strings as module arguments.
"""
with clib.Session() as lib:
with pytest.raises(GMTInvalidInput):
lib.call_module("get", ("FONT_TITLE", "FONT_TAG"))


def test_call_module_invalid_arguments():
"""
call_module should fail for invalid module arguments.
Expand Down