Skip to content

Commit

Permalink
Merge pull request #230 from nicoddemus/release-3.0.2
Browse files Browse the repository at this point in the history
Release 3.0.2
  • Loading branch information
nicoddemus committed Aug 31, 2018
2 parents 0c14963 + 0b322e5 commit eaaf9a3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.0.2 (2018-08-31)
------------------

- Another fix related to ``QtInfoMsg`` objects during logging (`#225`_).


3.0.1 (2018-08-30)
------------------

Expand Down
12 changes: 8 additions & 4 deletions pytestqt/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class QtLoggingPlugin(object):
test and augment reporting if the test failed with the messages captured.
"""

LOG_FAIL_OPTIONS = ['NO', 'CRITICAL', 'WARNING', 'DEBUG']
LOG_FAIL_OPTIONS = ['NO', 'CRITICAL', 'WARNING', 'DEBUG', 'INFO']

def __init__(self, config):
self.config = config
Expand Down Expand Up @@ -199,10 +199,10 @@ class Record(object):
:ivar str message: message contents.
:ivar Qt.QtMsgType type: enum that identifies message type
:ivar str type_name: ``type`` as string: ``"QtDebugMsg"``,
:ivar str type_name: ``type`` as string: ``"QtInfoMsg"``, ``"QtDebugMsg"``,
``"QtWarningMsg"`` or ``"QtCriticalMsg"``.
:ivar str log_type_name:
type name similar to the logging package: ``DEBUG``,
type name similar to the logging package: ``INFO``, ``DEBUG``,
``WARNING`` and ``CRITICAL``.
:ivar datetime.datetime when: when the message was captured
:ivar bool ignored: If this record matches a regex from the "qt_log_ignore"
Expand Down Expand Up @@ -258,11 +258,15 @@ def _get_log_type_name(cls, msg_type):
qt_api.QtCriticalMsg: 'CRITICAL',
qt_api.QtFatalMsg: 'FATAL',
}
if qt_api.QtInfoMsg is not None:
cls._log_type_name_map[qt_api.QtInfoMsg] = 'INFO'
return cls._log_type_name_map[msg_type]

def matches_level(self, level):
assert level in QtLoggingPlugin.LOG_FAIL_OPTIONS
if level == 'DEBUG':
if level == 'INFO':
return self.log_type_name in ('INFO', 'DEBUG', 'WARNING', 'CRITICAL')
elif level == 'DEBUG':
return self.log_type_name in ('DEBUG', 'WARNING', 'CRITICAL')
elif level == 'WARNING':
return self.log_type_name in ('WARNING', 'CRITICAL')
Expand Down
1 change: 1 addition & 0 deletions tests/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def test_qtlog_fixture(qtlog):
"""
Test qtlog fixture.
"""
# qInfo is not exposed by the bindings yet (#225)
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 Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ setenv=
passenv=DISPLAY XAUTHORITY USER USERNAME

[testenv:lint]
basepython=python3.4
basepython=python3
usedevelop=true
deps=
pytest
Expand Down

0 comments on commit eaaf9a3

Please sign in to comment.