diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py index 95af04b9e40..d9127b82d3f 100644 --- a/xarray/tests/__init__.py +++ b/xarray/tests/__init__.py @@ -122,8 +122,8 @@ def assertWarns(self, message): with warnings.catch_warnings(record=True) as w: warnings.filterwarnings('always', message) yield - assert len(w) > 0 - assert any(message in str(wi.message) for wi in w) + assert len(w) > 0 + assert any(message in str(wi.message) for wi in w) def assertVariableEqual(self, v1, v2): assert_equal(v1, v2) diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index 1396f73ce76..d237ac11aa7 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -2321,7 +2321,7 @@ def test_to_dataset_whole(self): self.assertDatasetIdentical(expected, actual) expected = Dataset({'bar': ('x', [1, 2])}) - with self.assertWarns('order of the arguments'): + with pytest.warns(FutureWarning): actual = named.to_dataset('bar') self.assertDatasetIdentical(expected, actual) diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index f098a0aabb8..a889f2268e3 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -274,7 +274,7 @@ class Arbitrary(object): self.assertDatasetIdentical(expected, actual) def test_constructor_deprecated(self): - with self.assertWarns('deprecated'): + with pytest.warns(FutureWarning): DataArray([1, 2, 3], coords={'x': [0, 1, 2]}) def test_constructor_auto_align(self):