diff --git a/tests/helpers/fixtures.py b/tests/helpers/fixtures.py index 5d0a67aa7..9e3ba82b3 100644 --- a/tests/helpers/fixtures.py +++ b/tests/helpers/fixtures.py @@ -28,6 +28,7 @@ import sys import collections import itertools import textwrap +import unittest.mock import pytest @@ -37,6 +38,7 @@ from qutebrowser.utils import objreg from qutebrowser.browser import cookies from PyQt5.QtCore import QEvent, QSize, Qt +from PyQt5.QtGui import QKeyEvent from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout from PyQt5.QtNetwork import QNetworkCookieJar try: @@ -263,12 +265,10 @@ def webframe(webpage): @pytest.fixture def fake_keyevent_factory(): """Fixture that when called will return a mock instance of a QKeyEvent.""" - from unittest import mock - from PyQt5.QtGui import QKeyEvent def fake_keyevent(key, modifiers=0, text='', typ=QEvent.KeyPress): """Generate a new fake QKeyPressEvent.""" - evtmock = mock.create_autospec(QKeyEvent, instance=True) + evtmock = unittest.mock.create_autospec(QKeyEvent, instance=True) evtmock.key.return_value = key evtmock.modifiers.return_value = modifiers evtmock.text.return_value = text