Skip to content

Commit

Permalink
Add exception class to pytest.warns calls
Browse files Browse the repository at this point in the history
This is failing on current pytest.
  • Loading branch information
QuLogic committed Oct 7, 2022
1 parent 91093a2 commit 960e49e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -491,13 +491,13 @@ def test_subclass_clear_cla():
# Note, we cannot use mocking here as we want to be sure that the
# superclass fallback does not recurse.

with pytest.warns(match='Overriding `Axes.cla`'):
with pytest.warns(PendingDeprecationWarning, match='Overriding `Axes.cla`'):
class ClaAxes(Axes):
def cla(self):
nonlocal called
called = True

with pytest.warns(match='Overriding `Axes.cla`'):
with pytest.warns(PendingDeprecationWarning, match='Overriding `Axes.cla`'):
class ClaSuperAxes(Axes):
def cla(self):
nonlocal called
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/tests/test_colors.py
Expand Up @@ -117,7 +117,7 @@ def test_double_register_builtin_cmap():
mpl.colormaps[name], name=name, force=True
)
with pytest.raises(ValueError, match='A colormap named "viridis"'):
with pytest.warns():
with pytest.warns(PendingDeprecationWarning):
cm.register_cmap(name, mpl.colormaps[name])
with pytest.warns(UserWarning):
# TODO is warning more than once!
Expand All @@ -128,7 +128,7 @@ def test_unregister_builtin_cmap():
name = "viridis"
match = f'cannot unregister {name!r} which is a builtin colormap.'
with pytest.raises(ValueError, match=match):
with pytest.warns():
with pytest.warns(PendingDeprecationWarning):
cm.unregister_cmap(name)


Expand Down

0 comments on commit 960e49e

Please sign in to comment.