Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e0c9185

Browse 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

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/matplotlib/testing/conftest.py

Lines 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)