Skip to content

Commit

Permalink
TST: Followup corrections to matplotlib#28205
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
QuLogic committed May 10, 2024
1 parent 72c62b5 commit 569505a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/matplotlib/testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ def ipython_in_subprocess(requested_backend_or_gui_framework, all_expected_backe
capture_output=True,
)

assert proc.stdout.strip() == f"Out[1]: '{expected_backend}'"
assert proc.stdout.strip().endswith(f"'{expected_backend}'")
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_inline.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from pathlib import Path
from tempfile import TemporaryDirectory
import sys

import pytest

Expand All @@ -12,6 +13,7 @@
pytest.importorskip('matplotlib_inline')


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

Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def new_choose_save_file(title, directory, filename):
assert mpl.rcParams["savefig.directory"] == f"{tmp_path}/test"


@pytest.mark.backend('macosx')
def test_ipython():
from matplotlib.testing import ipython_in_subprocess
ipython_in_subprocess("osx", {(8, 24): "macosx", (7, 0): "MacOSX"})
1 change: 1 addition & 0 deletions lib/matplotlib/tests/test_backend_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def custom_handler(signum, frame):
signal.signal(signal.SIGINT, original_handler)


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

0 comments on commit 569505a

Please sign in to comment.