Skip to content

Pytest capture uses match, not message #3011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ Bug fixes
By `Maximilian Roos <https://github.com/max-sixty>`_.
- Fixed performance issues with cftime installed (:issue:`3000`)
By `0x0L <https://github.com/0x0L>`_.
- Replace incorrect usages of `message` in pytest assertions
with `match` (:issue:`3011`)
By `Maximilian Roos <https://github.com/max-sixty>`_.

.. _whats-new.0.12.1:

Expand Down
4 changes: 2 additions & 2 deletions xarray/tests/test_dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def test_reset_coords(self):
dims=['x', 'y'], name='foo')
assert_identical(actual, expected)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
with raises_regex(ValueError, 'cannot reset coord'):
data = data.reset_coords(inplace=True)
with raises_regex(ValueError, 'cannot be found'):
Expand Down Expand Up @@ -1540,7 +1540,7 @@ def test_reorder_levels(self):
obj = self.mda.reorder_levels(x=['level_2', 'level_1'])
assert_identical(obj, expected)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
array = self.mda.copy()
array.reorder_levels(x=['level_2', 'level_1'], inplace=True)
assert_identical(array, expected)
Expand Down
10 changes: 5 additions & 5 deletions xarray/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2258,7 +2258,7 @@ def test_set_index(self):
obj = ds.set_index(x=mindex.names)
assert_identical(obj, expected)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
ds.set_index(x=mindex.names, inplace=True)
assert_identical(ds, expected)

Expand All @@ -2278,7 +2278,7 @@ def test_reset_index(self):
obj = ds.reset_index('x')
assert_identical(obj, expected)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
ds.reset_index('x', inplace=True)
assert_identical(ds, expected)

Expand All @@ -2291,7 +2291,7 @@ def test_reorder_levels(self):
reindexed = ds.reorder_levels(x=['level_2', 'level_1'])
assert_identical(reindexed, expected)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
ds.reorder_levels(x=['level_2', 'level_1'], inplace=True)
assert_identical(ds, expected)

Expand Down Expand Up @@ -2375,7 +2375,7 @@ def test_update(self):
assert actual_result is actual
assert_identical(expected, actual)

with pytest.warns(FutureWarning, message='The inplace argument'):
with pytest.warns(FutureWarning, match='The inplace argument'):
actual = data.update(data, inplace=False)
expected = data
assert actual is not expected
Expand Down Expand Up @@ -4615,7 +4615,7 @@ def test_dataset_constructor_aligns_to_explicit_coords(


def test_error_message_on_set_supplied():
with pytest.raises(TypeError, message='has invalid type set'):
with pytest.raises(TypeError, match="has invalid type <class 'set'>"):
xr.Dataset(dict(date=[1, 2, 3], sec={4}))


Expand Down
3 changes: 2 additions & 1 deletion xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ def test_2d_coords_line_plot(self):
hdl = da.plot.line(x='lon', hue='y')
assert len(hdl) == 4

with pytest.raises(ValueError, message='If x or y are 2D '):
with pytest.raises(
ValueError, match="For 2D inputs, hue must be a dimension"):
da.plot.line(x='lon', hue='lat')

def test_2d_before_squeeze(self):
Expand Down