Uploaded Test files

This commit is contained in:
Batuhan Berk Başoğlu 2020-11-12 11:05:57 -05:00
parent f584ad9d97
commit 2e81cb7d99
16627 changed files with 2065359 additions and 102444 deletions

View file

@ -0,0 +1,71 @@
import os
def pytest_configure(config):
"""
This function gets run by py.test at the very start
"""
if 'USE_QT_API' in os.environ:
os.environ['QT_API'] = os.environ['USE_QT_API'].lower()
# We need to import qtpy here to make sure that the API versions get set
# straight away.
import qtpy
def pytest_report_header(config):
"""
This function is used by py.test to insert a customized header into the
test report.
"""
versions = os.linesep
versions += 'PyQt4: '
try:
from PyQt4 import Qt
versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
except ImportError:
versions += 'not installed'
except AttributeError:
versions += 'unknown version'
versions += os.linesep
versions += 'PyQt5: '
try:
from PyQt5 import Qt
versions += "PyQt: {0} - Qt: {1}".format(Qt.PYQT_VERSION_STR, Qt.QT_VERSION_STR)
except ImportError:
versions += 'not installed'
except AttributeError:
versions += 'unknown version'
versions += os.linesep
versions += 'PySide: '
try:
import PySide
from PySide import QtCore
versions += "PySide: {0} - Qt: {1}".format(PySide.__version__, QtCore.__version__)
except ImportError:
versions += 'not installed'
except AttributeError:
versions += 'unknown version'
versions += os.linesep
versions += 'PySide2: '
try:
import PySide2
from PySide2 import QtCore
versions += "PySide: {0} - Qt: {1}".format(PySide2.__version__, QtCore.__version__)
except ImportError:
versions += 'not installed'
except AttributeError:
versions += 'unknown version'
versions += os.linesep
return versions

View file

@ -0,0 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ----------------------------------------------------------------------------
# Copyright © 2015- The Spyder Development Team
#
# Licensed under the terms of the MIT License
# ----------------------------------------------------------------------------
"""File for running tests programmatically."""
# Standard library imports
import sys
# Third party imports
import qtpy # to ensure that Qt4 uses API v2
import pytest
def main():
"""Run pytest tests."""
errno = pytest.main(['-x', 'qtpy', '-v', '-rw', '--durations=10',
'--cov=qtpy', '--cov-report=term-missing'])
sys.exit(errno)
if __name__ == '__main__':
main()

View file

@ -0,0 +1,110 @@
from __future__ import absolute_import
import mock
import platform
import sys
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not PYQT5, reason="Targeted to PyQt5")
@mock.patch.object(platform, 'mac_ver')
def test_qt59_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.9.2',)
# Patch Qt version
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.9.1')
# This should raise an Exception
with pytest.raises(Exception) as e:
import qtpy
assert '10.10' in str(e.value)
assert '5.9' in str(e.value)
@pytest.mark.skipif(not PYQT5, reason="Targeted to PyQt5")
@mock.patch.object(platform, 'mac_ver')
def test_qt59_no_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.10.1',)
# Patch Qt version
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.9.5')
# This should not raise an Exception
try:
import qtpy
except Exception:
pytest.fail("Error!")
@pytest.mark.skipif(not (PYQT5 or PYSIDE2),
reason="Targeted to PyQt5 or PySide2")
@mock.patch.object(platform, 'mac_ver')
def test_qt511_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.10.3',)
# Patch Qt version
if PYQT5:
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.11.1')
else:
monkeypatch.setattr("PySide2.QtCore.__version__", '5.11.1')
# This should raise an Exception
with pytest.raises(Exception) as e:
import qtpy
assert '10.11' in str(e.value)
assert '5.11' in str(e.value)
@pytest.mark.skipif(not (PYQT5 or PYSIDE2),
reason="Targeted to PyQt5 or PySide2")
@mock.patch.object(platform, 'mac_ver')
def test_qt511_no_exception(mac_ver, monkeypatch):
# Remove qtpy to reimport it again
try:
del sys.modules["qtpy"]
except KeyError:
pass
# Patch stdlib to emulate a macOS system
monkeypatch.setattr("sys.platform", 'darwin')
mac_ver.return_value = ('10.13.2',)
# Patch Qt version
if PYQT5:
monkeypatch.setattr("PyQt5.QtCore.QT_VERSION_STR", '5.11.1')
else:
monkeypatch.setattr("PySide2.QtCore.__version__", '5.11.1')
# This should not raise an Exception
try:
import qtpy
except Exception:
pytest.fail("Error!")

View file

@ -0,0 +1,82 @@
import os
from qtpy import QtCore, QtGui, QtWidgets, QtWebEngineWidgets
def assert_pyside():
"""
Make sure that we are using PySide
"""
import PySide
assert QtCore.QEvent is PySide.QtCore.QEvent
assert QtGui.QPainter is PySide.QtGui.QPainter
assert QtWidgets.QWidget is PySide.QtGui.QWidget
assert QtWebEngineWidgets.QWebEnginePage is PySide.QtWebKit.QWebPage
def assert_pyside2():
"""
Make sure that we are using PySide
"""
import PySide2
assert QtCore.QEvent is PySide2.QtCore.QEvent
assert QtGui.QPainter is PySide2.QtGui.QPainter
assert QtWidgets.QWidget is PySide2.QtWidgets.QWidget
assert QtWebEngineWidgets.QWebEnginePage is PySide2.QtWebEngineWidgets.QWebEnginePage
def assert_pyqt4():
"""
Make sure that we are using PyQt4
"""
import PyQt4
assert QtCore.QEvent is PyQt4.QtCore.QEvent
assert QtGui.QPainter is PyQt4.QtGui.QPainter
assert QtWidgets.QWidget is PyQt4.QtGui.QWidget
assert QtWebEngineWidgets.QWebEnginePage is PyQt4.QtWebKit.QWebPage
def assert_pyqt5():
"""
Make sure that we are using PyQt5
"""
import PyQt5
assert QtCore.QEvent is PyQt5.QtCore.QEvent
assert QtGui.QPainter is PyQt5.QtGui.QPainter
assert QtWidgets.QWidget is PyQt5.QtWidgets.QWidget
if QtWebEngineWidgets.WEBENGINE:
assert QtWebEngineWidgets.QWebEnginePage is PyQt5.QtWebEngineWidgets.QWebEnginePage
else:
assert QtWebEngineWidgets.QWebEnginePage is PyQt5.QtWebKitWidgets.QWebPage
def test_qt_api():
"""
If QT_API is specified, we check that the correct Qt wrapper was used
"""
QT_API = os.environ.get('QT_API', '').lower()
if QT_API == 'pyside':
assert_pyside()
elif QT_API in ('pyqt', 'pyqt4'):
assert_pyqt4()
elif QT_API == 'pyqt5':
assert_pyqt5()
elif QT_API == 'pyside2':
assert_pyside2()
else:
# If the tests are run locally, USE_QT_API and QT_API may not be
# defined, but we still want to make sure qtpy is behaving sensibly.
# We should then be loading, in order of decreasing preference, PyQt5,
# PyQt4, and PySide.
try:
import PyQt5
except ImportError:
try:
import PyQt4
except ImportError:
import PySide
assert_pyside()
else:
assert_pyqt4()
else:
assert_pyqt5()

View file

@ -0,0 +1,106 @@
from __future__ import absolute_import
import os
import sys
import pytest
from qtpy import PYSIDE2, QtGui, QtWidgets
PY3 = sys.version[0] == "3"
def get_qapp(icon_path=None):
qapp = QtWidgets.QApplication.instance()
if qapp is None:
qapp = QtWidgets.QApplication([''])
return qapp
class Data(object):
"""
Test class to store in userData. The __getitem__ is needed in order to
reproduce the segmentation fault.
"""
def __getitem__(self, item):
raise ValueError("Failing")
@pytest.mark.skipif(PY3 or (PYSIDE2 and os.environ.get('CI', None) is not None),
reason="It segfaults in Python 3 and in our CIs with PySide2")
def test_patched_qcombobox():
"""
In PySide, using Python objects as userData in QComboBox causes
Segmentation faults under certain conditions. Even in cases where it
doesn't, findData does not work correctly. Likewise, findData also
does not work correctly with Python objects when using PyQt4. On the
other hand, PyQt5 deals with this case correctly. We therefore patch
QComboBox when using PyQt4 and PySide to avoid issues.
"""
app = get_qapp()
data1 = Data()
data2 = Data()
data3 = Data()
data4 = Data()
data5 = Data()
data6 = Data()
icon1 = QtGui.QIcon()
icon2 = QtGui.QIcon()
widget = QtWidgets.QComboBox()
widget.addItem('a', data1)
widget.insertItem(0, 'b', data2)
widget.addItem('c', data1)
widget.setItemData(2, data3)
widget.addItem(icon1, 'd', data4)
widget.insertItem(3, icon2, 'e', data5)
widget.addItem(icon1, 'f')
widget.insertItem(5, icon2, 'g')
widget.show()
assert widget.findData(data1) == 1
assert widget.findData(data2) == 0
assert widget.findData(data3) == 2
assert widget.findData(data4) == 4
assert widget.findData(data5) == 3
assert widget.findData(data6) == -1
assert widget.itemData(0) == data2
assert widget.itemData(1) == data1
assert widget.itemData(2) == data3
assert widget.itemData(3) == data5
assert widget.itemData(4) == data4
assert widget.itemData(5) is None
assert widget.itemData(6) is None
assert widget.itemText(0) == 'b'
assert widget.itemText(1) == 'a'
assert widget.itemText(2) == 'c'
assert widget.itemText(3) == 'e'
assert widget.itemText(4) == 'd'
assert widget.itemText(5) == 'g'
assert widget.itemText(6) == 'f'
@pytest.mark.skipif((PYSIDE2 and os.environ.get('CI', None) is not None),
reason="It segfaults in our CIs with PYSIDE2")
def test_model_item():
"""
This is a regression test for an issue that caused the call to item(0)
below to trigger segmentation faults in PySide. The issue is
non-deterministic when running the call once, so we include a loop to make
sure that we trigger the fault.
"""
app = get_qapp()
combo = QtWidgets.QComboBox()
label_data = [('a', None)]
for iter in range(10000):
combo.clear()
for i, (label, data) in enumerate(label_data):
combo.addItem(label, userData=data)
model = combo.model()
model.item(0)

View file

@ -0,0 +1,98 @@
from __future__ import absolute_import
import sys
import pytest
from qtpy import PYSIDE, PYSIDE2, PYQT4
from qtpy.QtWidgets import QApplication
from qtpy.QtWidgets import QHeaderView
from qtpy.QtCore import Qt
from qtpy.QtCore import QAbstractListModel
PY3 = sys.version[0] == "3"
def get_qapp(icon_path=None):
qapp = QApplication.instance()
if qapp is None:
qapp = QApplication([''])
return qapp
@pytest.mark.skipif(PY3 or PYSIDE2, reason="It fails on Python 3 and PySide2")
def test_patched_qheaderview():
"""
This will test whether QHeaderView has the new methods introduced in Qt5.
It will then create an instance of QHeaderView and test that no exceptions
are raised and that some basic behaviour works.
"""
assert QHeaderView.sectionsClickable is not None
assert QHeaderView.sectionsMovable is not None
assert QHeaderView.sectionResizeMode is not None
assert QHeaderView.setSectionsClickable is not None
assert QHeaderView.setSectionsMovable is not None
assert QHeaderView.setSectionResizeMode is not None
# setup a model and add it to a headerview
qapp = get_qapp()
headerview = QHeaderView(Qt.Horizontal)
class Model(QAbstractListModel):
pass
model = Model()
headerview.setModel(model)
assert headerview.count() == 1
# test it
assert isinstance(headerview.sectionsClickable(), bool)
assert isinstance(headerview.sectionsMovable(), bool)
if PYSIDE:
assert isinstance(headerview.sectionResizeMode(0),
QHeaderView.ResizeMode)
else:
assert isinstance(headerview.sectionResizeMode(0), int)
headerview.setSectionsClickable(True)
assert headerview.sectionsClickable() == True
headerview.setSectionsClickable(False)
assert headerview.sectionsClickable() == False
headerview.setSectionsMovable(True)
assert headerview.sectionsMovable() == True
headerview.setSectionsMovable(False)
assert headerview.sectionsMovable() == False
headerview.setSectionResizeMode(QHeaderView.Interactive)
assert headerview.sectionResizeMode(0) == QHeaderView.Interactive
headerview.setSectionResizeMode(QHeaderView.Fixed)
assert headerview.sectionResizeMode(0) == QHeaderView.Fixed
headerview.setSectionResizeMode(QHeaderView.Stretch)
assert headerview.sectionResizeMode(0) == QHeaderView.Stretch
headerview.setSectionResizeMode(QHeaderView.ResizeToContents)
assert headerview.sectionResizeMode(0) == QHeaderView.ResizeToContents
headerview.setSectionResizeMode(0, QHeaderView.Interactive)
assert headerview.sectionResizeMode(0) == QHeaderView.Interactive
headerview.setSectionResizeMode(0, QHeaderView.Fixed)
assert headerview.sectionResizeMode(0) == QHeaderView.Fixed
headerview.setSectionResizeMode(0, QHeaderView.Stretch)
assert headerview.sectionResizeMode(0) == QHeaderView.Stretch
headerview.setSectionResizeMode(0, QHeaderView.ResizeToContents)
assert headerview.sectionResizeMode(0) == QHeaderView.ResizeToContents
# test that the old methods in Qt4 raise exceptions
if PYQT4 or PYSIDE:
with pytest.warns(UserWarning):
headerview.isClickable()
with pytest.warns(UserWarning):
headerview.isMovable()
with pytest.warns(UserWarning):
headerview.resizeMode(0)
with pytest.warns(UserWarning):
headerview.setClickable(True)
with pytest.warns(UserWarning):
headerview.setMovable(True)
with pytest.warns(UserWarning):
headerview.setResizeMode(0, QHeaderView.Interactive)

View file

@ -0,0 +1,41 @@
"""Test QDesktopServices split in Qt5."""
from __future__ import absolute_import
import pytest
import warnings
from qtpy import PYQT4, PYSIDE
def test_qstandarpath():
"""Test the qtpy.QStandardPaths namespace"""
from qtpy.QtCore import QStandardPaths
assert QStandardPaths.StandardLocation is not None
# Attributes from QDesktopServices shouldn't be in QStandardPaths
with pytest.raises(AttributeError) as excinfo:
QStandardPaths.setUrlHandler
def test_qdesktopservice():
"""Test the qtpy.QDesktopServices namespace"""
from qtpy.QtGui import QDesktopServices
assert QDesktopServices.setUrlHandler is not None
@pytest.mark.skipif(not (PYQT4 or PYSIDE), reason="Warning is only raised in old bindings")
def test_qdesktopservice_qt4_pyside():
from qtpy.QtGui import QDesktopServices
# Attributes from QStandardPaths should raise a warning when imported
# from QDesktopServices
with warnings.catch_warnings(record=True) as w:
# Cause all warnings to always be triggered.
warnings.simplefilter("always")
# Try to import QtHelp.
QDesktopServices.StandardLocation
assert len(w) == 1
assert issubclass(w[-1].category, DeprecationWarning)
assert "deprecated" in str(w[-1].message)

View file

@ -0,0 +1,25 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3danimation():
"""Test the qtpy.Qt3DAnimation namespace"""
Qt3DAnimation = pytest.importorskip("qtpy.Qt3DAnimation")
assert Qt3DAnimation.QAnimationController is not None
assert Qt3DAnimation.QAdditiveClipBlend is not None
assert Qt3DAnimation.QAbstractClipBlendNode is not None
assert Qt3DAnimation.QAbstractAnimation is not None
assert Qt3DAnimation.QKeyframeAnimation is not None
assert Qt3DAnimation.QAbstractAnimationClip is not None
assert Qt3DAnimation.QAbstractClipAnimator is not None
assert Qt3DAnimation.QClipAnimator is not None
assert Qt3DAnimation.QAnimationGroup is not None
assert Qt3DAnimation.QLerpClipBlend is not None
assert Qt3DAnimation.QMorphingAnimation is not None
assert Qt3DAnimation.QAnimationAspect is not None
assert Qt3DAnimation.QVertexBlendAnimation is not None
assert Qt3DAnimation.QBlendedClipAnimator is not None
assert Qt3DAnimation.QMorphTarget is not None

View file

@ -0,0 +1,44 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3dcore():
"""Test the qtpy.Qt3DCore namespace"""
Qt3DCore = pytest.importorskip("qtpy.Qt3DCore")
assert Qt3DCore.QPropertyValueAddedChange is not None
assert Qt3DCore.QSkeletonLoader is not None
assert Qt3DCore.QPropertyNodeRemovedChange is not None
assert Qt3DCore.QPropertyUpdatedChange is not None
assert Qt3DCore.QAspectEngine is not None
assert Qt3DCore.QPropertyValueAddedChangeBase is not None
assert Qt3DCore.QStaticPropertyValueRemovedChangeBase is not None
assert Qt3DCore.QPropertyNodeAddedChange is not None
assert Qt3DCore.QDynamicPropertyUpdatedChange is not None
assert Qt3DCore.QStaticPropertyUpdatedChangeBase is not None
assert Qt3DCore.ChangeFlags is not None
assert Qt3DCore.QAbstractAspect is not None
assert Qt3DCore.QBackendNode is not None
assert Qt3DCore.QTransform is not None
assert Qt3DCore.QPropertyUpdatedChangeBase is not None
assert Qt3DCore.QNodeId is not None
assert Qt3DCore.QJoint is not None
assert Qt3DCore.QSceneChange is not None
assert Qt3DCore.QNodeIdTypePair is not None
assert Qt3DCore.QAbstractSkeleton is not None
assert Qt3DCore.QComponentRemovedChange is not None
assert Qt3DCore.QComponent is not None
assert Qt3DCore.QEntity is not None
assert Qt3DCore.QNodeCommand is not None
assert Qt3DCore.QNode is not None
assert Qt3DCore.QPropertyValueRemovedChange is not None
assert Qt3DCore.QPropertyValueRemovedChangeBase is not None
assert Qt3DCore.QComponentAddedChange is not None
assert Qt3DCore.QNodeCreatedChangeBase is not None
assert Qt3DCore.QNodeDestroyedChange is not None
assert Qt3DCore.QArmature is not None
assert Qt3DCore.QStaticPropertyValueAddedChangeBase is not None
assert Qt3DCore.ChangeFlag is not None
assert Qt3DCore.QSkeleton is not None

View file

@ -0,0 +1,47 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3dextras():
"""Test the qtpy.Qt3DExtras namespace"""
Qt3DExtras = pytest.importorskip("qtpy.Qt3DExtras")
assert Qt3DExtras.QTextureMaterial is not None
assert Qt3DExtras.QPhongAlphaMaterial is not None
assert Qt3DExtras.QOrbitCameraController is not None
assert Qt3DExtras.QAbstractSpriteSheet is not None
assert Qt3DExtras.QNormalDiffuseMapMaterial is not None
assert Qt3DExtras.QDiffuseSpecularMaterial is not None
assert Qt3DExtras.QSphereGeometry is not None
assert Qt3DExtras.QCuboidGeometry is not None
assert Qt3DExtras.QForwardRenderer is not None
assert Qt3DExtras.QPhongMaterial is not None
assert Qt3DExtras.QSpriteGrid is not None
assert Qt3DExtras.QDiffuseMapMaterial is not None
assert Qt3DExtras.QConeGeometry is not None
assert Qt3DExtras.QSpriteSheetItem is not None
assert Qt3DExtras.QPlaneGeometry is not None
assert Qt3DExtras.QSphereMesh is not None
assert Qt3DExtras.QNormalDiffuseSpecularMapMaterial is not None
assert Qt3DExtras.QCuboidMesh is not None
assert Qt3DExtras.QGoochMaterial is not None
assert Qt3DExtras.QText2DEntity is not None
assert Qt3DExtras.QTorusMesh is not None
assert Qt3DExtras.Qt3DWindow is not None
assert Qt3DExtras.QPerVertexColorMaterial is not None
assert Qt3DExtras.QExtrudedTextGeometry is not None
assert Qt3DExtras.QSkyboxEntity is not None
assert Qt3DExtras.QAbstractCameraController is not None
assert Qt3DExtras.QExtrudedTextMesh is not None
assert Qt3DExtras.QCylinderGeometry is not None
assert Qt3DExtras.QTorusGeometry is not None
assert Qt3DExtras.QMorphPhongMaterial is not None
assert Qt3DExtras.QPlaneMesh is not None
assert Qt3DExtras.QDiffuseSpecularMapMaterial is not None
assert Qt3DExtras.QSpriteSheet is not None
assert Qt3DExtras.QConeMesh is not None
assert Qt3DExtras.QFirstPersonCameraController is not None
assert Qt3DExtras.QMetalRoughMaterial is not None
assert Qt3DExtras.QCylinderMesh is not None

View file

@ -0,0 +1,33 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3dinput():
"""Test the qtpy.Qt3DInput namespace"""
Qt3DInput = pytest.importorskip("qtpy.Qt3DInput")
assert Qt3DInput.QAxisAccumulator is not None
assert Qt3DInput.QInputSettings is not None
assert Qt3DInput.QAnalogAxisInput is not None
assert Qt3DInput.QAbstractAxisInput is not None
assert Qt3DInput.QMouseHandler is not None
assert Qt3DInput.QButtonAxisInput is not None
assert Qt3DInput.QInputSequence is not None
assert Qt3DInput.QWheelEvent is not None
assert Qt3DInput.QActionInput is not None
assert Qt3DInput.QKeyboardDevice is not None
assert Qt3DInput.QMouseDevice is not None
assert Qt3DInput.QAxis is not None
assert Qt3DInput.QInputChord is not None
assert Qt3DInput.QMouseEvent is not None
assert Qt3DInput.QKeyboardHandler is not None
assert Qt3DInput.QKeyEvent is not None
assert Qt3DInput.QAbstractActionInput is not None
assert Qt3DInput.QInputAspect is not None
assert Qt3DInput.QLogicalDevice is not None
assert Qt3DInput.QAction is not None
assert Qt3DInput.QAbstractPhysicalDevice is not None
assert Qt3DInput.QAxisSetting is not None

View file

@ -0,0 +1,12 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3dlogic():
"""Test the qtpy.Qt3DLogic namespace"""
Qt3DLogic = pytest.importorskip("qtpy.Qt3DLogic")
assert Qt3DLogic.QLogicAspect is not None
assert Qt3DLogic.QFrameAction is not None

View file

@ -0,0 +1,119 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qt3drender():
"""Test the qtpy.Qt3DRender namespace"""
Qt3DRender = pytest.importorskip("qtpy.Qt3DRender")
assert Qt3DRender.QPointSize is not None
assert Qt3DRender.QFrustumCulling is not None
assert Qt3DRender.QPickPointEvent is not None
assert Qt3DRender.QRenderPassFilter is not None
assert Qt3DRender.QMesh is not None
assert Qt3DRender.QRayCaster is not None
assert Qt3DRender.QStencilMask is not None
assert Qt3DRender.QPickLineEvent is not None
assert Qt3DRender.QPickTriangleEvent is not None
assert Qt3DRender.QRenderState is not None
assert Qt3DRender.QTextureWrapMode is not None
assert Qt3DRender.QRenderPass is not None
assert Qt3DRender.QGeometryRenderer is not None
assert Qt3DRender.QAttribute is not None
assert Qt3DRender.QStencilOperation is not None
assert Qt3DRender.QScissorTest is not None
assert Qt3DRender.QTextureCubeMapArray is not None
assert Qt3DRender.QRenderTarget is not None
assert Qt3DRender.QStencilTest is not None
assert Qt3DRender.QTextureData is not None
assert Qt3DRender.QBuffer is not None
assert Qt3DRender.QLineWidth is not None
assert Qt3DRender.QLayer is not None
assert Qt3DRender.QTextureRectangle is not None
assert Qt3DRender.QRenderTargetSelector is not None
assert Qt3DRender.QPickingSettings is not None
assert Qt3DRender.QCullFace is not None
assert Qt3DRender.QAbstractFunctor is not None
assert Qt3DRender.PropertyReaderInterface is not None
assert Qt3DRender.QMaterial is not None
assert Qt3DRender.QAlphaCoverage is not None
assert Qt3DRender.QClearBuffers is not None
assert Qt3DRender.QAlphaTest is not None
assert Qt3DRender.QStencilOperationArguments is not None
assert Qt3DRender.QTexture2DMultisample is not None
assert Qt3DRender.QLevelOfDetailSwitch is not None
assert Qt3DRender.QRenderStateSet is not None
assert Qt3DRender.QViewport is not None
assert Qt3DRender.QObjectPicker is not None
assert Qt3DRender.QPolygonOffset is not None
assert Qt3DRender.QRenderSettings is not None
assert Qt3DRender.QFrontFace is not None
assert Qt3DRender.QTexture3D is not None
assert Qt3DRender.QTextureBuffer is not None
assert Qt3DRender.QTechniqueFilter is not None
assert Qt3DRender.QLayerFilter is not None
assert Qt3DRender.QFilterKey is not None
assert Qt3DRender.QRenderSurfaceSelector is not None
assert Qt3DRender.QEnvironmentLight is not None
assert Qt3DRender.QMemoryBarrier is not None
assert Qt3DRender.QNoDepthMask is not None
assert Qt3DRender.QBlitFramebuffer is not None
assert Qt3DRender.QGraphicsApiFilter is not None
assert Qt3DRender.QAbstractTexture is not None
assert Qt3DRender.QRenderCaptureReply is not None
assert Qt3DRender.QAbstractLight is not None
assert Qt3DRender.QAbstractRayCaster is not None
assert Qt3DRender.QDirectionalLight is not None
assert Qt3DRender.QDispatchCompute is not None
assert Qt3DRender.QBufferDataGenerator is not None
assert Qt3DRender.QPointLight is not None
assert Qt3DRender.QStencilTestArguments is not None
assert Qt3DRender.QTexture1D is not None
assert Qt3DRender.QCameraSelector is not None
assert Qt3DRender.QProximityFilter is not None
assert Qt3DRender.QTexture1DArray is not None
assert Qt3DRender.QBlendEquation is not None
assert Qt3DRender.QTextureImageDataGenerator is not None
assert Qt3DRender.QSpotLight is not None
assert Qt3DRender.QEffect is not None
assert Qt3DRender.QSeamlessCubemap is not None
assert Qt3DRender.QTexture2DMultisampleArray is not None
assert Qt3DRender.QComputeCommand is not None
assert Qt3DRender.QFrameGraphNode is not None
assert Qt3DRender.QSortPolicy is not None
assert Qt3DRender.QTextureImageData is not None
assert Qt3DRender.QCamera is not None
assert Qt3DRender.QGeometry is not None
assert Qt3DRender.QScreenRayCaster is not None
assert Qt3DRender.QClipPlane is not None
assert Qt3DRender.QMultiSampleAntiAliasing is not None
assert Qt3DRender.QRayCasterHit is not None
assert Qt3DRender.QAbstractTextureImage is not None
assert Qt3DRender.QNoDraw is not None
assert Qt3DRender.QPickEvent is not None
assert Qt3DRender.QRenderCapture is not None
assert Qt3DRender.QDepthTest is not None
assert Qt3DRender.QParameter is not None
assert Qt3DRender.QLevelOfDetail is not None
assert Qt3DRender.QGeometryFactory is not None
assert Qt3DRender.QTexture2D is not None
assert Qt3DRender.QRenderAspect is not None
assert Qt3DRender.QPaintedTextureImage is not None
assert Qt3DRender.QDithering is not None
assert Qt3DRender.QTextureGenerator is not None
assert Qt3DRender.QBlendEquationArguments is not None
assert Qt3DRender.QLevelOfDetailBoundingSphere is not None
assert Qt3DRender.QColorMask is not None
assert Qt3DRender.QSceneLoader is not None
assert Qt3DRender.QTextureLoader is not None
assert Qt3DRender.QShaderProgram is not None
assert Qt3DRender.QTextureCubeMap is not None
assert Qt3DRender.QTexture2DArray is not None
assert Qt3DRender.QTextureImage is not None
assert Qt3DRender.QCameraLens is not None
assert Qt3DRender.QRenderTargetOutput is not None
assert Qt3DRender.QShaderProgramBuilder is not None
assert Qt3DRender.QTechnique is not None
assert Qt3DRender.QShaderData is not None

View file

@ -0,0 +1,11 @@
from __future__ import absolute_import
import pytest
from qtpy import PYSIDE2
@pytest.mark.skipif(not PYSIDE2, reason="Only available by default in PySide2")
def test_qtcharts():
"""Test the qtpy.QtCharts namespace"""
from qtpy import QtCharts
assert QtCharts.QtCharts.QChart is not None

View file

@ -0,0 +1,18 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2, QtCore
"""Test QtCore."""
def test_qtmsghandler():
"""Test qtpy.QtMsgHandler"""
assert QtCore.qInstallMessageHandler is not None
@pytest.mark.skipif(not (PYQT5 or PYSIDE2),
reason="Targeted to PyQt5 or PySide2")
def test_DateTime_toPython():
"""Test QDateTime.toPython"""
assert QtCore.QDateTime.toPython is not None

View file

@ -0,0 +1,46 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtdatavisualization():
"""Test the qtpy.QtDataVisualization namespace"""
QtDataVisualization = pytest.importorskip("qtpy.QtDataVisualization")
assert QtDataVisualization.QScatter3DSeries is not None
assert QtDataVisualization.QSurfaceDataItem is not None
assert QtDataVisualization.QSurface3DSeries is not None
assert QtDataVisualization.QAbstract3DInputHandler is not None
assert QtDataVisualization.QHeightMapSurfaceDataProxy is not None
assert QtDataVisualization.QAbstractDataProxy is not None
assert QtDataVisualization.Q3DCamera is not None
assert QtDataVisualization.QAbstract3DGraph is not None
assert QtDataVisualization.QCustom3DVolume is not None
assert QtDataVisualization.Q3DInputHandler is not None
assert QtDataVisualization.QBarDataProxy is not None
assert QtDataVisualization.QSurfaceDataProxy is not None
assert QtDataVisualization.QScatterDataItem is not None
assert QtDataVisualization.Q3DLight is not None
assert QtDataVisualization.QScatterDataProxy is not None
assert QtDataVisualization.QValue3DAxis is not None
assert QtDataVisualization.Q3DBars is not None
assert QtDataVisualization.QBarDataItem is not None
assert QtDataVisualization.QItemModelBarDataProxy is not None
assert QtDataVisualization.Q3DTheme is not None
assert QtDataVisualization.QCustom3DItem is not None
assert QtDataVisualization.QItemModelScatterDataProxy is not None
assert QtDataVisualization.QValue3DAxisFormatter is not None
assert QtDataVisualization.QItemModelSurfaceDataProxy is not None
assert QtDataVisualization.Q3DScatter is not None
assert QtDataVisualization.QTouch3DInputHandler is not None
assert QtDataVisualization.QBar3DSeries is not None
assert QtDataVisualization.QAbstract3DAxis is not None
assert QtDataVisualization.Q3DScene is not None
assert QtDataVisualization.QCategory3DAxis is not None
assert QtDataVisualization.QAbstract3DSeries is not None
assert QtDataVisualization.Q3DObject is not None
assert QtDataVisualization.QCustom3DLabel is not None
assert QtDataVisualization.Q3DSurface is not None
assert QtDataVisualization.QLogValue3DAxisFormatter is not None

View file

@ -0,0 +1,28 @@
from __future__ import absolute_import
import pytest
from qtpy import PYSIDE2, PYSIDE
@pytest.mark.skipif(PYSIDE2 or PYSIDE, reason="QtDesigner is not avalaible in PySide/PySide2")
def test_qtdesigner():
from qtpy import QtDesigner
"""Test the qtpy.QtDesigner namespace"""
assert QtDesigner.QAbstractExtensionFactory is not None
assert QtDesigner.QAbstractExtensionManager is not None
assert QtDesigner.QDesignerActionEditorInterface is not None
assert QtDesigner.QDesignerContainerExtension is not None
assert QtDesigner.QDesignerCustomWidgetCollectionInterface is not None
assert QtDesigner.QDesignerCustomWidgetInterface is not None
assert QtDesigner.QDesignerFormEditorInterface is not None
assert QtDesigner.QDesignerFormWindowCursorInterface is not None
assert QtDesigner.QDesignerFormWindowInterface is not None
assert QtDesigner.QDesignerFormWindowManagerInterface is not None
assert QtDesigner.QDesignerMemberSheetExtension is not None
assert QtDesigner.QDesignerObjectInspectorInterface is not None
assert QtDesigner.QDesignerPropertyEditorInterface is not None
assert QtDesigner.QDesignerPropertySheetExtension is not None
assert QtDesigner.QDesignerTaskMenuExtension is not None
assert QtDesigner.QDesignerWidgetBoxInterface is not None
assert QtDesigner.QExtensionFactory is not None
assert QtDesigner.QExtensionManager is not None
assert QtDesigner.QFormBuilder is not None

View file

@ -0,0 +1,22 @@
"""Test for QtHelp namespace."""
from __future__ import absolute_import
import pytest
def test_qthelp():
"""Test the qtpy.QtHelp namespace."""
from qtpy import QtHelp
assert QtHelp.QHelpContentItem is not None
assert QtHelp.QHelpContentModel is not None
assert QtHelp.QHelpContentWidget is not None
assert QtHelp.QHelpEngine is not None
assert QtHelp.QHelpEngineCore is not None
assert QtHelp.QHelpIndexModel is not None
assert QtHelp.QHelpIndexWidget is not None
assert QtHelp.QHelpSearchEngine is not None
assert QtHelp.QHelpSearchQuery is not None
assert QtHelp.QHelpSearchQueryWidget is not None
assert QtHelp.QHelpSearchResultWidget is not None

View file

@ -0,0 +1,48 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtlocation():
"""Test the qtpy.QtLocation namespace"""
from qtpy import QtLocation
assert QtLocation.QGeoCodeReply is not None
assert QtLocation.QGeoCodingManager is not None
assert QtLocation.QGeoCodingManagerEngine is not None
assert QtLocation.QGeoManeuver is not None
assert QtLocation.QGeoRoute is not None
assert QtLocation.QGeoRouteReply is not None
assert QtLocation.QGeoRouteRequest is not None
assert QtLocation.QGeoRouteSegment is not None
assert QtLocation.QGeoRoutingManager is not None
assert QtLocation.QGeoRoutingManagerEngine is not None
assert QtLocation.QGeoServiceProvider is not None
#assert QtLocation.QGeoServiceProviderFactory is not None
assert QtLocation.QPlace is not None
assert QtLocation.QPlaceAttribute is not None
assert QtLocation.QPlaceCategory is not None
assert QtLocation.QPlaceContactDetail is not None
assert QtLocation.QPlaceContent is not None
assert QtLocation.QPlaceContentReply is not None
assert QtLocation.QPlaceContentRequest is not None
assert QtLocation.QPlaceDetailsReply is not None
assert QtLocation.QPlaceEditorial is not None
assert QtLocation.QPlaceIcon is not None
assert QtLocation.QPlaceIdReply is not None
assert QtLocation.QPlaceImage is not None
assert QtLocation.QPlaceManager is not None
assert QtLocation.QPlaceManagerEngine is not None
assert QtLocation.QPlaceMatchReply is not None
assert QtLocation.QPlaceMatchRequest is not None
assert QtLocation.QPlaceProposedSearchResult is not None
assert QtLocation.QPlaceRatings is not None
assert QtLocation.QPlaceReply is not None
assert QtLocation.QPlaceResult is not None
assert QtLocation.QPlaceReview is not None
assert QtLocation.QPlaceSearchReply is not None
assert QtLocation.QPlaceSearchRequest is not None
assert QtLocation.QPlaceSearchResult is not None
assert QtLocation.QPlaceSearchSuggestionReply is not None
assert QtLocation.QPlaceSupplier is not None
assert QtLocation.QPlaceUser is not None

View file

@ -0,0 +1,18 @@
from __future__ import absolute_import
import os
import sys
import pytest
@pytest.mark.skipif(os.name == 'nt' and sys.version_info[:2] == (3, 5),
reason="Conda packages don't seem to include QtMultimedia")
def test_qtmultimedia():
"""Test the qtpy.QtMultimedia namespace"""
from qtpy import QtMultimedia
assert QtMultimedia.QAbstractVideoBuffer is not None
assert QtMultimedia.QAudio is not None
assert QtMultimedia.QAudioDeviceInfo is not None
assert QtMultimedia.QAudioInput is not None
assert QtMultimedia.QSound is not None

View file

@ -0,0 +1,18 @@
from __future__ import absolute_import
import os
import sys
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
@pytest.mark.skipif(os.name == 'nt' and sys.version_info[:2] == (3, 5),
reason="Conda packages don't seem to include QtMultimedia")
def test_qtmultimediawidgets():
"""Test the qtpy.QtMultimediaWidgets namespace"""
from qtpy import QtMultimediaWidgets
assert QtMultimediaWidgets.QCameraViewfinder is not None
assert QtMultimediaWidgets.QGraphicsVideoItem is not None
assert QtMultimediaWidgets.QVideoWidget is not None
#assert QtMultimediaWidgets.QVideoWidgetControl is not None

View file

@ -0,0 +1,43 @@
from __future__ import absolute_import
import pytest
from qtpy import PYSIDE, PYSIDE2, QtNetwork
def test_qtnetwork():
"""Test the qtpy.QtNetwork namespace"""
assert QtNetwork.QAbstractNetworkCache is not None
assert QtNetwork.QNetworkCacheMetaData is not None
if not PYSIDE and not PYSIDE2:
assert QtNetwork.QHttpMultiPart is not None
assert QtNetwork.QHttpPart is not None
assert QtNetwork.QNetworkAccessManager is not None
assert QtNetwork.QNetworkCookie is not None
assert QtNetwork.QNetworkCookieJar is not None
assert QtNetwork.QNetworkDiskCache is not None
assert QtNetwork.QNetworkReply is not None
assert QtNetwork.QNetworkRequest is not None
assert QtNetwork.QNetworkConfigurationManager is not None
assert QtNetwork.QNetworkConfiguration is not None
assert QtNetwork.QNetworkSession is not None
assert QtNetwork.QAuthenticator is not None
assert QtNetwork.QHostAddress is not None
assert QtNetwork.QHostInfo is not None
assert QtNetwork.QNetworkAddressEntry is not None
assert QtNetwork.QNetworkInterface is not None
assert QtNetwork.QNetworkProxy is not None
assert QtNetwork.QNetworkProxyFactory is not None
assert QtNetwork.QNetworkProxyQuery is not None
assert QtNetwork.QAbstractSocket is not None
assert QtNetwork.QLocalServer is not None
assert QtNetwork.QLocalSocket is not None
assert QtNetwork.QTcpServer is not None
assert QtNetwork.QTcpSocket is not None
assert QtNetwork.QUdpSocket is not None
if not PYSIDE:
assert QtNetwork.QSslCertificate is not None
assert QtNetwork.QSslCipher is not None
assert QtNetwork.QSslConfiguration is not None
assert QtNetwork.QSslError is not None
assert QtNetwork.QSslKey is not None
assert QtNetwork.QSslSocket is not None

View file

@ -0,0 +1,18 @@
from __future__ import absolute_import
import pytest
from qtpy import QtPrintSupport
def test_qtprintsupport():
"""Test the qtpy.QtPrintSupport namespace"""
assert QtPrintSupport.QAbstractPrintDialog is not None
assert QtPrintSupport.QPageSetupDialog is not None
assert QtPrintSupport.QPrintDialog is not None
assert QtPrintSupport.QPrintPreviewDialog is not None
assert QtPrintSupport.QPrintEngine is not None
assert QtPrintSupport.QPrinter is not None
assert QtPrintSupport.QPrinterInfo is not None
assert QtPrintSupport.QPrintPreviewWidget is not None

View file

@ -0,0 +1,34 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtqml():
"""Test the qtpy.QtQml namespace"""
from qtpy import QtQml
assert QtQml.QJSEngine is not None
assert QtQml.QJSValue is not None
assert QtQml.QJSValueIterator is not None
assert QtQml.QQmlAbstractUrlInterceptor is not None
assert QtQml.QQmlApplicationEngine is not None
assert QtQml.QQmlComponent is not None
assert QtQml.QQmlContext is not None
assert QtQml.QQmlEngine is not None
assert QtQml.QQmlImageProviderBase is not None
assert QtQml.QQmlError is not None
assert QtQml.QQmlExpression is not None
assert QtQml.QQmlExtensionPlugin is not None
assert QtQml.QQmlFileSelector is not None
assert QtQml.QQmlIncubationController is not None
assert QtQml.QQmlIncubator is not None
if not PYSIDE2:
# https://wiki.qt.io/Qt_for_Python_Missing_Bindings#QtQml
assert QtQml.QQmlListProperty is not None
assert QtQml.QQmlListReference is not None
assert QtQml.QQmlNetworkAccessManagerFactory is not None
assert QtQml.QQmlParserStatus is not None
assert QtQml.QQmlProperty is not None
assert QtQml.QQmlPropertyValueSource is not None
assert QtQml.QQmlScriptString is not None
assert QtQml.QQmlPropertyMap is not None

View file

@ -0,0 +1,53 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtquick():
"""Test the qtpy.QtQuick namespace"""
from qtpy import QtQuick
assert QtQuick.QQuickAsyncImageProvider is not None
if not PYSIDE2:
assert QtQuick.QQuickCloseEvent is not None
assert QtQuick.QQuickFramebufferObject is not None
assert QtQuick.QQuickImageProvider is not None
assert QtQuick.QQuickImageResponse is not None
assert QtQuick.QQuickItem is not None
assert QtQuick.QQuickItemGrabResult is not None
assert QtQuick.QQuickPaintedItem is not None
assert QtQuick.QQuickRenderControl is not None
assert QtQuick.QQuickTextDocument is not None
assert QtQuick.QQuickTextureFactory is not None
assert QtQuick.QQuickView is not None
assert QtQuick.QQuickWindow is not None
assert QtQuick.QSGAbstractRenderer is not None
assert QtQuick.QSGBasicGeometryNode is not None
assert QtQuick.QSGClipNode is not None
assert QtQuick.QSGDynamicTexture is not None
assert QtQuick.QSGEngine is not None
if not PYSIDE2:
assert QtQuick.QSGFlatColorMaterial is not None
assert QtQuick.QSGGeometry is not None
assert QtQuick.QSGGeometryNode is not None
#assert QtQuick.QSGImageNode is not None
if not PYSIDE2:
assert QtQuick.QSGMaterial is not None
assert QtQuick.QSGMaterialShader is not None
assert QtQuick.QSGMaterialType is not None
assert QtQuick.QSGNode is not None
assert QtQuick.QSGOpacityNode is not None
if not PYSIDE2:
assert QtQuick.QSGOpaqueTextureMaterial is not None
#assert QtQuick.QSGRectangleNode is not None
#assert QtQuick.QSGRenderNode is not None
#assert QtQuick.QSGRendererInterface is not None
assert QtQuick.QSGSimpleRectNode is not None
assert QtQuick.QSGSimpleTextureNode is not None
assert QtQuick.QSGTexture is not None
if not PYSIDE2:
assert QtQuick.QSGTextureMaterial is not None
assert QtQuick.QSGTextureProvider is not None
assert QtQuick.QSGTransformNode is not None
if not PYSIDE2:
assert QtQuick.QSGVertexColorMaterial is not None

View file

@ -0,0 +1,10 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtquickwidgets():
"""Test the qtpy.QtQuickWidgets namespace"""
from qtpy import QtQuickWidgets
assert QtQuickWidgets.QQuickWidget is not None

View file

@ -0,0 +1,24 @@
from __future__ import absolute_import
import pytest
from qtpy import QtSql
def test_qtsql():
"""Test the qtpy.QtSql namespace"""
assert QtSql.QSqlDatabase is not None
assert QtSql.QSqlDriverCreatorBase is not None
assert QtSql.QSqlDriver is not None
assert QtSql.QSqlError is not None
assert QtSql.QSqlField is not None
assert QtSql.QSqlIndex is not None
assert QtSql.QSqlQuery is not None
assert QtSql.QSqlRecord is not None
assert QtSql.QSqlResult is not None
assert QtSql.QSqlQueryModel is not None
assert QtSql.QSqlRelationalDelegate is not None
assert QtSql.QSqlRelation is not None
assert QtSql.QSqlRelationalTableModel is not None
assert QtSql.QSqlTableModel is not None
# Following modules are not (yet) part of any wrapper:
# QSqlDriverCreator, QSqlDriverPlugin

View file

@ -0,0 +1,13 @@
from __future__ import absolute_import
import pytest
def test_qtsvg():
"""Test the qtpy.QtSvg namespace"""
from qtpy import QtSvg
assert QtSvg.QGraphicsSvgItem is not None
assert QtSvg.QSvgGenerator is not None
assert QtSvg.QSvgRenderer is not None
assert QtSvg.QSvgWidget is not None

View file

@ -0,0 +1,9 @@
from __future__ import absolute_import
import pytest
from qtpy import QtTest
def test_qttest():
"""Test the qtpy.QtTest namespace"""
assert QtTest.QTest is not None

View file

@ -0,0 +1,13 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtwebchannel():
"""Test the qtpy.QtWebChannel namespace"""
from qtpy import QtWebChannel
assert QtWebChannel.QWebChannel is not None
assert QtWebChannel.QWebChannelAbstractTransport is not None

View file

@ -0,0 +1,12 @@
from __future__ import absolute_import
import pytest
from qtpy import QtWebEngineWidgets
def test_qtwebenginewidgets():
"""Test the qtpy.QtWebSockets namespace"""
assert QtWebEngineWidgets.QWebEnginePage is not None
assert QtWebEngineWidgets.QWebEngineView is not None
assert QtWebEngineWidgets.QWebEngineSettings is not None

View file

@ -0,0 +1,15 @@
from __future__ import absolute_import
import pytest
from qtpy import PYQT5, PYSIDE2
@pytest.mark.skipif(not (PYQT5 or PYSIDE2), reason="Only available in Qt5 bindings")
def test_qtwebsockets():
"""Test the qtpy.QtWebSockets namespace"""
from qtpy import QtWebSockets
assert QtWebSockets.QMaskGenerator is not None
assert QtWebSockets.QWebSocket is not None
assert QtWebSockets.QWebSocketCorsAuthenticator is not None
assert QtWebSockets.QWebSocketProtocol is not None
assert QtWebSockets.QWebSocketServer is not None

View file

@ -0,0 +1,25 @@
from __future__ import absolute_import
import pytest
from qtpy import PYSIDE2, PYSIDE
def test_qtxmlpatterns():
"""Test the qtpy.QtXmlPatterns namespace"""
from qtpy import QtXmlPatterns
assert QtXmlPatterns.QAbstractMessageHandler is not None
assert QtXmlPatterns.QAbstractUriResolver is not None
assert QtXmlPatterns.QAbstractXmlNodeModel is not None
assert QtXmlPatterns.QAbstractXmlReceiver is not None
if not PYSIDE2 and not PYSIDE:
assert QtXmlPatterns.QSimpleXmlNodeModel is not None
assert QtXmlPatterns.QSourceLocation is not None
assert QtXmlPatterns.QXmlFormatter is not None
assert QtXmlPatterns.QXmlItem is not None
assert QtXmlPatterns.QXmlName is not None
assert QtXmlPatterns.QXmlNamePool is not None
assert QtXmlPatterns.QXmlNodeModelIndex is not None
assert QtXmlPatterns.QXmlQuery is not None
assert QtXmlPatterns.QXmlResultItems is not None
assert QtXmlPatterns.QXmlSchema is not None
assert QtXmlPatterns.QXmlSchemaValidator is not None
assert QtXmlPatterns.QXmlSerializer is not None

View file

@ -0,0 +1,86 @@
import os
import sys
import contextlib
import pytest
from qtpy import PYSIDE2, QtWidgets
from qtpy.QtWidgets import QComboBox
from qtpy import uic
from qtpy.uic import loadUi
QCOMBOBOX_SUBCLASS = """
from qtpy.QtWidgets import QComboBox
class _QComboBoxSubclass(QComboBox):
pass
"""
@contextlib.contextmanager
def enabled_qcombobox_subclass(tmpdir):
"""
Context manager that sets up a temporary module with a QComboBox subclass
and then removes it once we are done.
"""
with open(tmpdir.join('qcombobox_subclass.py').strpath, 'w') as f:
f.write(QCOMBOBOX_SUBCLASS)
sys.path.insert(0, tmpdir.strpath)
yield
sys.path.pop(0)
def get_qapp(icon_path=None):
"""
Helper function to return a QApplication instance
"""
qapp = QtWidgets.QApplication.instance()
if qapp is None:
qapp = QtWidgets.QApplication([''])
return qapp
@pytest.mark.skipif((PYSIDE2 and os.environ.get('CI', None) is not None),
reason="It segfaults in our CIs with PYSIDE2")
def test_load_ui():
"""
Make sure that the patched loadUi function behaves as expected with a
simple .ui file.
"""
app = get_qapp()
ui = loadUi(os.path.join(os.path.dirname(__file__), 'test.ui'))
assert isinstance(ui.pushButton, QtWidgets.QPushButton)
assert isinstance(ui.comboBox, QComboBox)
@pytest.mark.skipif((PYSIDE2 and os.environ.get('CI', None) is not None),
reason="It segfaults in our CIs with PYSIDE2")
def test_load_ui_custom_auto(tmpdir):
"""
Test that we can load a .ui file with custom widgets without having to
explicitly specify a dictionary of custom widgets, even in the case of
PySide.
"""
app = get_qapp()
with enabled_qcombobox_subclass(tmpdir):
from qcombobox_subclass import _QComboBoxSubclass
ui = loadUi(os.path.join(os.path.dirname(__file__), 'test_custom.ui'))
assert isinstance(ui.pushButton, QtWidgets.QPushButton)
assert isinstance(ui.comboBox, _QComboBoxSubclass)
def test_load_full_uic():
"""Test that we load the full uic objects for PyQt5 and PyQt4."""
QT_API = os.environ.get('QT_API', '').lower()
if QT_API.startswith('pyside'):
assert hasattr(uic, 'loadUi')
assert not hasattr(uic, 'loadUiType')
else:
objects = ['compileUi', 'compileUiDir', 'loadUi', 'loadUiType',
'widgetPluginPath']
assert all([hasattr(uic, o) for o in objects])