Skip to content

Commit 981d89e

Browse files
committed
Require netCDF4 for test
1 parent 1f5ef7d commit 981d89e

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

xarray/tests/test_coding_strings.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
from xarray.coding import strings
99
from xarray.core import indexing
1010

11-
from . import IndexerMaker, assert_array_equal, assert_identical, requires_dask
11+
from . import (
12+
IndexerMaker,
13+
assert_array_equal,
14+
assert_identical,
15+
requires_dask,
16+
requires_netCDF4,
17+
)
1218

1319
with suppress(ImportError):
1420
import dask.array as da
@@ -30,19 +36,20 @@ def test_vlen_dtype():
3036
assert strings.check_vlen_dtype(np.dtype(object)) is None
3137

3238

33-
@pytest.mark.parametrize("numpy_str_type", (np.str, np.str_))
34-
def test_numpy_str_handling(numpy_str_type):
35-
dtype = strings.create_vlen_dtype(numpy_str_type)
36-
assert dtype.metadata["element_type"] == numpy_str_type
39+
@pytest.mark.parametrize("str_type", (str, np.str_))
40+
def test_numpy_str_handling(str_type):
41+
dtype = strings.create_vlen_dtype(str_type)
42+
assert dtype.metadata["element_type"] == str_type
3743
assert strings.is_unicode_dtype(dtype)
3844
assert not strings.is_bytes_dtype(dtype)
39-
assert strings.check_vlen_dtype(dtype) is numpy_str_type
45+
assert strings.check_vlen_dtype(dtype) is str_type
4046

4147

42-
@pytest.mark.parametrize("numpy_str_type", (np.str, np.str_))
43-
def test_write_file_from_np_str(numpy_str_type):
48+
@requires_netCDF4
49+
@pytest.mark.parametrize("str_type", (str, np.str_))
50+
def test_write_file_from_np_str(str_type):
4451
# should be moved elsewhere probably
45-
scenarios = [numpy_str_type(v) for v in ["scenario_a", "scenario_b", "scenario_c"]]
52+
scenarios = [str_type(v) for v in ["scenario_a", "scenario_b", "scenario_c"]]
4653
years = range(2015, 2100 + 1)
4754
tdf = pd.DataFrame(
4855
data=np.random.random((len(scenarios), len(years))),

0 commit comments

Comments
 (0)