Skip to content

Commit d68a0cb

Browse files
committed
Fix some tests
1 parent 62041f0 commit d68a0cb

11 files changed

+23
-23
lines changed

pygmt/clib/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ def virtualfile_in( # noqa: PLR0912
18691869
valid_kinds += ("empty", "matrix", "vectors", "geojson")
18701870
if kind not in valid_kinds:
18711871
raise GMTTypeError(
1872-
type(data), reason="Unrecognized for {check_kind!r} kind."
1872+
type(data), reason=f"Unrecognized for {check_kind!r} kind."
18731873
)
18741874

18751875
# Decide which virtualfile_from_ function to use

pygmt/tests/test_blockm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import xarray as xr
1212
from pygmt import blockmean, blockmode
1313
from pygmt.datasets import load_sample_data
14-
from pygmt.exceptions import GMTInvalidInput
14+
from pygmt.exceptions import GMTTypeError
1515
from pygmt.helpers import GMTTempFile
1616

1717

@@ -68,7 +68,7 @@ def test_blockmean_wrong_kind_of_input_table_grid(dataframe):
6868
Run blockmean using table input that is not a pandas.DataFrame or file but a grid.
6969
"""
7070
invalid_table = dataframe.bathymetry.to_xarray()
71-
with pytest.raises(GMTInvalidInput):
71+
with pytest.raises(GMTTypeError):
7272
blockmean(data=invalid_table, spacing="5m", region=[245, 255, 20, 30])
7373

7474

pygmt/tests/test_blockmedian.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pytest
1010
from pygmt import blockmedian
1111
from pygmt.datasets import load_sample_data
12-
from pygmt.exceptions import GMTInvalidInput
12+
from pygmt.exceptions import GMTTypeError
1313
from pygmt.helpers import GMTTempFile
1414

1515

@@ -65,7 +65,7 @@ def test_blockmedian_wrong_kind_of_input_table_grid(dataframe):
6565
Run blockmedian using table input that is not a pandas.DataFrame or file but a grid.
6666
"""
6767
invalid_table = dataframe.bathymetry.to_xarray()
68-
with pytest.raises(GMTInvalidInput):
68+
with pytest.raises(GMTTypeError):
6969
blockmedian(data=invalid_table, spacing="5m", region=[245, 255, 20, 30])
7070

7171

pygmt/tests/test_clib_call_module.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88
from pygmt import Figure, clib
9-
from pygmt.exceptions import GMTCLibError, GMTInvalidInput
9+
from pygmt.exceptions import GMTCLibError, GMTTypeError
1010
from pygmt.helpers import GMTTempFile
1111

1212
POINTS_DATA = Path(__file__).parent / "data" / "points.txt"
@@ -53,7 +53,7 @@ def test_call_module_invalid_argument_type():
5353
call_module only accepts a string or a list of strings as module arguments.
5454
"""
5555
with clib.Session() as lib:
56-
with pytest.raises(GMTInvalidInput):
56+
with pytest.raises(GMTTypeError):
5757
lib.call_module("get", ("FONT_TITLE", "FONT_TAG"))
5858

5959

pygmt/tests/test_grd2cpt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import pytest
88
from pygmt import Figure, grd2cpt
9-
from pygmt.exceptions import GMTInvalidInput
9+
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
1010
from pygmt.helpers import GMTTempFile
1111
from pygmt.helpers.testing import load_static_earth_relief
1212

@@ -62,7 +62,7 @@ def test_grd2cpt_unrecognized_data_type():
6262
"""
6363
Test that an error will be raised if an invalid data type is passed to grid.
6464
"""
65-
with pytest.raises(GMTInvalidInput):
65+
with pytest.raises(GMTTypeError):
6666
grd2cpt(grid=0)
6767

6868

pygmt/tests/test_grdfilter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import xarray as xr
1010
from pygmt import grdfilter
1111
from pygmt.enums import GridRegistration, GridType
12-
from pygmt.exceptions import GMTInvalidInput
12+
from pygmt.exceptions import GMTTypeError
1313
from pygmt.helpers import GMTTempFile
1414
from pygmt.helpers.testing import load_static_earth_relief
1515

@@ -79,5 +79,5 @@ def test_grdfilter_fails():
7979
"""
8080
Check that grdfilter fails correctly.
8181
"""
82-
with pytest.raises(GMTInvalidInput):
82+
with pytest.raises(GMTTypeError):
8383
grdfilter(np.arange(10).reshape((5, 2)))

pygmt/tests/test_grdimage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pygmt.clib import __gmt_version__
1111
from pygmt.datasets import load_earth_relief
1212
from pygmt.enums import GridRegistration, GridType
13-
from pygmt.exceptions import GMTInvalidInput
13+
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
1414
from pygmt.helpers.testing import check_figures_equal
1515

1616

@@ -156,7 +156,7 @@ def test_grdimage_fails():
156156
Should fail for unrecognized input.
157157
"""
158158
fig = Figure()
159-
with pytest.raises(GMTInvalidInput):
159+
with pytest.raises(GMTTypeError):
160160
fig.grdimage(np.arange(20).reshape((4, 5)))
161161

162162

pygmt/tests/test_grdinfo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77
from pygmt import grdinfo
8-
from pygmt.exceptions import GMTInvalidInput
8+
from pygmt.exceptions import GMTTypeError
99
from pygmt.helpers.testing import load_static_earth_relief
1010

1111

@@ -30,7 +30,7 @@ def test_grdinfo_fails():
3030
"""
3131
Check that grdinfo fails correctly.
3232
"""
33-
with pytest.raises(GMTInvalidInput):
33+
with pytest.raises(GMTTypeError):
3434
grdinfo(np.arange(10).reshape((5, 2)))
3535

3636

pygmt/tests/test_grdtrack.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import pandas as pd
1010
import pytest
1111
from pygmt import grdtrack
12-
from pygmt.exceptions import GMTInvalidInput
12+
from pygmt.exceptions import GMTInvalidInput, GMTTypeError
1313
from pygmt.helpers import GMTTempFile
1414
from pygmt.helpers.testing import load_static_earth_relief
1515

@@ -129,7 +129,7 @@ def test_grdtrack_wrong_kind_of_points_input(dataarray, dataframe):
129129
Run grdtrack using points input that is not a pandas.DataFrame or file.
130130
"""
131131
invalid_points = dataframe.longitude.to_xarray()
132-
with pytest.raises(GMTInvalidInput):
132+
with pytest.raises(GMTTypeError):
133133
grdtrack(points=invalid_points, grid=dataarray, newcolname="bathymetry")
134134

135135

@@ -138,7 +138,7 @@ def test_grdtrack_wrong_kind_of_grid_input(dataarray, dataframe):
138138
Run grdtrack using grid input that is not an xarray.DataArray or file.
139139
"""
140140
invalid_grid = dataarray.to_dataset()
141-
with pytest.raises(GMTInvalidInput):
141+
with pytest.raises(GMTTypeError):
142142
grdtrack(points=dataframe, grid=invalid_grid, newcolname="bathymetry")
143143

144144

pygmt/tests/test_grdview.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
from pygmt import Figure, grdcut
7-
from pygmt.exceptions import GMTInvalidInput
7+
from pygmt.exceptions import GMTTypeError
88
from pygmt.helpers import GMTTempFile
99
from pygmt.helpers.testing import load_static_earth_relief
1010

@@ -59,7 +59,7 @@ def test_grdview_wrong_kind_of_grid(xrgrid):
5959
"""
6060
dataset = xrgrid.to_dataset() # convert xarray.DataArray to xarray.Dataset
6161
fig = Figure()
62-
with pytest.raises(GMTInvalidInput):
62+
with pytest.raises(GMTTypeError):
6363
fig.grdview(grid=dataset)
6464

6565

@@ -237,5 +237,5 @@ def test_grdview_wrong_kind_of_drapegrid(xrgrid):
237237
"""
238238
dataset = xrgrid.to_dataset() # convert xarray.DataArray to xarray.Dataset
239239
fig = Figure()
240-
with pytest.raises(GMTInvalidInput):
240+
with pytest.raises(GMTTypeError):
241241
fig.grdview(grid=xrgrid, drapegrid=dataset)

0 commit comments

Comments
 (0)