From 3b65546e92166b9ed5b4e026f6bec08234a38eb5 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Thu, 9 May 2024 16:45:58 -0400 Subject: [PATCH] Backport PR #28195: TST: Prepare for pytest 9 --- lib/matplotlib/tests/test_backend_bases.py | 6 +++--- lib/matplotlib/tests/test_backend_gtk3.py | 3 --- lib/matplotlib/tests/test_backend_qt.py | 4 +--- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/tests/test_backend_bases.py b/lib/matplotlib/tests/test_backend_bases.py index c264f01acdb2..3a49f0ec08ec 100644 --- a/lib/matplotlib/tests/test_backend_bases.py +++ b/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, @@ -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) diff --git a/lib/matplotlib/tests/test_backend_gtk3.py b/lib/matplotlib/tests/test_backend_gtk3.py index 6a95f47e1ddd..d7fa4329cfc8 100644 --- a/lib/matplotlib/tests/test_backend_gtk3.py +++ b/lib/matplotlib/tests/test_backend_gtk3.py @@ -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") diff --git a/lib/matplotlib/tests/test_backend_qt.py b/lib/matplotlib/tests/test_backend_qt.py index 026a49b1441e..a105b88c7449 100644 --- a/lib/matplotlib/tests/test_backend_qt.py +++ b/lib/matplotlib/tests/test_backend_qt.py @@ -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