Suppress Qt warning in unittests.
This commit is contained in:
parent
cdc298fbc5
commit
bb2caaa11d
@ -27,6 +27,7 @@ from PyQt5.QtWebKitWidgets import QWebPage
|
|||||||
from qutebrowser.browser import tabhistory
|
from qutebrowser.browser import tabhistory
|
||||||
from qutebrowser.browser.tabhistory import TabHistoryItem as Item
|
from qutebrowser.browser.tabhistory import TabHistoryItem as Item
|
||||||
from qutebrowser.utils import qtutils
|
from qutebrowser.utils import qtutils
|
||||||
|
from qutebrowser.test import helpers
|
||||||
|
|
||||||
|
|
||||||
class SerializeHistoryTests(unittest.TestCase):
|
class SerializeHistoryTests(unittest.TestCase):
|
||||||
@ -61,6 +62,7 @@ class SerializeHistoryTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_count(self):
|
def test_count(self):
|
||||||
"""Check if the history's count was loaded correctly."""
|
"""Check if the history's count was loaded correctly."""
|
||||||
|
with helpers.disable_logger('qt'):
|
||||||
self.assertEqual(self.history.count(), len(self.items))
|
self.assertEqual(self.history.count(), len(self.items))
|
||||||
|
|
||||||
def test_valid(self):
|
def test_valid(self):
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
"""Helpers needed by tests."""
|
"""Helpers needed by tests."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import logging
|
||||||
import contextlib
|
import contextlib
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
@ -55,6 +56,16 @@ def environ_set_temp(env):
|
|||||||
del os.environ[name]
|
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=''):
|
def fake_keyevent(key, modifiers=0, text=''):
|
||||||
"""Generate a new fake QKeyPressEvent."""
|
"""Generate a new fake QKeyPressEvent."""
|
||||||
evtmock = mock.create_autospec(QKeyEvent, instance=True)
|
evtmock = mock.create_autospec(QKeyEvent, instance=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user