Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/pytestqt/qt_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,7 @@ def _import_module(module_name):

self._check_qt_api_version()

# qInfo is not exposed in PySide6 (#232)
if hasattr(QtCore, "QMessageLogger"):
self.qInfo = lambda msg: QtCore.QMessageLogger().info(msg)
elif hasattr(QtCore, "qInfo"):
self.qInfo = QtCore.qInfo
else:
self.qInfo = None

self.qInfo = QtCore.qInfo
self.qDebug = QtCore.qDebug
self.qWarning = QtCore.qWarning
self.qCritical = QtCore.qCritical
Expand Down
1 change: 1 addition & 0 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ class Mock:
qtcore = Mock()
for method_name in (
"qInstallMessageHandler",
"qInfo",
"qDebug",
"qWarning",
"qCritical",
Expand Down
30 changes: 5 additions & 25 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def print_msg(msg_type, context, message):
qt_api.QtCore.qInstallMessageHandler(print_msg)

def test_types():
# qInfo is not exposed by the bindings yet (#225)
# qt_api.qInfo('this is an INFO message')
qt_api.qInfo('this is an INFO message')
qt_api.qDebug('this is a DEBUG message')
qt_api.qWarning('this is a WARNING message')
qt_api.qCritical('this is a CRITICAL message')
Expand All @@ -45,8 +44,7 @@ def test_types():
res.stdout.fnmatch_lines(
[
"*-- Captured Qt messages --*",
# qInfo is not exposed by the bindings yet (#232)
# '*QtInfoMsg: this is an INFO message*',
"*QtInfoMsg: this is an INFO message*",
"*QtDebugMsg: this is a DEBUG message*",
"*QtWarningMsg: this is a WARNING message*",
"*QtCriticalMsg: this is a CRITICAL message*",
Expand All @@ -56,43 +54,25 @@ def test_types():
res.stdout.fnmatch_lines(
[
"*-- Captured stderr call --*",
# qInfo is not exposed by the bindings yet (#232)
# '*QtInfoMsg: this is an INFO message*',
# 'this is an INFO message*',
"this is an INFO message*",
"this is a DEBUG message*",
"this is a WARNING message*",
"this is a CRITICAL message*",
]
)


def test_qinfo(qtlog):
"""Test INFO messages when we have means to do so. Should be temporary until bindings
catch up and expose qInfo (or at least QMessageLogger), then we should update
the other logging tests properly. #232
"""

if qt_api.is_pyside:
assert (
qt_api.qInfo is None
), "pyside6 does not expose qInfo. If it does, update this test."
return

qt_api.qInfo("this is an INFO message")
records = [(m.type, m.message.strip()) for m in qtlog.records]
assert records == [(qt_api.QtCore.QtMsgType.QtInfoMsg, "this is an INFO message")]


def test_qtlog_fixture(qtlog):
"""
Test qtlog fixture.
"""
# qInfo is not exposed by the bindings yet (#232)
qt_api.qInfo("this is an INFO message")
qt_api.qDebug("this is a DEBUG message")
qt_api.qWarning("this is a WARNING message")
qt_api.qCritical("this is a CRITICAL message")
records = [(m.type, m.message.strip()) for m in qtlog.records]
assert records == [
(qt_api.QtCore.QtMsgType.QtInfoMsg, "this is an INFO message"),
(qt_api.QtCore.QtMsgType.QtDebugMsg, "this is a DEBUG message"),
(qt_api.QtCore.QtMsgType.QtWarningMsg, "this is a WARNING message"),
(qt_api.QtCore.QtMsgType.QtCriticalMsg, "this is a CRITICAL message"),
Expand Down