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

Skip to content

Commit 673da5e

Browse files
committed
Changed the test to skip when IPython can't be imported and use _run_helper for the subprocess.
1 parent 5df766f commit 673da5e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

lib/matplotlib/tests/test_backends_interactive.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -536,16 +536,20 @@ def test_blitting_events(env):
536536
assert 0 < ndraws < 5
537537

538538

539+
def _fallback_check():
540+
import IPython.core.interactiveshell as ipsh
541+
import matplotlib.pyplot
542+
ipsh.InteractiveShell.instance()
543+
matplotlib.pyplot.figure()
544+
545+
539546
def test_fallback_to_different_backend():
547+
pytest.importorskip("IPython")
540548
import subprocess
541549
# Runs the process that caused the GH issue 23770
542550
# making sure that this doesn't crash
543551
# since we're supposed to be switching to a different backend instead.
544-
response = subprocess.run(["python", "-c",
545-
"import IPython.core.interactiveshell as ipsh; "
546-
"ipsh.InteractiveShell.instance(); "
547-
"import matplotlib.pyplot; "
548-
"matplotlib.pyplot.figure()"], check=True)
552+
response = _run_helper(_fallback_check, timeout=_test_timeout)
549553
assert response != subprocess.CalledProcessError
550554

551555

0 commit comments

Comments
 (0)