Skip to content

Commit

Permalink
PR: Update pytest.importorskip usage (CI) (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored May 2, 2024
2 parents d76a59b + 67285c4 commit 0f7b181
Show file tree
Hide file tree
Showing 35 changed files with 107 additions and 38 deletions.
3 changes: 2 additions & 1 deletion qtpy/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"):
Expand Down
4 changes: 2 additions & 2 deletions qtpy/tests/test_qsci.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qt3danimation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion qtpy/tests/test_qt3dcore.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qt3dextras.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qt3dinput.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qt3dlogic.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion qtpy/tests/test_qt3drender.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtaxcontainer.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtbluetooth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion qtpy/tests/test_qtcharts.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

from qtpy import PYSIDE2, PYSIDE6
from qtpy.tests.utils import pytest_importorskip


@pytest.mark.skipif(
Expand All @@ -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
3 changes: 2 additions & 1 deletion qtpy/tests/test_qtconcurrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions qtpy/tests/test_qtdatavisualization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest

from qtpy.tests.utils import pytest_importorskip


def test_qtdatavisualization():
"""Test the qtpy.QtDataVisualization namespace"""
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtdbus.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion qtpy/tests/test_qtdesigner.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions qtpy/tests/test_qtmacextras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion qtpy/tests/test_qtnetworkauth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtpdf.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtpdfwidgets.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtpurchasing.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtquick3d.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtquickcontrols2.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtremoteobjects.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtscxml.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtstatemachine.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtsvgwidgets.py
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion qtpy/tests/test_qtuitools.py
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 0f7b181

Please sign in to comment.