54 lines
2.0 KiB
Diff
54 lines
2.0 KiB
Diff
From 67c0d933d5860088ec905a2491e952560f37e476 Mon Sep 17 00:00:00 2001
|
|
From: Spencer Clark <spencerkclark@gmail.com>
|
|
Date: Fri, 3 Apr 2020 08:03:07 -0400
|
|
Subject: [PATCH] Only fail if a specific warning occurs
|
|
|
|
---
|
|
xarray/tests/test_backends.py | 12 +++++++++---
|
|
1 file changed, 9 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/xarray/tests/test_backends.py b/xarray/tests/test_backends.py
|
|
index 82fe1b3814..b26a3b37fc 100644
|
|
--- a/xarray/tests/test_backends.py
|
|
+++ b/xarray/tests/test_backends.py
|
|
@@ -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):
|
|
@@ -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
|
|
@@ -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
|
|
@@ -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
|