Skip to content

Commit 182bc0b

Browse files
committed
TST: Prepare for pytest 9
The current version of pytest is warning that using `importorskip` to catch `ImportError` will start being ignored (and thus raising) with pytest 9. Fortunately, in all cases, we don't need these calls, as they are: - already checked for `ImportError` at the top-level of the file - already checked by the backend switcher - not actually possible to fail importing
1 parent a4243d9 commit 182bc0b

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

lib/matplotlib/tests/test_backend_bases.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import importlib
2+
13
from matplotlib import path, transforms
24
from matplotlib.backend_bases import (
35
FigureCanvasBase, KeyEvent, LocationEvent, MouseButton, MouseEvent,
@@ -325,9 +327,7 @@ def test_toolbar_home_restores_autoscale():
325327
def test_draw(backend):
326328
from matplotlib.figure import Figure
327329
from matplotlib.backends.backend_agg import FigureCanvas
328-
test_backend = pytest.importorskip(
329-
f'matplotlib.backends.backend_{backend}'
330-
)
330+
test_backend = importlib.import_module(f'matplotlib.backends.backend_{backend}')
331331
TestCanvas = test_backend.FigureCanvas
332332
fig_test = Figure(constrained_layout=True)
333333
TestCanvas(fig_test)

lib/matplotlib/tests/test_backend_gtk3.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
import pytest
44

55

6-
pytest.importorskip("matplotlib.backends.backend_gtk3agg")
7-
8-
96
@pytest.mark.backend("gtk3agg", skip_on_importerror=True)
107
def test_correct_key():
118
pytest.xfail("test_widget_send_event is not triggering key_press_event")

lib/matplotlib/tests/test_backend_qt.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
@pytest.fixture
2828
def qt_core(request):
29-
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
30-
QtCore = qt_compat.QtCore
31-
29+
from matplotlib.backends.qt_compat import QtCore
3230
return QtCore
3331

3432

0 commit comments

Comments
 (0)