Skip to content

Commit a26733c

Browse files
committed
Revert "Enable qInfo tests for PySide6 (#593)"
This reverts commit ce1a689. This change is incorrect as it breaks things with PySide < 6.8.2, but we support running against older versions. The next commit will fix this properly without breaking compatibility. See #232
1 parent ce1a689 commit a26733c

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed

src/pytestqt/qt_compat.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,14 @@ def _import_module(module_name):
111111

112112
self._check_qt_api_version()
113113

114-
self.qInfo = QtCore.qInfo
114+
# qInfo is not exposed in PySide6 (#232)
115+
if hasattr(QtCore, "QMessageLogger"):
116+
self.qInfo = lambda msg: QtCore.QMessageLogger().info(msg)
117+
elif hasattr(QtCore, "qInfo"):
118+
self.qInfo = QtCore.qInfo
119+
else:
120+
self.qInfo = None
121+
115122
self.qDebug = QtCore.qDebug
116123
self.qWarning = QtCore.qWarning
117124
self.qCritical = QtCore.qCritical

tests/test_basics.py

-1
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,6 @@ class Mock:
613613
qtcore = Mock()
614614
for method_name in (
615615
"qInstallMessageHandler",
616-
"qInfo",
617616
"qDebug",
618617
"qWarning",
619618
"qCritical",

tests/test_logging.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ def print_msg(msg_type, context, message):
2626
qt_api.QtCore.qInstallMessageHandler(print_msg)
2727
2828
def test_types():
29-
qt_api.qInfo('this is an INFO message')
29+
# qInfo is not exposed by the bindings yet (#225)
30+
# qt_api.qInfo('this is an INFO message')
3031
qt_api.qDebug('this is a DEBUG message')
3132
qt_api.qWarning('this is a WARNING message')
3233
qt_api.qCritical('this is a CRITICAL message')
@@ -44,7 +45,8 @@ def test_types():
4445
res.stdout.fnmatch_lines(
4546
[
4647
"*-- Captured Qt messages --*",
47-
"*QtInfoMsg: this is an INFO message*",
48+
# qInfo is not exposed by the bindings yet (#232)
49+
# '*QtInfoMsg: this is an INFO message*',
4850
"*QtDebugMsg: this is a DEBUG message*",
4951
"*QtWarningMsg: this is a WARNING message*",
5052
"*QtCriticalMsg: this is a CRITICAL message*",
@@ -54,25 +56,43 @@ def test_types():
5456
res.stdout.fnmatch_lines(
5557
[
5658
"*-- Captured stderr call --*",
57-
"this is an INFO message*",
59+
# qInfo is not exposed by the bindings yet (#232)
60+
# '*QtInfoMsg: this is an INFO message*',
61+
# 'this is an INFO message*',
5862
"this is a DEBUG message*",
5963
"this is a WARNING message*",
6064
"this is a CRITICAL message*",
6165
]
6266
)
6367

6468

69+
def test_qinfo(qtlog):
70+
"""Test INFO messages when we have means to do so. Should be temporary until bindings
71+
catch up and expose qInfo (or at least QMessageLogger), then we should update
72+
the other logging tests properly. #232
73+
"""
74+
75+
if qt_api.is_pyside:
76+
assert (
77+
qt_api.qInfo is None
78+
), "pyside6 does not expose qInfo. If it does, update this test."
79+
return
80+
81+
qt_api.qInfo("this is an INFO message")
82+
records = [(m.type, m.message.strip()) for m in qtlog.records]
83+
assert records == [(qt_api.QtCore.QtMsgType.QtInfoMsg, "this is an INFO message")]
84+
85+
6586
def test_qtlog_fixture(qtlog):
6687
"""
6788
Test qtlog fixture.
6889
"""
69-
qt_api.qInfo("this is an INFO message")
90+
# qInfo is not exposed by the bindings yet (#232)
7091
qt_api.qDebug("this is a DEBUG message")
7192
qt_api.qWarning("this is a WARNING message")
7293
qt_api.qCritical("this is a CRITICAL message")
7394
records = [(m.type, m.message.strip()) for m in qtlog.records]
7495
assert records == [
75-
(qt_api.QtCore.QtMsgType.QtInfoMsg, "this is an INFO message"),
7696
(qt_api.QtCore.QtMsgType.QtDebugMsg, "this is a DEBUG message"),
7797
(qt_api.QtCore.QtMsgType.QtWarningMsg, "this is a WARNING message"),
7898
(qt_api.QtCore.QtMsgType.QtCriticalMsg, "this is a CRITICAL message"),

0 commit comments

Comments
 (0)