Skip to content

Commit

Permalink
Separate tests for gmtinfo and grdinfo (#461)
Browse files Browse the repository at this point in the history
Separate the tests of grdinfo into test_grdinfo.py
  • Loading branch information
seisman authored May 26, 2020
1 parent 52c2d13 commit 4bfebcd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
28 changes: 28 additions & 0 deletions pygmt/tests/test_grdinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Tests for grdinfo
"""
import numpy as np
import pytest

from .. import grdinfo
from ..datasets import load_earth_relief
from ..exceptions import GMTInvalidInput


def test_grdinfo():
"Make sure grd info works as expected"
grid = load_earth_relief()
result = grdinfo(grid, L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14453125 5558.79248047 1 1 361 181"


def test_grdinfo_file():
"Test grdinfo with file input"
result = grdinfo("@earth_relief_60m", L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14465255 5558.79248047 1 1 361 181"


def test_grdinfo_fails():
"Check that grdinfo fails correctly"
with pytest.raises(GMTInvalidInput):
grdinfo(np.arange(10).reshape((5, 2)))
22 changes: 1 addition & 21 deletions pygmt/tests/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import numpy as np
import pytest

from .. import info, grdinfo
from .. import info
from ..exceptions import GMTInvalidInput
from ..datasets import load_earth_relief

TEST_DATA_DIR = os.path.join(os.path.dirname(__file__), "data")
POINTS_DATA = os.path.join(TEST_DATA_DIR, "points.txt")
Expand Down Expand Up @@ -53,22 +52,3 @@ def test_info_fails():
info(fname=21)
with pytest.raises(GMTInvalidInput):
info(fname=np.arange(20))


def test_grdinfo():
"Make sure grd info works as expected"
grid = load_earth_relief()
result = grdinfo(grid, L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14453125 5558.79248047 1 1 361 181"


def test_grdinfo_file():
"Test grdinfo with file input"
result = grdinfo("@earth_relief_60m", L=0, C="n")
assert result.strip() == "-180 180 -90 90 -8592.14465255 5558.79248047 1 1 361 181"


def test_grdinfo_fails():
"Check that grdinfo fails correctly"
with pytest.raises(GMTInvalidInput):
grdinfo(np.arange(10).reshape((5, 2)))

0 comments on commit 4bfebcd

Please sign in to comment.