tests: Ignore some Qt warnings during teardown.

This commit is contained in:
Florian Bruhin 2015-11-03 06:38:48 +01:00
parent 7e0e770d53
commit f5eb755ef3
2 changed files with 12 additions and 12 deletions

View File

@ -34,3 +34,4 @@ qt_log_ignore =
^virtual void QSslSocketBackendPrivate::transmit\(\) SSLRead failed with: -9805 ^virtual void QSslSocketBackendPrivate::transmit\(\) SSLRead failed with: -9805
^Type conversion already registered from type .* ^Type conversion already registered from type .*
^QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once\. ^QNetworkReplyImplPrivate::error: Internal problem, this method must only be called once\.
^QWaitCondition: Destroyed while threads are still waiting

View File

@ -37,6 +37,15 @@ from qutebrowser.misc import ipc
from qutebrowser.utils import log from qutebrowser.utils import log
def is_ignored_qt_message(message):
"""Check if the message is listed in qt_log_ignore."""
regexes = pytest.config.getini('qt_log_ignore')
for regex in regexes:
if re.match(regex, message):
return True
return False
class NoLineMatch(Exception): class NoLineMatch(Exception):
"""Raised by LogLine on unmatched lines.""" """Raised by LogLine on unmatched lines."""
@ -90,19 +99,11 @@ class LogLine:
self.line = int(match.group('line')) self.line = int(match.group('line'))
self.message = match.group('message') self.message = match.group('message')
self.expected = self._is_ignored() self.expected = is_ignored_qt_message(self.message)
def __repr__(self): def __repr__(self):
return 'LogLine({!r})'.format(self._line) return 'LogLine({!r})'.format(self._line)
def _is_ignored(self):
"""Check if the message is listed in qt_log_ignore."""
regexes = pytest.config.getini('qt_log_ignore')
for regex in regexes:
if re.match(regex, self.message):
return True
return False
class QuteProc(testprocess.Process): class QuteProc(testprocess.Process):
@ -129,9 +130,7 @@ class QuteProc(testprocess.Process):
return None return None
elif not line.strip(): elif not line.strip():
return None return None
elif (line == "QWaitCondition: Destroyed while threads are still " elif is_ignored_qt_message(line):
"waiting"):
# Happens on Windows during exit sometimes
return None return None
else: else:
raise testprocess.InvalidLine raise testprocess.InvalidLine