Suppress Qt warning in unittests.

This commit is contained in:
Florian Bruhin 2015-02-27 18:47:53 +01:00
parent cdc298fbc5
commit bb2caaa11d
2 changed files with 14 additions and 1 deletions

View File

@ -27,6 +27,7 @@ from PyQt5.QtWebKitWidgets import QWebPage
from qutebrowser.browser import tabhistory
from qutebrowser.browser.tabhistory import TabHistoryItem as Item
from qutebrowser.utils import qtutils
from qutebrowser.test import helpers
class SerializeHistoryTests(unittest.TestCase):
@ -61,7 +62,8 @@ class SerializeHistoryTests(unittest.TestCase):
def test_count(self):
"""Check if the history's count was loaded correctly."""
self.assertEqual(self.history.count(), len(self.items))
with helpers.disable_logger('qt'):
self.assertEqual(self.history.count(), len(self.items))
def test_valid(self):
"""Check if all items are valid."""

View File

@ -20,6 +20,7 @@
"""Helpers needed by tests."""
import os
import logging
import contextlib
from unittest import mock
@ -55,6 +56,16 @@ def environ_set_temp(env):
del os.environ[name]
@contextlib.contextmanager
def disable_logger(name):
"""Temporarily disable a logger."""
logging.getLogger(name).propagate = False
try:
yield
finally:
logging.getLogger(name).propagate = True
def fake_keyevent(key, modifiers=0, text=''):
"""Generate a new fake QKeyPressEvent."""
evtmock = mock.create_autospec(QKeyEvent, instance=True)