tests.helpers: Clean up imports

This commit is contained in:
Florian Bruhin 2016-06-09 12:59:42 +02:00
parent 346e59880e
commit ef2b3cd6d9

View File

@ -28,6 +28,7 @@ import sys
import collections import collections
import itertools import itertools
import textwrap import textwrap
import unittest.mock
import pytest import pytest
@ -37,6 +38,7 @@ from qutebrowser.utils import objreg
from qutebrowser.browser import cookies from qutebrowser.browser import cookies
from PyQt5.QtCore import QEvent, QSize, Qt from PyQt5.QtCore import QEvent, QSize, Qt
from PyQt5.QtGui import QKeyEvent
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout from PyQt5.QtWidgets import QWidget, QHBoxLayout, QVBoxLayout
from PyQt5.QtNetwork import QNetworkCookieJar from PyQt5.QtNetwork import QNetworkCookieJar
try: try:
@ -263,12 +265,10 @@ def webframe(webpage):
@pytest.fixture @pytest.fixture
def fake_keyevent_factory(): def fake_keyevent_factory():
"""Fixture that when called will return a mock instance of a QKeyEvent.""" """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): def fake_keyevent(key, modifiers=0, text='', typ=QEvent.KeyPress):
"""Generate a new fake QKeyPressEvent.""" """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.key.return_value = key
evtmock.modifiers.return_value = modifiers evtmock.modifiers.return_value = modifiers
evtmock.text.return_value = text evtmock.text.return_value = text