Skip to content

Commit

Permalink
TST: Prepare for pytest 9
Browse files Browse the repository at this point in the history
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
  • Loading branch information
QuLogic committed May 9, 2024
1 parent a4243d9 commit 182bc0b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
6 changes: 3 additions & 3 deletions lib/matplotlib/tests/test_backend_bases.py
@@ -1,3 +1,5 @@
import importlib

from matplotlib import path, transforms
from matplotlib.backend_bases import (
FigureCanvasBase, KeyEvent, LocationEvent, MouseButton, MouseEvent,
Expand Down Expand Up @@ -325,9 +327,7 @@ def test_toolbar_home_restores_autoscale():
def test_draw(backend):
from matplotlib.figure import Figure
from matplotlib.backends.backend_agg import FigureCanvas
test_backend = pytest.importorskip(
f'matplotlib.backends.backend_{backend}'
)
test_backend = importlib.import_module(f'matplotlib.backends.backend_{backend}')
TestCanvas = test_backend.FigureCanvas
fig_test = Figure(constrained_layout=True)
TestCanvas(fig_test)
Expand Down
3 changes: 0 additions & 3 deletions lib/matplotlib/tests/test_backend_gtk3.py
Expand Up @@ -3,9 +3,6 @@
import pytest


pytest.importorskip("matplotlib.backends.backend_gtk3agg")


@pytest.mark.backend("gtk3agg", skip_on_importerror=True)
def test_correct_key():
pytest.xfail("test_widget_send_event is not triggering key_press_event")
Expand Down
4 changes: 1 addition & 3 deletions lib/matplotlib/tests/test_backend_qt.py
Expand Up @@ -26,9 +26,7 @@

@pytest.fixture
def qt_core(request):
qt_compat = pytest.importorskip('matplotlib.backends.qt_compat')
QtCore = qt_compat.QtCore

from matplotlib.backends.qt_compat import QtCore
return QtCore


Expand Down

0 comments on commit 182bc0b

Please sign in to comment.