8000 TST: Ignore deprecations when switching backends. · matplotlib/matplotlib@8bd12db · GitHub
[go: up one dir, main page]

Skip to content

Commit 8bd12db

Browse files
committed
TST: Ignore deprecations when switching backends.
Otherwise, stuff like Qt4 backend cannot be tested because the deprecation warning will cause a failure.
1 parent 4723dab commit 8bd12db

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/matplotlib/testing/conftest.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,21 @@ def mpl_test_settings(request):
7878
style, = style_marker.args
7979

8080
matplotlib.testing.setup()
81-
if backend is not None:
82-
# This import must come after setup() so it doesn't load the
83-
# default backend prematurely.
84-
import matplotlib.pyplot as plt
85-
try:
86-
plt.switch_backend(backend)
87-
except ImportError as exc:
88-
# Should only occur for the cairo backend tests, if neither
89-
# pycairo nor cairocffi are installed.
90-
if 'cairo' in backend.lower() or skip_on_importerror:
91-
pytest.skip("Failed to switch to backend {} ({})."
92-
.format(backend, exc))
93-
else:
94-
raise
9581
with cbook._suppress_matplotlib_deprecation_warning():
82+
if backend is not None:
83+
# This import must come after setup() so it doesn't load the
84+
# default backend prematurely.
85+
import matplotlib.pyplot as plt
86+
try:
87+
plt.switch_backend(backend)
88+
except ImportError as exc:
89+
# Should only occur for the cairo backend tests, if neither
90+
# pycairo nor cairocffi are installed.
91+
if 'cairo' in backend.lower() or skip_on_importerror:
92+
pytest.skip("Failed to switch to backend {} ({})."
93+
.format(backend, exc))
94+
else:
95+
raise
9696
matplotlib.style.use(style)
9797
try:
9898
yield

0 commit comments

Comments
 (0)
0