Skip to content

Commit 5007961

Browse files
authored
Fix errors in the test suite due to pytest warning changes (#1423)
* Fix errors in the test suite due to pytest warning changes This is causing CI failures for some builds. This is really a pytest bug (pytest-dev/pytest#2430), but working around this on our end is easy enough (and cleans things up a little). * deprecated_call() -> warns(FutureWarning) * another attempt
1 parent f7eb309 commit 5007961

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

xarray/tests/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ def assertWarns(self, message):
128128
with warnings.catch_warnings(record=True) as w:
129129
warnings.filterwarnings('always', message)
130130
yield
131-
assert len(w) > 0
132-
assert any(message in str(wi.message) for wi in w)
131+
assert len(w) > 0
132+
assert any(message in str(wi.message) for wi in w)
133133

134134
def assertVariableEqual(self, v1, v2):
135135
assert_equal(v1, v2)

xarray/tests/test_dataarray.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2322,7 +2322,7 @@ def test_to_dataset_whole(self):
23222322
self.assertDatasetIdentical(expected, actual)
23232323

23242324
expected = Dataset({'bar': ('x', [1, 2])})
2325-
with self.assertWarns('order of the arguments'):
2325+
with pytest.warns(FutureWarning):
23262326
actual = named.to_dataset('bar')
23272327
self.assertDatasetIdentical(expected, actual)
23282328

xarray/tests/test_dataset.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ class Arbitrary(object):
274274
self.assertDatasetIdentical(expected, actual)
275275

276276
def test_constructor_deprecated(self):
277-
with self.assertWarns('deprecated'):
277+
with pytest.warns(FutureWarning):
278278
DataArray([1, 2, 3], coords={'x': [0, 1, 2]})
279279

280280
def test_constructor_auto_align(self):

0 commit comments

Comments
 (0)