Skip to content
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

Only fail certain use_cftime backend tests if a specific warning occurs #3930

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -4334,6 +4334,12 @@ def test_source_encoding_always_present():
assert ds.encoding["source"] == tmp


def _assert_no_dates_out_of_range_warning(record):
undesired_message = "dates out of range"
for warning in record:
assert undesired_message not in str(warning.message)


@requires_scipy_or_netCDF4
@pytest.mark.parametrize("calendar", _STANDARD_CALENDARS)
def test_use_cftime_standard_calendar_default_in_range(calendar):
Expand All @@ -4360,7 +4366,7 @@ def test_use_cftime_standard_calendar_default_in_range(calendar):
with open_dataset(tmp_file) as ds:
assert_identical(expected_x, ds.x)
assert_identical(expected_time, ds.time)
assert not record
_assert_no_dates_out_of_range_warning(record)


@requires_cftime
Expand Down Expand Up @@ -4423,7 +4429,7 @@ def test_use_cftime_true(calendar, units_year):
with open_dataset(tmp_file, use_cftime=True) as ds:
assert_identical(expected_x, ds.x)
assert_identical(expected_time, ds.time)
assert not record
_assert_no_dates_out_of_range_warning(record)


@requires_scipy_or_netCDF4
Expand Down Expand Up @@ -4452,7 +4458,7 @@ def test_use_cftime_false_standard_calendar_in_range(calendar):
with open_dataset(tmp_file, use_cftime=False) as ds:
assert_identical(expected_x, ds.x)
assert_identical(expected_time, ds.time)
assert not record
_assert_no_dates_out_of_range_warning(record)


@requires_scipy_or_netCDF4
Expand Down