diff --git a/doc/whats-new.rst b/doc/whats-new.rst index ccc323c0c02..b33cb992874 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -120,12 +120,9 @@ Bug fixes By `Maximilian Roos `_. - Fixed performance issues with cftime installed (:issue:`3000`) By `0x0L `_. -- Replace incorrect usages of `message` in pytest assertions - with `match` (:issue:`3011`) - By `Maximilian Roos `_. -- Add explicit pytest markers, now required by pytest - (:issue:`3032`). - By `Maximilian Roos `_. +- Test suite fixes for newer versions of pytest (:issue:`3011`, :issue:`3032`). + By `Maximilian Roos `_ + and `Stephan Hoyer `_. .. _whats-new.0.12.1: diff --git a/xarray/tests/test_dataarray.py b/xarray/tests/test_dataarray.py index b0ea2cd5cc6..5c81c843d00 100644 --- a/xarray/tests/test_dataarray.py +++ b/xarray/tests/test_dataarray.py @@ -3710,15 +3710,14 @@ def test_rolling_properties(da): assert rolling_obj.obj.get_axis_num('time') == 1 # catching invalid args - with pytest.raises(ValueError) as exception: + with pytest.raises(ValueError, match='exactly one dim/window should'): da.rolling(time=7, x=2) - assert 'exactly one dim/window should' in str(exception) - with pytest.raises(ValueError) as exception: + with pytest.raises(ValueError, match='window must be > 0'): da.rolling(time=-2) - assert 'window must be > 0' in str(exception) - with pytest.raises(ValueError) as exception: + with pytest.raises( + ValueError, match='min_periods must be greater than zero' + ): da.rolling(time=2, min_periods=0) - assert 'min_periods must be greater than zero' in str(exception) @pytest.mark.parametrize('name', ('sum', 'mean', 'std', 'min', 'max', diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 1265f6a337a..7b3ae88608b 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -4788,18 +4788,16 @@ def test_coarsen_coords_cftime(): def test_rolling_properties(ds): # catching invalid args - with pytest.raises(ValueError) as exception: + with pytest.raises(ValueError, match='exactly one dim/window should'): ds.rolling(time=7, x=2) - assert 'exactly one dim/window should' in str(exception) - with pytest.raises(ValueError) as exception: + with pytest.raises(ValueError, match='window must be > 0'): ds.rolling(time=-2) - assert 'window must be > 0' in str(exception) - with pytest.raises(ValueError) as exception: + with pytest.raises( + ValueError, match='min_periods must be greater than zero' + ): ds.rolling(time=2, min_periods=0) - assert 'min_periods must be greater than zero' in str(exception) - with pytest.raises(KeyError) as exception: + with pytest.raises(KeyError, match='time2'): ds.rolling(time2=2) - assert 'time2' in str(exception) @pytest.mark.parametrize('name',