Skip to content

Test test_missing.py without cftime installed #5556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jul 1, 2021
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