Skip to content

Commit ce1a689

Browse files
authored
Enable qInfo tests for PySide6 (#593)
PySide6 now exposes `qInfo` just like Qt6. This enables the `qInfo` tests accordingly. For reference see issue #232.
1 parent 5b4b00d commit ce1a689

File tree

3 files changed

+7
-33
lines changed

3 files changed

+7
-33
lines changed

src/pytestqt/qt_compat.py

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

112112
self._check_qt_api_version()
113113

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-
114+
self.qInfo = QtCore.qInfo
122115
self.qDebug = QtCore.qDebug
123116
self.qWarning = QtCore.qWarning
124117
self.qCritical = QtCore.qCritical

tests/test_basics.py

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

tests/test_logging.py

+5-25
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ def print_msg(msg_type, context, message):
2626
qt_api.QtCore.qInstallMessageHandler(print_msg)
2727
2828
def test_types():
29-
# qInfo is not exposed by the bindings yet (#225)
30-
# qt_api.qInfo('this is an INFO message')
29+
qt_api.qInfo('this is an INFO message')
3130
qt_api.qDebug('this is a DEBUG message')
3231
qt_api.qWarning('this is a WARNING message')
3332
qt_api.qCritical('this is a CRITICAL message')
@@ -45,8 +44,7 @@ def test_types():
4544
res.stdout.fnmatch_lines(
4645
[
4746
"*-- Captured Qt messages --*",
48-
# qInfo is not exposed by the bindings yet (#232)
49-
# '*QtInfoMsg: this is an INFO message*',
47+
"*QtInfoMsg: this is an INFO message*",
5048
"*QtDebugMsg: this is a DEBUG message*",
5149
"*QtWarningMsg: this is a WARNING message*",
5250
"*QtCriticalMsg: this is a CRITICAL message*",
@@ -56,43 +54,25 @@ def test_types():
5654
res.stdout.fnmatch_lines(
5755
[
5856
"*-- Captured stderr call --*",
59-
# qInfo is not exposed by the bindings yet (#232)
60-
# '*QtInfoMsg: this is an INFO message*',
61-
# 'this is an INFO message*',
57+
"this is an INFO message*",
6258
"this is a DEBUG message*",
6359
"this is a WARNING message*",
6460
"this is a CRITICAL message*",
6561
]
6662
)
6763

6864

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-
8665
def test_qtlog_fixture(qtlog):
8766
"""
8867
Test qtlog fixture.
8968
"""
90-
# qInfo is not exposed by the bindings yet (#232)
69+
qt_api.qInfo("this is an INFO message")
9170
qt_api.qDebug("this is a DEBUG message")
9271
qt_api.qWarning("this is a WARNING message")
9372
qt_api.qCritical("this is a CRITICAL message")
9473
records = [(m.type, m.message.strip()) for m in qtlog.records]
9574
assert records == [
75+
(qt_api.QtCore.QtMsgType.QtInfoMsg, "this is an INFO message"),
9676
(qt_api.QtCore.QtMsgType.QtDebugMsg, "this is a DEBUG message"),
9777
(qt_api.QtCore.QtMsgType.QtWarningMsg, "this is a WARNING message"),
9878
(qt_api.QtCore.QtMsgType.QtCriticalMsg, "this is a CRITICAL message"),

0 commit comments

Comments
 (0)