Skip to content
Merged
12 changes: 12 additions & 0 deletions xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,15 @@ def create_test_data(seed=None, add_attrs=True):
obj.encoding = {"foo": "bar"}
assert all(obj.data.flags.writeable for obj in obj.variables.values())
return obj


_CFTIME_CALENDARS = [
"365_day",
"360_day",
"julian",
"all_leap",
"366_day",
"gregorian",
"proleptic_gregorian",
"standard",
]
13 changes: 1 addition & 12 deletions xarray/tests/test_cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,11 @@
to_cftime_datetime,
to_offset,
)
from xarray.tests import _CFTIME_CALENDARS

cftime = pytest.importorskip("cftime")


_CFTIME_CALENDARS = [
"365_day",
"360_day",
"julian",
"all_leap",
"366_day",
"gregorian",
"proleptic_gregorian",
"standard",
]


def _id_func(param):
"""Called on each parameter passed to pytest.mark.parametrize"""
return str(param)
Expand Down
8 changes: 6 additions & 2 deletions xarray/tests/test_missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
)
from xarray.core.pycompat import dask_array_type
from xarray.tests import (
_CFTIME_CALENDARS,
assert_allclose,
assert_array_equal,
assert_equal,
Expand All @@ -23,7 +24,6 @@
requires_dask,
requires_scipy,
)
from xarray.tests.test_cftime_offsets import _CFTIME_CALENDARS


@pytest.fixture
Expand Down Expand Up @@ -542,6 +542,7 @@ def test_get_clean_interp_index_dt(cf_da, calendar, freq):
np.testing.assert_array_equal(gi, si)


@requires_cftime
def test_get_clean_interp_index_potential_overflow():
da = xr.DataArray(
[0, 1, 2],
Expand Down Expand Up @@ -592,7 +593,10 @@ def test_interpolate_na_max_gap_errors(da_time):


@requires_bottleneck
@pytest.mark.parametrize("time_range_func", [pd.date_range, xr.cftime_range])
@pytest.mark.parametrize(
"time_range_func",
[pd.date_range, pytest.param(xr.cftime_range, marks=requires_cftime)],
)
@pytest.mark.parametrize("transform", [lambda x: x, lambda x: x.to_dataset(name="a")])
@pytest.mark.parametrize(
"max_gap", ["3H", np.timedelta64(3, "h"), pd.to_timedelta("3H")]
Expand Down