From 529d26f66b0d01f5a07ba880f04a21951175e78b Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 7 Oct 2022 00:49:30 -0400 Subject: [PATCH] Add exception class to pytest.warns calls This is failing on current pytest. --- lib/matplotlib/tests/test_axes.py | 6 ++++-- lib/matplotlib/tests/test_colors.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 02fcf233e542..dd609a9e040d 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -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 diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index f0c23038e11a..6d618c1b847c 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -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! @@ -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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy