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

Skip to content

Commit 196c8db

Browse files
committed
TST: Followup corrections to #28205
Make the changes suggested by @ianthomas23, and also mark the ipython tests as using their backend. While the backend is already checked for availability at the top of the respective files, that only checks whether it can be imported, not whether it can be set as the Matplotlib backend. Adding the marker causes our pytest configuration to actually check and skip the test if unavailable (e.g., on Linux without `(WAYLAND_)DISPLAY` set fails to set an interactive backend).
1 parent d8f3016 commit 196c8db

File tree

4 files changed

+5
-1
lines changed

4 files changed

+5
-1
lines changed

lib/matplotlib/testing/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,4 @@ def ipython_in_subprocess(requested_backend_or_gui_framework, all_expected_backe
210210
capture_output=True,
211211
)
212212

213-
assert proc.stdout.strip() == f"Out[1]: '{expected_backend}'"
213+
assert proc.stdout.strip().endswith(f"'{expected_backend}'")

lib/matplotlib/tests/test_backend_inline.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22
from pathlib import Path
33
from tempfile import TemporaryDirectory
4+
import sys
45

56
import pytest
67

@@ -12,6 +13,7 @@
1213
pytest.importorskip('matplotlib_inline')
1314

1415

16+
@pytest.mark.skipif(sys.version_info[:2] <= (3, 9), reason="Requires Python 3.10+")
1517
def test_ipynb():
1618
nb_path = Path(__file__).parent / 'test_inline_01.ipynb'
1719

lib/matplotlib/tests/test_backend_macosx.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def new_choose_save_file(title, directory, filename):
4646
assert mpl.rcParams["savefig.directory"] == f"{tmp_path}/test"
4747

4848

49+
@pytest.mark.backend('macosx')
4950
def test_ipython():
5051
from matplotlib.testing import ipython_in_subprocess
5152
ipython_in_subprocess("osx", {(8, 24): "macosx", (7, 0): "MacOSX"})

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ def custom_handler(signum, frame):
374374
signal.signal(signal.SIGINT, original_handler)
375375

376376

377+
@pytest.mark.backend('QtAgg', skip_on_importerror=True)
377378
def test_ipython():
378379
from matplotlib.testing import ipython_in_subprocess
379380
ipython_in_subprocess("qt", {(8, 24): "qtagg", (8, 15): "QtAgg", (7, 0): "Qt5Agg"})

0 commit comments

Comments
 (0)