Skip to content

Commit

Permalink
Merge pull request #24113 from QuLogic/warn-types
Browse files Browse the repository at this point in the history
Add exception class to pytest.warns calls
  • Loading branch information
timhoffm committed Oct 7, 2022
2 parents 6f137b9 + 529d26f commit 4965500
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_axes.py
Expand Up @@ -491,13 +491,15 @@ 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 4965500

Please sign in to comment.