Fix tests and lint

This commit is contained in:
Florian Bruhin 2017-09-28 09:32:23 +02:00
parent f077f52997
commit 35beb84e85
8 changed files with 20 additions and 32 deletions

View File

@ -644,8 +644,8 @@ class Quitter:
session_manager = objreg.get('session-manager')
session_manager.save(session, with_private=True)
# Make sure we're not accepting a connection from the new process before
# we fully exited.
# Make sure we're not accepting a connection from the new process
# before we fully exited.
ipc.server.shutdown()
# Open a new process and immediately shutdown the existing one

View File

@ -19,7 +19,6 @@
"""Wrapper over a QWebEngineView."""
import os
import math
import functools
import html as html_utils

View File

@ -26,8 +26,8 @@ from PyQt5.QtWidgets import QMessageBox
from qutebrowser.config import (config, configdata, configfiles, configtypes,
configexc)
from qutebrowser.utils import objreg, qtutils, usertypes, log, standarddir
from qutebrowser.misc import earlyinit, msgbox, objects
from qutebrowser.utils import objreg, usertypes, log, standarddir
from qutebrowser.misc import msgbox, objects
# Error which happened during init, so we can show a message box.

View File

@ -148,7 +148,7 @@ def _handle_nouveau_graphics():
force_sw_var in os.environ):
return
if config.force_software_rendering:
if config.val.force_software_rendering:
os.environ[force_sw_var] = '1'
return
@ -175,7 +175,8 @@ def _handle_nouveau_graphics():
def _handle_wayland():
assert objects.backend == usertypes.Backend.QtWebEngine, objects.backend
if QApplication.instance().platformName() not in ['wayland', 'wayland-egl']:
platform = QApplication.instance().platformName()
if platform not in ['wayland', 'wayland-egl']:
return
_show_dialog(
@ -204,6 +205,7 @@ class BackendImports:
def _try_import_backends():
"""Check whether backends can be imported and return BackendImports."""
# pylint: disable=unused-variable
results = BackendImports()
try:

View File

@ -36,7 +36,7 @@ except ImportError:
import attr
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QObject,
QSocketNotifier, QTimer, QUrl)
from PyQt5.QtWidgets import QApplication, QDialog
from PyQt5.QtWidgets import QApplication
from qutebrowser.commands import cmdutils
from qutebrowser.misc import earlyinit, crashdialog, ipc

View File

@ -113,15 +113,15 @@ class ListenError(Error):
message: The error message.
"""
def __init__(self, server):
def __init__(self, local_server):
"""Constructor.
Args:
server: The QLocalServer which has the error set.
local_server: The QLocalServer which has the error set.
"""
super().__init__()
self.code = server.serverError()
self.message = server.errorString()
self.code = local_server.serverError()
self.message = local_server.errorString()
def __str__(self):
return "Error while listening to IPC server: {} (error {})".format(

View File

@ -27,8 +27,8 @@ qutebrowser's initialization process roughly looks like this:
it's too old.
- The main() function in this file gets invoked
- Argument parsing takes place
- earlyinit.early_init() gets invoked to do various low-level initialization and
checks whether all dependencies are met.
- earlyinit.early_init() gets invoked to do various low-level initialization
and checks whether all dependencies are met.
- app.run() gets called, which takes over.
See the docstring of app.py for details.
"""

View File

@ -39,9 +39,6 @@ def init_patch(qapp, fake_save_manager, monkeypatch, config_tmpdir,
monkeypatch.setattr(config, 'key_instance', None)
monkeypatch.setattr(config, 'change_filters', [])
monkeypatch.setattr(configinit, '_init_errors', None)
# Make sure we get no SSL warning
monkeypatch.setattr(configinit.earlyinit, 'check_backend_ssl_support',
lambda _backend: None)
yield
try:
objreg.delete('config-commands')
@ -242,33 +239,23 @@ class TestQtArgs:
assert configinit.qt_args(parsed) == [sys.argv[0], '--foo', '--bar']
@pytest.mark.parametrize('arg, confval, can_import, is_new_webkit, used', [
@pytest.mark.parametrize('arg, confval, used', [
# overridden by commandline arg
('webkit', 'auto', False, False, usertypes.Backend.QtWebKit),
# overridden by config
(None, 'webkit', False, False, usertypes.Backend.QtWebKit),
# WebKit available but too old
(None, 'auto', True, False, usertypes.Backend.QtWebEngine),
# WebKit available and new
(None, 'auto', True, True, usertypes.Backend.QtWebKit),
# WebKit unavailable
(None, 'auto', False, False, usertypes.Backend.QtWebEngine),
('webkit', 'webengine', usertypes.Backend.QtWebKit),
# set in config
(None, 'webkit', usertypes.Backend.QtWebKit),
])
def test_get_backend(monkeypatch, fake_args, config_stub,
arg, confval, can_import, is_new_webkit, used):
arg, confval, used):
real_import = __import__
def fake_import(name, *args, **kwargs):
if name != 'PyQt5.QtWebKit':
return real_import(name, *args, **kwargs)
if can_import:
return None
raise ImportError
fake_args.backend = arg
config_stub.val.backend = confval
monkeypatch.setattr(configinit.qtutils, 'is_new_qtwebkit',
lambda: is_new_webkit)
monkeypatch.setattr('builtins.__import__', fake_import)
assert configinit.get_backend(fake_args) == used