Backport patch to fix tests catching too many warnings.

This commit is contained in:
Elliott Sales de Andrade
2020-06-23 04:32:16 -04:00
parent e8852ff34b
commit 92222176fe
2 changed files with 59 additions and 2 deletions
+53
View File
@@ -0,0 +1,53 @@
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
+6 -2
View File
@@ -20,6 +20,8 @@ Patch0002: 0002-DOC-Skip-examples-using-unpackaged-dependencies.patch
Patch0003: 0003-DOC-Don-t-print-out-conda-pip-environment.patch
# https://github.com/pydata/xarray/pull/3274
Patch0004: 0004-Use-drawstyle-instead-of-linestyle-in-plot.step.patch
# https://github.com/pydata/xarray/pull/3930
Patch0005: https://github.com/pydata/xarray/pull/3930.patch
BuildArch: noarch
@@ -117,8 +119,7 @@ popd
%check
rm -rf xarray
PYTHONPATH=%{buildroot}%{python3_sitelib} \
pytest-3 -ra -n auto -m "not network" --pyargs xarray
%{pytest} -ra -n auto -m "not network" --pyargs xarray
%files -n python3-%{srcname}
@@ -135,6 +136,9 @@ PYTHONPATH=%{buildroot}%{python3_sitelib} \
%changelog
* Tue Jun 23 2020 Elliott Sales de Andrade <quantum.analyst@gmail.com> - 0.15.1-3
- Backport patch to fix tests catching too many warnings
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.15.1-3
- Rebuilt for Python 3.9