Skip to content

Commit 2c299ff

Browse files
committed
Test whether QAction.setShortcuts doesn't support a Qt.Key argument as suggested by @ccordoba12
The test is expected to fail on Qt6 >= 6.5. The earlier versions of PyQt/PySide are patched against the fail, so don't test them.
1 parent 429fd3d commit 2c299ff

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

qtpy/tests/test_qtgui.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
import sys
44

55
import pytest
6+
from packaging.version import parse
67

78
from qtpy import (
89
PYQT5,
910
PYQT_VERSION,
1011
PYSIDE2,
1112
PYSIDE6,
13+
QT_VERSION,
1214
QtCore,
1315
QtGui,
1416
QtWidgets,
@@ -189,11 +191,28 @@ def test_QAction_functions(qtbot):
189191
action.setShortcuts(QtGui.QKeySequence.UnknownKey)
190192
action.setShortcut(QtCore.Qt.Key_F1)
191193
action.setShortcuts([QtCore.Qt.Key_F1])
192-
# The following line is wrong even for Qt6 == 6.6.
194+
# The following line fails even for Qt6 == 6.6.
193195
# Don't test the function with a single `QtCore.Qt.Key` argument.
196+
# See the following test.
194197
# action.setShortcuts(QtCore.Qt.Key_F1)
195198

196199

200+
@pytest.mark.skipif(
201+
parse(QT_VERSION) < parse('6.5.0'),
202+
reason="Qt6 >= 6.5 specific test",
203+
)
204+
@pytest.mark.skipif(
205+
sys.platform == "darwin" and sys.version_info[:2] == (3, 7),
206+
reason="Stalls on macOS CI with Python 3.7",
207+
)
208+
@pytest.mark.xfail(strict=True)
209+
def test_QAction_functions_fail(qtbot):
210+
"""Test `QtGui.QAction.setShortcuts` compatibility with `QtCore.Qt.Key` type."""
211+
action = QtGui.QAction("QtPy", None)
212+
# The following line is wrong even for Qt6 == 6.6.
213+
action.setShortcuts(QtCore.Qt.Key_F1)
214+
215+
197216
def test_opengl_imports():
198217
"""
199218
Test for presence of QOpenGL* classes.

0 commit comments

Comments
 (0)