Skip to content

Commit 6edbea3

Browse files
committed
Declare read-only properties in a compact way
Also, selectively ignore coverage for certain lines that are tested in a separater process in the tests
1 parent cccffd4 commit 6edbea3

File tree

1 file changed

+7
-21
lines changed

1 file changed

+7
-21
lines changed

pytestqt/plugin.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ def qtlog(request):
443443
if hasattr(request._pyfuncitem, 'qt_log_capture'):
444444
return request._pyfuncitem.qt_log_capture
445445
else:
446-
return _QtMessageCapture()
446+
return _QtMessageCapture() # pragma: no cover
447447

448448

449449
class QtLoggingPlugin(object):
@@ -471,7 +471,7 @@ def pytest_runtest_makereport(self, item, call):
471471

472472
if not report.passed:
473473
long_repr = getattr(report, 'longrepr', None)
474-
if hasattr(long_repr, 'addsection'):
474+
if hasattr(long_repr, 'addsection'): # pragma: no cover
475475
lines = []
476476
for rec in item.qt_log_capture.records:
477477
log_format = self.config.getoption('qt_log_format')
@@ -533,25 +533,11 @@ def __init__(self, msg_type, message):
533533
self._log_type_name = self._get_log_type_name(msg_type)
534534
self._when = datetime.datetime.now()
535535

536-
@property
537-
def message(self):
538-
return self._message
539-
540-
@property
541-
def type(self):
542-
return self._type
543-
544-
@property
545-
def type_name(self):
546-
return self._type_name
547-
548-
@property
549-
def log_type_name(self):
550-
return self._log_type_name
551-
552-
@property
553-
def when(self):
554-
return self._when
536+
message = property(lambda self: self._message)
537+
type = property(lambda self: self._type)
538+
type_name = property(lambda self: self._type_name)
539+
log_type_name = property(lambda self: self._log_type_name)
540+
when = property(lambda self: self._when)
555541

556542
@classmethod
557543
def _get_msg_type_name(cls, msg_type):

0 commit comments

Comments
 (0)