From 5403a546bc522eac32814e0134f7a897c326a4aa Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Wed, 22 Jul 2020 14:37:41 -0400 Subject: [PATCH] Backport PR #17963: TST: Ignore deprecations when switching backends. --- lib/matplotlib/testing/conftest.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py index 563a9fc0fb66..391dd5d49d38 100644 --- a/lib/matplotlib/testing/conftest.py +++ b/lib/matplotlib/testing/conftest.py @@ -78,21 +78,21 @@ def mpl_test_settings(request): style, = style_marker.args matplotlib.testing.setup() - if backend is not None: - # This import must come after setup() so it doesn't load the - # default backend prematurely. - import matplotlib.pyplot as plt - try: - plt.switch_backend(backend) - except ImportError as exc: - # Should only occur for the cairo backend tests, if neither - # pycairo nor cairocffi are installed. - if 'cairo' in backend.lower() or skip_on_importerror: - pytest.skip("Failed to switch to backend {} ({})." - .format(backend, exc)) - else: - raise with cbook._suppress_matplotlib_deprecation_warning(): + if backend is not None: + # This import must come after setup() so it doesn't load the + # default backend prematurely. + import matplotlib.pyplot as plt + try: + plt.switch_backend(backend) + except ImportError as exc: + # Should only occur for the cairo backend tests, if neither + # pycairo nor cairocffi are installed. + if 'cairo' in backend.lower() or skip_on_importerror: + pytest.skip("Failed to switch to backend {} ({})." + .format(backend, exc)) + else: + raise matplotlib.style.use(style) try: yield