Skip to content

Commit 513fdf0

Browse files
committed
some more tests
1 parent b1815d4 commit 513fdf0

File tree

6 files changed

+30
-7
lines changed

6 files changed

+30
-7
lines changed

mplotutils/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,17 @@
4646

4747
try:
4848
__version__ = _get_version("mplotutils")
49-
except Exception:
49+
except Exception: # pragma: no cover
5050
# Local copy or not installed with setuptools.
5151
# Disable minimum version checks on downstream libraries.
5252
__version__ = "999"
5353

5454

55+
def empty_func_not_testted():
56+
57+
pass
58+
59+
5560
def __getattr__(attr):
5661

5762
m = (

mplotutils/_colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def colorbar(
237237
raise ValueError(msg)
238238

239239
if not all(isinstance(ax, mpl.axes.Axes) for ax in axs):
240-
raise TypeError("ax must be of Type mpl.axes.Axes")
240+
raise TypeError("ax must be of type mpl.axes.Axes")
241241

242242
f = axs[0].get_figure()
243243

mplotutils/tests/test_colorbar.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ def test_colorbar_deprecate_ax1():
144144
mpu.colorbar(h, ax1=ax)
145145

146146

147+
def test_colorbar_error_not_axes():
148+
149+
with pytest.raises(TypeError, match="ax must be of type mpl.axes.Axes"):
150+
mpu.colorbar(None, object())
151+
152+
with figure_context() as f:
153+
with pytest.raises(TypeError, match="ax must be of type mpl.axes.Axes"):
154+
mpu.colorbar(None, f)
155+
156+
147157
def test_colorbar_different_figures():
148158
with figure_context() as f1, figure_context() as f2:
149159
ax1 = f1.subplots()

mplotutils/tests/test_hatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_hatch_pattern(self):
5757

5858
h = self.function(da, "*", ax=ax)
5959
assert h.hatches == ["", "*"]
60-
h = self.function(da, "//", ax=ax)
60+
h = self.function(da, "//")
6161
assert h.hatches == ["", "//"]
6262

6363
def test_hatch_label(self):

mplotutils/tests/test_label_map.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ def test_works():
99
with subplots_context() as (f, ax):
1010
ylabel_map("ylabel", ax=ax)
1111
xlabel_map("ylabel", ax=ax)
12+
13+
ylabel_map("ylabel")
14+
xlabel_map("ylabel")

mplotutils/tests/test_mapticklabels.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import cartopy.crs as ccrs
22
import numpy as np
3+
import pytest
34

45
import mplotutils as mpu
56

67
from . import subplots_context
78

89

9-
def test_yticklabels_robinson():
10+
@pytest.mark.parametrize("pass_ax", (True, False))
11+
def test_yticklabels_robinson(pass_ax):
1012
with subplots_context(subplot_kw=dict(projection=ccrs.Robinson())) as (f, ax):
1113
ax.set_global()
1214

1315
lat = np.arange(-90, 91, 20)
1416

15-
mpu.yticklabels(lat, ax=ax, size=8)
17+
ax_ = ax if pass_ax else None
18+
mpu.yticklabels(lat, ax=ax_, size=8)
1619

1720
x_pos = -179.99
1821

@@ -26,14 +29,16 @@ def test_yticklabels_robinson():
2629
assert ax.texts[-1].get_text() == "70°N"
2730

2831

29-
def test_yticklabels_robinson_180():
32+
@pytest.mark.parametrize("pass_ax", (True, False))
33+
def test_yticklabels_robinson_180(pass_ax):
3034
proj = ccrs.Robinson(central_longitude=180)
3135
with subplots_context(subplot_kw=dict(projection=proj)) as (f, ax):
3236
ax.set_global()
3337

3438
lat = np.arange(-90, 91, 20)
3539

36-
mpu.yticklabels(lat, ax=ax, size=8)
40+
ax_ = ax if pass_ax else None
41+
mpu.yticklabels(lat, ax=ax_, size=8)
3742

3843
x_pos = 0.0
3944

0 commit comments

Comments
 (0)