Skip to content

Commit 912f02b

Browse files
committed
Add tests for new modules that have unscoped enums
1 parent ee98657 commit 912f02b

File tree

9 files changed

+156
-17
lines changed

9 files changed

+156
-17
lines changed

qtpy/tests/test_qtdbus.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
from qtpy import PYQT5, PYQT_VERSION
34
from qtpy.tests.utils import pytest_importorskip
45

56

@@ -11,3 +12,20 @@ def test_qtdbus():
1112
assert QtDBus.QDBusAbstractInterface is not None
1213
assert QtDBus.QDBusArgument is not None
1314
assert QtDBus.QDBusConnection is not None
15+
16+
17+
@pytest.mark.skipif(
18+
PYQT5 and PYQT_VERSION.startswith("5.9"),
19+
reason=(
20+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
21+
"to work with scoped enum access"
22+
),
23+
)
24+
def test_enum_access():
25+
"""Test scoped and unscoped enum access."""
26+
QtDBus = pytest_importorskip("qtpy.QtDBus")
27+
28+
assert (
29+
QtDBus.QDBusError.InvalidSignature
30+
== QtDBus.QDBusError.ErrorType.InvalidSignature
31+
)

qtpy/tests/test_qtdesigner.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from qtpy import PYSIDE2
3+
from qtpy import PYQT5, PYQT_VERSION, PYSIDE2
44
from qtpy.tests.utils import pytest_importorskip
55

66

@@ -28,3 +28,20 @@ def test_qtdesigner():
2828
assert QtDesigner.QExtensionFactory is not None
2929
assert QtDesigner.QExtensionManager is not None
3030
assert QtDesigner.QFormBuilder is not None
31+
32+
33+
@pytest.mark.skipif(
34+
PYQT5 and PYQT_VERSION.startswith("5.9"),
35+
reason=(
36+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
37+
"to work with scoped enum access"
38+
),
39+
)
40+
def test_enum_access():
41+
"""Test scoped and unscoped enum access."""
42+
QtDesigner = pytest_importorskip("qtpy.QtDesigner")
43+
44+
assert (
45+
QtDesigner.QDesignerFormWindowInterface.EditFeature
46+
== QtDesigner.QDesignerFormWindowInterface.FeatureFlag.EditFeature
47+
)

qtpy/tests/test_qthelp.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Test for QtHelp namespace."""
22

3+
import pytest
4+
5+
from qtpy import PYQT5, PYQT_VERSION, QtHelp
6+
37

48
def test_qthelp():
59
"""Test the qtpy.QtHelp namespace."""
6-
from qtpy import QtHelp
7-
810
assert QtHelp.QHelpContentItem is not None
911
assert QtHelp.QHelpContentModel is not None
1012
assert QtHelp.QHelpContentWidget is not None
@@ -16,3 +18,18 @@ def test_qthelp():
1618
assert QtHelp.QHelpSearchQuery is not None
1719
assert QtHelp.QHelpSearchQueryWidget is not None
1820
assert QtHelp.QHelpSearchResultWidget is not None
21+
22+
23+
@pytest.mark.skipif(
24+
PYQT5 and PYQT_VERSION.startswith("5.9"),
25+
reason=(
26+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
27+
"to work with scoped enum access"
28+
),
29+
)
30+
def test_enum_access():
31+
"""Test scoped and unscoped enum access."""
32+
assert (
33+
QtHelp.QHelpSearchQuery.DEFAULT
34+
== QtHelp.QHelpSearchQuery.FieldName.DEFAULT
35+
)

qtpy/tests/test_qtmultimedia.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
import sys
2-
31
import pytest
42

5-
from qtpy import PYQT6, PYSIDE6
3+
from qtpy import PYQT5, PYQT6, PYQT_VERSION, PYSIDE6, QtMultimedia
64

75

86
def test_qtmultimedia():
97
"""Test the qtpy.QtMultimedia namespace"""
10-
from qtpy import QtMultimedia
11-
128
assert QtMultimedia.QAudio is not None
139
assert QtMultimedia.QAudioInput is not None
1410

1511
if not (PYSIDE6 or PYQT6):
1612
assert QtMultimedia.QAbstractVideoBuffer is not None
1713
assert QtMultimedia.QAudioDeviceInfo is not None
1814
assert QtMultimedia.QSound is not None
15+
16+
17+
@pytest.mark.skipif(
18+
PYQT5 and PYQT_VERSION.startswith("5.9"),
19+
reason=(
20+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
21+
"to work with scoped enum access"
22+
),
23+
)
24+
def test_enum_access():
25+
"""Test scoped and unscoped enum access."""
26+
assert (
27+
QtMultimedia.QAudio.LinearVolumeScale
28+
== QtMultimedia.QAudio.VolumeScale.LinearVolumeScale
29+
)

qtpy/tests/test_qtnetwork.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from qtpy import PYQT6, PYSIDE2, PYSIDE6, QtNetwork
1+
import pytest
2+
3+
from qtpy import PYQT5, PYQT6, PYQT_VERSION, PYSIDE2, PYSIDE6, QtNetwork
24

35

46
def test_qtnetwork():
@@ -38,3 +40,18 @@ def test_qtnetwork():
3840
assert QtNetwork.QSslError is not None
3941
assert QtNetwork.QSslKey is not None
4042
assert QtNetwork.QSslSocket is not None
43+
44+
45+
@pytest.mark.skipif(
46+
PYQT5 and PYQT_VERSION.startswith("5.9"),
47+
reason=(
48+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
49+
"to work with scoped enum access"
50+
),
51+
)
52+
def test_enum_access():
53+
"""Test scoped and unscoped enum access."""
54+
assert (
55+
QtNetwork.QAbstractSocket.ShareAddress
56+
== QtNetwork.QAbstractSocket.BindFlag.ShareAddress
57+
)

qtpy/tests/test_qtopengl.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import pytest
2+
3+
from qtpy import PYQT5, PYQT_VERSION, QtOpenGL
4+
5+
16
def test_qtopengl():
27
"""Test the qtpy.QtOpenGL namespace"""
3-
from qtpy import QtOpenGL
4-
58
assert QtOpenGL.QOpenGLBuffer is not None
69
assert QtOpenGL.QOpenGLContext is not None
710
assert QtOpenGL.QOpenGLContextGroup is not None
@@ -19,3 +22,18 @@ def test_qtopengl():
1922
assert QtOpenGL.QOpenGLWindow is not None
2023
# We do not test for QOpenGLTimeMonitor or QOpenGLTimerQuery as
2124
# they are not present on some architectures such as armhf
25+
26+
27+
@pytest.mark.skipif(
28+
PYQT5 and PYQT_VERSION.startswith("5.9"),
29+
reason=(
30+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
31+
"to work with scoped enum access"
32+
),
33+
)
34+
def test_enum_access():
35+
"""Test scoped and unscoped enum access."""
36+
assert (
37+
QtOpenGL.QOpenGLBuffer.RangeRead
38+
== QtOpenGL.QOpenGLBuffer.RangeAccessFlag.RangeRead
39+
)

qtpy/tests/test_qtopenglwidgets.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,14 @@ def test_qtopenglwidgets():
99
from qtpy import QtOpenGLWidgets
1010

1111
assert QtOpenGLWidgets.QOpenGLWidget is not None
12+
13+
14+
@pytest.mark.skipif(PYSIDE2 or PYQT5, reason="Not available in PySide2/PyQt5")
15+
def test_enum_access():
16+
"""Test scoped and unscoped enum access."""
17+
from qtpy import QtOpenGLWidgets
18+
19+
assert (
20+
QtOpenGLWidgets.QOpenGLWidget.NoPartialUpdate
21+
== QtOpenGLWidgets.QOpenGLWidget.UpdateBehavior.NoPartialUpdate
22+
)

qtpy/tests/test_qtpositioning.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from qtpy import QT6
3+
from qtpy import PYQT5, PYQT_VERSION, QT6, QtPositioning
44
from qtpy.tests.utils import using_conda
55

66

@@ -10,8 +10,6 @@
1010
)
1111
def test_qtpositioning():
1212
"""Test the qtpy.QtPositioning namespace"""
13-
from qtpy import QtPositioning
14-
1513
assert QtPositioning.QGeoAddress is not None
1614
assert QtPositioning.QGeoAreaMonitorInfo is not None
1715
assert QtPositioning.QGeoAreaMonitorSource is not None
@@ -31,3 +29,22 @@ def test_qtpositioning():
3129
assert QtPositioning.QGeoSatelliteInfoSource is not None
3230
assert QtPositioning.QGeoShape is not None
3331
assert QtPositioning.QNmeaPositionInfoSource is not None
32+
33+
34+
@pytest.mark.skipif(
35+
QT6 and using_conda(),
36+
reason="QPositioning bindings not included in Conda qt-main >= 6.4.3.",
37+
)
38+
@pytest.mark.skipif(
39+
PYQT5 and PYQT_VERSION.startswith("5.9"),
40+
reason=(
41+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
42+
"to work with scoped enum access"
43+
),
44+
)
45+
def test_enum_access():
46+
"""Test scoped and unscoped enum access."""
47+
assert (
48+
QtPositioning.QGeoShape.PolygonType
49+
== QtPositioning.QGeoShape.ShapeType.PolygonType
50+
)

qtpy/tests/test_qtprintsupport.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
"""Test QtPrintSupport."""
22

3-
import sys
4-
53
import pytest
64

7-
from qtpy import QtPrintSupport
5+
from qtpy import PYQT5, PYQT_VERSION, QtPrintSupport
86

97

108
def test_qtprintsupport():
@@ -34,3 +32,18 @@ def test_qprintpreviewwidget_print_(qtbot):
3432
assert QtPrintSupport.QPrintPreviewWidget.print_ is not None
3533
preview_widget = QtPrintSupport.QPrintPreviewWidget()
3634
preview_widget.print_()
35+
36+
37+
@pytest.mark.skipif(
38+
PYQT5 and PYQT_VERSION.startswith("5.9"),
39+
reason=(
40+
"A specific setup with at least sip 4.9.9 is needed for PyQt5 5.9.* "
41+
"to work with scoped enum access"
42+
),
43+
)
44+
def test_enum_access():
45+
"""Test scoped and unscoped enum access"""
46+
assert (
47+
QtPrintSupport.QPrinter.HighResolution
48+
== QtPrintSupport.QPrinter.PrinterMode.HighResolution
49+
)

0 commit comments

Comments
 (0)