From 67285c4a6305bd42245eb3ad7b211ae88310dd63 Mon Sep 17 00:00:00 2001 From: dalthviz <16781833+dalthviz@users.noreply.github.com> Date: Thu, 2 May 2024 14:20:53 -0500 Subject: [PATCH] CI: Update 'pytest.importorskip' usage --- qtpy/tests/test_main.py | 3 ++- qtpy/tests/test_qsci.py | 4 ++-- qtpy/tests/test_qt3danimation.py | 4 +++- qtpy/tests/test_qt3dcore.py | 3 ++- qtpy/tests/test_qt3dextras.py | 4 +++- qtpy/tests/test_qt3dinput.py | 4 +++- qtpy/tests/test_qt3dlogic.py | 4 +++- qtpy/tests/test_qt3drender.py | 3 ++- qtpy/tests/test_qtaxcontainer.py | 4 +++- qtpy/tests/test_qtbluetooth.py | 4 +++- qtpy/tests/test_qtcharts.py | 3 ++- qtpy/tests/test_qtconcurrent.py | 3 ++- qtpy/tests/test_qtdatavisualization.py | 6 ++++-- qtpy/tests/test_qtdbus.py | 4 +++- qtpy/tests/test_qtdesigner.py | 3 ++- qtpy/tests/test_qtmacextras.py | 4 ++-- qtpy/tests/test_qtnetworkauth.py | 3 ++- qtpy/tests/test_qtpdf.py | 4 +++- qtpy/tests/test_qtpdfwidgets.py | 4 +++- qtpy/tests/test_qtpurchasing.py | 4 +++- qtpy/tests/test_qtquick3d.py | 4 +++- qtpy/tests/test_qtquickcontrols2.py | 4 +++- qtpy/tests/test_qtremoteobjects.py | 4 +++- qtpy/tests/test_qtscxml.py | 4 +++- qtpy/tests/test_qtstatemachine.py | 4 +++- qtpy/tests/test_qtsvgwidgets.py | 4 +++- qtpy/tests/test_qtuitools.py | 4 +++- qtpy/tests/test_qtwebenginecore.py | 4 +++- qtpy/tests/test_qtwebenginequick.py | 3 ++- qtpy/tests/test_qtwebenginewidgets.py | 3 ++- qtpy/tests/test_qtx11extras.py | 4 +++- qtpy/tests/test_shiboken.py | 4 +++- qtpy/tests/test_sip.py | 4 +++- qtpy/tests/test_uic.py | 4 ++-- qtpy/tests/utils.py | 16 ++++++++++++++++ 35 files changed, 107 insertions(+), 38 deletions(-) diff --git a/qtpy/tests/test_main.py b/qtpy/tests/test_main.py index 771c4894..30af2b26 100644 --- a/qtpy/tests/test_main.py +++ b/qtpy/tests/test_main.py @@ -6,6 +6,7 @@ import pytest from qtpy import API_NAMES, QtCore, QtGui, QtWidgets +from qtpy.tests.utils import pytest_importorskip with contextlib.suppress(Exception): # removed in qt 6.0 @@ -112,7 +113,7 @@ def test_qt_api_environ(api): If no QT_API is specified but some Qt is imported, ensure QT_API is set properly. """ mod = f"{api}.QtCore" - pytest.importorskip(mod, reason=f"Requires {api}") + pytest_importorskip(mod, reason=f"Requires {api}") # clean env env = os.environ.copy() for key in ("QT_API", "USE_QT_API"): diff --git a/qtpy/tests/test_qsci.py b/qtpy/tests/test_qsci.py index 8f001588..4371b950 100644 --- a/qtpy/tests/test_qsci.py +++ b/qtpy/tests/test_qsci.py @@ -3,7 +3,7 @@ import pytest from qtpy import PYSIDE2, PYSIDE6 -from qtpy.tests.utils import using_conda +from qtpy.tests.utils import pytest_importorskip, using_conda @pytest.mark.skipif( @@ -12,7 +12,7 @@ ) def test_qsci(): """Test the qtpy.Qsci namespace""" - Qsci = pytest.importorskip("qtpy.Qsci") + Qsci = pytest_importorskip("qtpy.Qsci") assert Qsci.QSCINTILLA_VERSION is not None assert Qsci.QSCINTILLA_VERSION_STR is not None assert Qsci.QsciAPIs is not None diff --git a/qtpy/tests/test_qt3danimation.py b/qtpy/tests/test_qt3danimation.py index 23171b08..9dba02cd 100644 --- a/qtpy/tests/test_qt3danimation.py +++ b/qtpy/tests/test_qt3danimation.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qt3danimation(): """Test the qtpy.Qt3DAnimation namespace""" - Qt3DAnimation = pytest.importorskip("qtpy.Qt3DAnimation") + Qt3DAnimation = pytest_importorskip("qtpy.Qt3DAnimation") assert Qt3DAnimation.QAnimationController is not None assert Qt3DAnimation.QAdditiveClipBlend is not None diff --git a/qtpy/tests/test_qt3dcore.py b/qtpy/tests/test_qt3dcore.py index 7cae9167..cb0fec54 100644 --- a/qtpy/tests/test_qt3dcore.py +++ b/qtpy/tests/test_qt3dcore.py @@ -1,13 +1,14 @@ import pytest from qtpy import PYQT6, PYSIDE6 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif(PYQT6, reason="Not complete in PyQt6") @pytest.mark.skipif(PYSIDE6, reason="Not complete in PySide6") def test_qt3dcore(): """Test the qtpy.Qt3DCore namespace""" - Qt3DCore = pytest.importorskip("qtpy.Qt3DCore") + Qt3DCore = pytest_importorskip("qtpy.Qt3DCore") assert Qt3DCore.QPropertyValueAddedChange is not None assert Qt3DCore.QSkeletonLoader is not None diff --git a/qtpy/tests/test_qt3dextras.py b/qtpy/tests/test_qt3dextras.py index ba3f0e14..214f60e1 100644 --- a/qtpy/tests/test_qt3dextras.py +++ b/qtpy/tests/test_qt3dextras.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qt3dextras(): """Test the qtpy.Qt3DExtras namespace""" - Qt3DExtras = pytest.importorskip("qtpy.Qt3DExtras") + Qt3DExtras = pytest_importorskip("qtpy.Qt3DExtras") assert Qt3DExtras.QTextureMaterial is not None assert Qt3DExtras.QPhongAlphaMaterial is not None diff --git a/qtpy/tests/test_qt3dinput.py b/qtpy/tests/test_qt3dinput.py index 562055ed..b80eab71 100644 --- a/qtpy/tests/test_qt3dinput.py +++ b/qtpy/tests/test_qt3dinput.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qt3dinput(): """Test the qtpy.Qt3DInput namespace""" - Qt3DInput = pytest.importorskip("qtpy.Qt3DInput") + Qt3DInput = pytest_importorskip("qtpy.Qt3DInput") assert Qt3DInput.QAxisAccumulator is not None assert Qt3DInput.QInputSettings is not None diff --git a/qtpy/tests/test_qt3dlogic.py b/qtpy/tests/test_qt3dlogic.py index c325bf76..995e6b38 100644 --- a/qtpy/tests/test_qt3dlogic.py +++ b/qtpy/tests/test_qt3dlogic.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qt3dlogic(): """Test the qtpy.Qt3DLogic namespace""" - Qt3DLogic = pytest.importorskip("qtpy.Qt3DLogic") + Qt3DLogic = pytest_importorskip("qtpy.Qt3DLogic") assert Qt3DLogic.QLogicAspect is not None assert Qt3DLogic.QFrameAction is not None diff --git a/qtpy/tests/test_qt3drender.py b/qtpy/tests/test_qt3drender.py index 7f5d450a..df9af337 100644 --- a/qtpy/tests/test_qt3drender.py +++ b/qtpy/tests/test_qt3drender.py @@ -1,13 +1,14 @@ import pytest from qtpy import PYQT6, PYSIDE6 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif(PYQT6, reason="Not complete in PyQt6") @pytest.mark.skipif(PYSIDE6, reason="Not complete in PySide6") def test_qt3drender(): """Test the qtpy.Qt3DRender namespace""" - Qt3DRender = pytest.importorskip("qtpy.Qt3DRender") + Qt3DRender = pytest_importorskip("qtpy.Qt3DRender") assert Qt3DRender.QPointSize is not None assert Qt3DRender.QFrustumCulling is not None diff --git a/qtpy/tests/test_qtaxcontainer.py b/qtpy/tests/test_qtaxcontainer.py index 6e31a153..1f4f7df8 100644 --- a/qtpy/tests/test_qtaxcontainer.py +++ b/qtpy/tests/test_qtaxcontainer.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtaxcontainer(): """Test the qtpy.QtAxContainer namespace""" - QtAxContainer = pytest.importorskip("qtpy.QtAxContainer") + QtAxContainer = pytest_importorskip("qtpy.QtAxContainer") assert QtAxContainer.QAxSelect is not None assert QtAxContainer.QAxWidget is not None diff --git a/qtpy/tests/test_qtbluetooth.py b/qtpy/tests/test_qtbluetooth.py index f9294e96..8b0a255a 100644 --- a/qtpy/tests/test_qtbluetooth.py +++ b/qtpy/tests/test_qtbluetooth.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtbluetooth(): """Test the qtpy.QtBluetooth namespace""" - QtBluetooth = pytest.importorskip("qtpy.QtBluetooth") + QtBluetooth = pytest_importorskip("qtpy.QtBluetooth") assert QtBluetooth.QBluetooth is not None assert QtBluetooth.QBluetoothDeviceInfo is not None diff --git a/qtpy/tests/test_qtcharts.py b/qtpy/tests/test_qtcharts.py index 4cce6f95..1c3e9541 100644 --- a/qtpy/tests/test_qtcharts.py +++ b/qtpy/tests/test_qtcharts.py @@ -1,6 +1,7 @@ import pytest from qtpy import PYSIDE2, PYSIDE6 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif( @@ -9,7 +10,7 @@ ) def test_qtcharts(): """Test the qtpy.QtCharts namespace""" - QtCharts = pytest.importorskip("qtpy.QtCharts") + QtCharts = pytest_importorskip("qtpy.QtCharts") assert QtCharts.QChart is not None assert QtCharts.QtCharts.QChart is not None diff --git a/qtpy/tests/test_qtconcurrent.py b/qtpy/tests/test_qtconcurrent.py index 114de183..8fc71777 100644 --- a/qtpy/tests/test_qtconcurrent.py +++ b/qtpy/tests/test_qtconcurrent.py @@ -2,11 +2,12 @@ from packaging.version import parse from qtpy import PYSIDE2, PYSIDE_VERSION +from qtpy.tests.utils import pytest_importorskip def test_qtconcurrent(): """Test the qtpy.QtConcurrent namespace""" - QtConcurrent = pytest.importorskip("qtpy.QtConcurrent") + QtConcurrent = pytest_importorskip("qtpy.QtConcurrent") assert QtConcurrent.QtConcurrent is not None diff --git a/qtpy/tests/test_qtdatavisualization.py b/qtpy/tests/test_qtdatavisualization.py index 5bbf7caf..7b8f21d4 100644 --- a/qtpy/tests/test_qtdatavisualization.py +++ b/qtpy/tests/test_qtdatavisualization.py @@ -1,5 +1,7 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtdatavisualization(): """Test the qtpy.QtDataVisualization namespace""" @@ -8,7 +10,7 @@ def test_qtdatavisualization(): # For example in the case of `PyQt5` you need `PyQtDataVisualization` # QtDataVisualization - QtDataVisualization = pytest.importorskip("qtpy.QtDataVisualization") + QtDataVisualization = pytest_importorskip("qtpy.QtDataVisualization") assert QtDataVisualization.QScatter3DSeries is not None assert QtDataVisualization.QSurfaceDataItem is not None assert QtDataVisualization.QSurface3DSeries is not None @@ -47,7 +49,7 @@ def test_qtdatavisualization(): # QtDatavisualization # import qtpy to get alias for `QtDataVisualization` with lower `v` - qtpy = pytest.importorskip("qtpy") + qtpy = pytest_importorskip("qtpy") assert qtpy.QtDatavisualization.QScatter3DSeries is not None assert qtpy.QtDatavisualization.QSurfaceDataItem is not None diff --git a/qtpy/tests/test_qtdbus.py b/qtpy/tests/test_qtdbus.py index 55946925..a4d9233a 100644 --- a/qtpy/tests/test_qtdbus.py +++ b/qtpy/tests/test_qtdbus.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtdbus(): """Test the qtpy.QtDBus namespace""" - QtDBus = pytest.importorskip("qtpy.QtDBus") + QtDBus = pytest_importorskip("qtpy.QtDBus") assert QtDBus.QDBusAbstractAdaptor is not None assert QtDBus.QDBusAbstractInterface is not None diff --git a/qtpy/tests/test_qtdesigner.py b/qtpy/tests/test_qtdesigner.py index 206390da..2ec8d9c4 100644 --- a/qtpy/tests/test_qtdesigner.py +++ b/qtpy/tests/test_qtdesigner.py @@ -1,12 +1,13 @@ import pytest from qtpy import PYSIDE2 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif(PYSIDE2, reason="QtDesigner is not available in PySide2") def test_qtdesigner(): """Test the qtpy.QtDesigner namespace.""" - QtDesigner = pytest.importorskip("qtpy.QtDesigner") + QtDesigner = pytest_importorskip("qtpy.QtDesigner") assert QtDesigner.QAbstractExtensionFactory is not None assert QtDesigner.QAbstractExtensionManager is not None diff --git a/qtpy/tests/test_qtmacextras.py b/qtpy/tests/test_qtmacextras.py index 1f33b616..b3664b82 100644 --- a/qtpy/tests/test_qtmacextras.py +++ b/qtpy/tests/test_qtmacextras.py @@ -3,7 +3,7 @@ import pytest from qtpy import PYQT6, PYSIDE6 -from qtpy.tests.utils import using_conda +from qtpy.tests.utils import pytest_importorskip, using_conda @pytest.mark.skipif( @@ -16,7 +16,7 @@ ) def test_qtmacextras(): """Test the qtpy.QtMacExtras namespace""" - QtMacExtras = pytest.importorskip("qtpy.QtMacExtras") + QtMacExtras = pytest_importorskip("qtpy.QtMacExtras") assert QtMacExtras.QMacPasteboardMime is not None assert QtMacExtras.QMacToolBar is not None diff --git a/qtpy/tests/test_qtnetworkauth.py b/qtpy/tests/test_qtnetworkauth.py index ff9b9237..6c6d3f92 100644 --- a/qtpy/tests/test_qtnetworkauth.py +++ b/qtpy/tests/test_qtnetworkauth.py @@ -1,12 +1,13 @@ import pytest from qtpy import PYQT5, PYQT6, PYSIDE2 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif(PYSIDE2, reason="Not available for PySide2") def test_qtnetworkauth(): """Test the qtpy.QtNetworkAuth namespace""" - QtNetworkAuth = pytest.importorskip("qtpy.QtNetworkAuth") + QtNetworkAuth = pytest_importorskip("qtpy.QtNetworkAuth") assert QtNetworkAuth.QAbstractOAuth is not None assert QtNetworkAuth.QAbstractOAuth2 is not None diff --git a/qtpy/tests/test_qtpdf.py b/qtpy/tests/test_qtpdf.py index f9611b1f..524c553c 100644 --- a/qtpy/tests/test_qtpdf.py +++ b/qtpy/tests/test_qtpdf.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtpdf(): """Test the qtpy.QtPdf namespace""" - QtPdf = pytest.importorskip("qtpy.QtPdf") + QtPdf = pytest_importorskip("qtpy.QtPdf") assert QtPdf.QPdfDocument is not None assert QtPdf.QPdfLink is not None diff --git a/qtpy/tests/test_qtpdfwidgets.py b/qtpy/tests/test_qtpdfwidgets.py index 55f508cf..33159448 100644 --- a/qtpy/tests/test_qtpdfwidgets.py +++ b/qtpy/tests/test_qtpdfwidgets.py @@ -1,8 +1,10 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtpdfwidgets(): """Test the qtpy.QtPdfWidgets namespace""" - QtPdfWidgets = pytest.importorskip("qtpy.QtPdfWidgets") + QtPdfWidgets = pytest_importorskip("qtpy.QtPdfWidgets") assert QtPdfWidgets.QPdfView is not None diff --git a/qtpy/tests/test_qtpurchasing.py b/qtpy/tests/test_qtpurchasing.py index d4c5173b..fd774b28 100644 --- a/qtpy/tests/test_qtpurchasing.py +++ b/qtpy/tests/test_qtpurchasing.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtpurchasing(): """Test the qtpy.QtPurchasing namespace""" - QtPurchasing = pytest.importorskip("qtpy.QtPurchasing") + QtPurchasing = pytest_importorskip("qtpy.QtPurchasing") assert QtPurchasing.QInAppProduct is not None assert QtPurchasing.QInAppStore is not None diff --git a/qtpy/tests/test_qtquick3d.py b/qtpy/tests/test_qtquick3d.py index ca614bd6..6cd3fdfd 100644 --- a/qtpy/tests/test_qtquick3d.py +++ b/qtpy/tests/test_qtquick3d.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtquick3d(): """Test the qtpy.QtQuick3D namespace""" - QtQuick3D = pytest.importorskip("qtpy.QtQuick3D") + QtQuick3D = pytest_importorskip("qtpy.QtQuick3D") assert QtQuick3D.QQuick3D is not None assert QtQuick3D.QQuick3DGeometry is not None diff --git a/qtpy/tests/test_qtquickcontrols2.py b/qtpy/tests/test_qtquickcontrols2.py index a77ef001..c1bbc08d 100644 --- a/qtpy/tests/test_qtquickcontrols2.py +++ b/qtpy/tests/test_qtquickcontrols2.py @@ -1,8 +1,10 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtquickcontrols2(): """Test the qtpy.QtQuickControls2 namespace""" - QtQuickControls2 = pytest.importorskip("qtpy.QtQuickControls2") + QtQuickControls2 = pytest_importorskip("qtpy.QtQuickControls2") assert QtQuickControls2.QQuickStyle is not None diff --git a/qtpy/tests/test_qtremoteobjects.py b/qtpy/tests/test_qtremoteobjects.py index db009eab..0aaf2e8d 100644 --- a/qtpy/tests/test_qtremoteobjects.py +++ b/qtpy/tests/test_qtremoteobjects.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtremoteobjects(): """Test the qtpy.QtRemoteObjects namespace""" - QtRemoteObjects = pytest.importorskip("qtpy.QtRemoteObjects") + QtRemoteObjects = pytest_importorskip("qtpy.QtRemoteObjects") assert QtRemoteObjects.QRemoteObjectAbstractPersistedStore is not None assert QtRemoteObjects.QRemoteObjectDynamicReplica is not None diff --git a/qtpy/tests/test_qtscxml.py b/qtpy/tests/test_qtscxml.py index 40033799..20d478ee 100644 --- a/qtpy/tests/test_qtscxml.py +++ b/qtpy/tests/test_qtscxml.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtscxml(): """Test the qtpy.QtScxml namespace""" - QtScxml = pytest.importorskip("qtpy.QtScxml") + QtScxml = pytest_importorskip("qtpy.QtScxml") assert QtScxml.QScxmlCompiler is not None assert QtScxml.QScxmlDynamicScxmlServiceFactory is not None diff --git a/qtpy/tests/test_qtstatemachine.py b/qtpy/tests/test_qtstatemachine.py index 5fa986b0..e312126d 100644 --- a/qtpy/tests/test_qtstatemachine.py +++ b/qtpy/tests/test_qtstatemachine.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtstatemachine(): """Test the qtpy.QtStateMachine namespace""" - QtStateMachine = pytest.importorskip("qtpy.QtStateMachine") + QtStateMachine = pytest_importorskip("qtpy.QtStateMachine") assert QtStateMachine.QAbstractState is not None assert QtStateMachine.QAbstractTransition is not None diff --git a/qtpy/tests/test_qtsvgwidgets.py b/qtpy/tests/test_qtsvgwidgets.py index 75339250..0b927ff1 100644 --- a/qtpy/tests/test_qtsvgwidgets.py +++ b/qtpy/tests/test_qtsvgwidgets.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtsvgwidgets(): """Test the qtpy.QtSvgWidgets namespace""" - QtSvgWidgets = pytest.importorskip("qtpy.QtSvgWidgets") + QtSvgWidgets = pytest_importorskip("qtpy.QtSvgWidgets") assert QtSvgWidgets.QGraphicsSvgItem is not None assert QtSvgWidgets.QSvgWidget is not None diff --git a/qtpy/tests/test_qtuitools.py b/qtpy/tests/test_qtuitools.py index 13ee4026..88426882 100644 --- a/qtpy/tests/test_qtuitools.py +++ b/qtpy/tests/test_qtuitools.py @@ -1,8 +1,10 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtuitools(): """Test the qtpy.QtUiTools namespace""" - QtUiTools = pytest.importorskip("qtpy.QtUiTools") + QtUiTools = pytest_importorskip("qtpy.QtUiTools") assert QtUiTools.QUiLoader is not None diff --git a/qtpy/tests/test_qtwebenginecore.py b/qtpy/tests/test_qtwebenginecore.py index 8f2b8c9a..e7d27b02 100644 --- a/qtpy/tests/test_qtwebenginecore.py +++ b/qtpy/tests/test_qtwebenginecore.py @@ -1,8 +1,10 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtwebenginecore(): """Test the qtpy.QtWebEngineCore namespace""" - QtWebEngineCore = pytest.importorskip("qtpy.QtWebEngineCore") + QtWebEngineCore = pytest_importorskip("qtpy.QtWebEngineCore") assert QtWebEngineCore.QWebEngineHttpRequest is not None diff --git a/qtpy/tests/test_qtwebenginequick.py b/qtpy/tests/test_qtwebenginequick.py index cfeda743..c354d13e 100644 --- a/qtpy/tests/test_qtwebenginequick.py +++ b/qtpy/tests/test_qtwebenginequick.py @@ -1,13 +1,14 @@ import pytest from qtpy import PYQT5, PYSIDE2 +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif(PYQT5 or PYSIDE2, reason="Only available in Qt6 bindings") def test_qtwebenginequick(): """Test the qtpy.QtWebEngineQuick namespace""" - QtWebEngineQuick = pytest.importorskip("qtpy.QtWebEngineQuick") + QtWebEngineQuick = pytest_importorskip("qtpy.QtWebEngineQuick") assert QtWebEngineQuick.QtWebEngineQuick is not None assert QtWebEngineQuick.QQuickWebEngineProfile is not None diff --git a/qtpy/tests/test_qtwebenginewidgets.py b/qtpy/tests/test_qtwebenginewidgets.py index c7c4d360..06339798 100644 --- a/qtpy/tests/test_qtwebenginewidgets.py +++ b/qtpy/tests/test_qtwebenginewidgets.py @@ -2,6 +2,7 @@ from packaging import version from qtpy import PYQT5, PYQT6, PYQT_VERSION, PYSIDE2, PYSIDE6, PYSIDE_VERSION +from qtpy.tests.utils import pytest_importorskip @pytest.mark.skipif( @@ -16,7 +17,7 @@ def test_qtwebenginewidgets(): """Test the qtpy.QtWebEngineWidget namespace""" - QtWebEngineWidgets = pytest.importorskip("qtpy.QtWebEngineWidgets") + QtWebEngineWidgets = pytest_importorskip("qtpy.QtWebEngineWidgets") assert QtWebEngineWidgets.QWebEnginePage is not None assert QtWebEngineWidgets.QWebEngineView is not None diff --git a/qtpy/tests/test_qtx11extras.py b/qtpy/tests/test_qtx11extras.py index f1e683dc..b639e0ce 100644 --- a/qtpy/tests/test_qtx11extras.py +++ b/qtpy/tests/test_qtx11extras.py @@ -1,8 +1,10 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_qtwinextras(): - QtX11Extras = pytest.importorskip("qtpy.QtX11Extras") + QtX11Extras = pytest_importorskip("qtpy.QtX11Extras") assert QtX11Extras is not None # This module doesn't seem to contain any classes diff --git a/qtpy/tests/test_shiboken.py b/qtpy/tests/test_shiboken.py index 4920fa55..ae9fe9ff 100644 --- a/qtpy/tests/test_shiboken.py +++ b/qtpy/tests/test_shiboken.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_shiboken(): """Test the qtpy.shiboken namespace""" - shiboken = pytest.importorskip("qtpy.shiboken") + shiboken = pytest_importorskip("qtpy.shiboken") assert shiboken.isValid is not None assert shiboken.wrapInstance is not None diff --git a/qtpy/tests/test_sip.py b/qtpy/tests/test_sip.py index 620d1fdf..edcf7efe 100644 --- a/qtpy/tests/test_sip.py +++ b/qtpy/tests/test_sip.py @@ -1,9 +1,11 @@ import pytest +from qtpy.tests.utils import pytest_importorskip + def test_sip(): """Test the qtpy.sip namespace""" - sip = pytest.importorskip("qtpy.sip") + sip = pytest_importorskip("qtpy.sip") assert sip.assign is not None assert sip.cast is not None diff --git a/qtpy/tests/test_uic.py b/qtpy/tests/test_uic.py index dcd69937..94558461 100644 --- a/qtpy/tests/test_uic.py +++ b/qtpy/tests/test_uic.py @@ -8,10 +8,10 @@ from qtpy import PYSIDE2, PYSIDE6, PYSIDE_VERSION, QtWidgets from qtpy.QtWidgets import QComboBox -from qtpy.tests.utils import using_conda +from qtpy.tests.utils import pytest_importorskip, using_conda if PYSIDE2: - pytest.importorskip("pyside2uic", reason="pyside2uic not installed") + pytest_importorskip("pyside2uic", reason="pyside2uic not installed") from qtpy import uic diff --git a/qtpy/tests/utils.py b/qtpy/tests/utils.py index daf4e762..68ac1668 100644 --- a/qtpy/tests/utils.py +++ b/qtpy/tests/utils.py @@ -2,6 +2,9 @@ import os +import pytest +from packaging.version import parse + def using_conda(): return os.environ.get("USE_CONDA", "Yes") == "Yes" @@ -9,3 +12,16 @@ def using_conda(): def not_using_conda(): return os.environ.get("USE_CONDA", "No") == "No" + + +def pytest_importorskip(module, **kwargs): + """ + Skip the test if the module cannot be imported. + + This is a wrapper around `pytest.importorskip` to support using it with + Python 3.7+. The `exc_type` argument was added in `pytest` 8.2.0. + See spyder-ide/qtpy#485 + """ + if parse(pytest.__version__) < parse("8.2.0"): + return pytest.importorskip(module, **kwargs) + return pytest.importorskip(module, **kwargs, exc_type=ImportError)