Skip to content
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

Add exception class to pytest.warns calls #24113

Merged
merged 1 commit into from Oct 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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