Skip to content

Commit

Permalink
Fix errors in the test suite due to pytest warning changes (#1423)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
shoyer authored May 24, 2017
1 parent f7eb309 commit 5007961
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions xarray/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,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)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -2322,7 +2322,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)

Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 5007961

Please sign in to comment.