Skip to content

Commit fd9f102

Browse files
committed
TST: skip the nbagg test if we don't have IPython installed
1 parent 8271e61 commit fd9f102

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/matplotlib/tests/test_backend_webagg.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,17 @@
33
import pytest
44

55

6-
@pytest.mark.parametrize('backend', ['webagg', 'nbagg'])
6+
@pytest.mark.parametrize("backend", ["webagg", "nbagg"])
77
def test_webagg_fallback(backend):
8-
test_code = ("import os;" +
9-
f"os.environ['MPLBACKEND'] = '{backend}';" +
10-
"import matplotlib.pyplot as plt; " +
11-
"print(plt.get_backend());"
12-
f"assert '{backend}' == plt.get_backend().lower();")
8+
if backend == "nbagg":
9+
pytest.importorskip("IPython")
10+
test_code = (
11+
"import os;"
12+
+ f"os.environ['MPLBACKEND'] = '{backend}';"
13+
+ "import matplotlib.pyplot as plt; "
14+
+ "print(plt.get_backend());"
15+
f"assert '{backend}' == plt.get_backend().lower();"
16+
)
1317
ret = subprocess.call(
1418
[sys.executable, "-c", test_code],
1519
env={"MPLBACKEND": backend, "DISPLAY": ""}

0 commit comments

Comments
 (0)