Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e0c9185

Browse filesBrowse files
anntzertimhoffm
authored andcommitted
Don't fail tests if cairo dependency is not installed. (#12835)
* Don't fail tests if cairo dependency is not installed. * Only skip cairo import errors for testing
1 parent fe8468a commit e0c9185
Copy full SHA for e0c9185

File tree

Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-1
lines changed

‎lib/matplotlib/testing/conftest.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/conftest.py
+10-1Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ def mpl_test_settings(request):
4343
# This import must come after setup() so it doesn't load the
4444
# default backend prematurely.
4545
import matplotlib.pyplot as plt
46-
plt.switch_backend(backend)
46+
try:
47+
plt.switch_backend(backend)
48+
except ImportError as exc:
49+
# Should only occur for the cairo backend tests, if neither
50+
# pycairo nor cairocffi are installed.
51+
if 'cairo' in backend.lower():
52+
pytest.skip("Failed to switch to backend {} ({})."
53+
.format(backend, exc))
54+
else:
55+
raise
4756
with warnings.catch_warnings():
4857
warnings.simplefilter("ignore", MatplotlibDeprecationWarning)
4958
matplotlib.style.use(style)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.