Fix tests and lint
This commit is contained in:
parent
f077f52997
commit
35beb84e85
@ -644,8 +644,8 @@ class Quitter:
|
|||||||
session_manager = objreg.get('session-manager')
|
session_manager = objreg.get('session-manager')
|
||||||
session_manager.save(session, with_private=True)
|
session_manager.save(session, with_private=True)
|
||||||
|
|
||||||
# Make sure we're not accepting a connection from the new process before
|
# Make sure we're not accepting a connection from the new process
|
||||||
# we fully exited.
|
# before we fully exited.
|
||||||
ipc.server.shutdown()
|
ipc.server.shutdown()
|
||||||
|
|
||||||
# Open a new process and immediately shutdown the existing one
|
# Open a new process and immediately shutdown the existing one
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
"""Wrapper over a QWebEngineView."""
|
"""Wrapper over a QWebEngineView."""
|
||||||
|
|
||||||
import os
|
|
||||||
import math
|
import math
|
||||||
import functools
|
import functools
|
||||||
import html as html_utils
|
import html as html_utils
|
||||||
|
@ -26,8 +26,8 @@ from PyQt5.QtWidgets import QMessageBox
|
|||||||
|
|
||||||
from qutebrowser.config import (config, configdata, configfiles, configtypes,
|
from qutebrowser.config import (config, configdata, configfiles, configtypes,
|
||||||
configexc)
|
configexc)
|
||||||
from qutebrowser.utils import objreg, qtutils, usertypes, log, standarddir
|
from qutebrowser.utils import objreg, usertypes, log, standarddir
|
||||||
from qutebrowser.misc import earlyinit, msgbox, objects
|
from qutebrowser.misc import msgbox, objects
|
||||||
|
|
||||||
|
|
||||||
# Error which happened during init, so we can show a message box.
|
# Error which happened during init, so we can show a message box.
|
||||||
|
@ -148,7 +148,7 @@ def _handle_nouveau_graphics():
|
|||||||
force_sw_var in os.environ):
|
force_sw_var in os.environ):
|
||||||
return
|
return
|
||||||
|
|
||||||
if config.force_software_rendering:
|
if config.val.force_software_rendering:
|
||||||
os.environ[force_sw_var] = '1'
|
os.environ[force_sw_var] = '1'
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -175,7 +175,8 @@ def _handle_nouveau_graphics():
|
|||||||
def _handle_wayland():
|
def _handle_wayland():
|
||||||
assert objects.backend == usertypes.Backend.QtWebEngine, objects.backend
|
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
|
return
|
||||||
|
|
||||||
_show_dialog(
|
_show_dialog(
|
||||||
@ -204,6 +205,7 @@ class BackendImports:
|
|||||||
|
|
||||||
def _try_import_backends():
|
def _try_import_backends():
|
||||||
"""Check whether backends can be imported and return BackendImports."""
|
"""Check whether backends can be imported and return BackendImports."""
|
||||||
|
# pylint: disable=unused-variable
|
||||||
results = BackendImports()
|
results = BackendImports()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -36,7 +36,7 @@ except ImportError:
|
|||||||
import attr
|
import attr
|
||||||
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QObject,
|
from PyQt5.QtCore import (pyqtSlot, qInstallMessageHandler, QObject,
|
||||||
QSocketNotifier, QTimer, QUrl)
|
QSocketNotifier, QTimer, QUrl)
|
||||||
from PyQt5.QtWidgets import QApplication, QDialog
|
from PyQt5.QtWidgets import QApplication
|
||||||
|
|
||||||
from qutebrowser.commands import cmdutils
|
from qutebrowser.commands import cmdutils
|
||||||
from qutebrowser.misc import earlyinit, crashdialog, ipc
|
from qutebrowser.misc import earlyinit, crashdialog, ipc
|
||||||
|
@ -113,15 +113,15 @@ class ListenError(Error):
|
|||||||
message: The error message.
|
message: The error message.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, server):
|
def __init__(self, local_server):
|
||||||
"""Constructor.
|
"""Constructor.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
server: The QLocalServer which has the error set.
|
local_server: The QLocalServer which has the error set.
|
||||||
"""
|
"""
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.code = server.serverError()
|
self.code = local_server.serverError()
|
||||||
self.message = server.errorString()
|
self.message = local_server.errorString()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Error while listening to IPC server: {} (error {})".format(
|
return "Error while listening to IPC server: {} (error {})".format(
|
||||||
|
@ -27,8 +27,8 @@ qutebrowser's initialization process roughly looks like this:
|
|||||||
it's too old.
|
it's too old.
|
||||||
- The main() function in this file gets invoked
|
- The main() function in this file gets invoked
|
||||||
- Argument parsing takes place
|
- Argument parsing takes place
|
||||||
- earlyinit.early_init() gets invoked to do various low-level initialization and
|
- earlyinit.early_init() gets invoked to do various low-level initialization
|
||||||
checks whether all dependencies are met.
|
and checks whether all dependencies are met.
|
||||||
- app.run() gets called, which takes over.
|
- app.run() gets called, which takes over.
|
||||||
See the docstring of app.py for details.
|
See the docstring of app.py for details.
|
||||||
"""
|
"""
|
||||||
|
@ -39,9 +39,6 @@ def init_patch(qapp, fake_save_manager, monkeypatch, config_tmpdir,
|
|||||||
monkeypatch.setattr(config, 'key_instance', None)
|
monkeypatch.setattr(config, 'key_instance', None)
|
||||||
monkeypatch.setattr(config, 'change_filters', [])
|
monkeypatch.setattr(config, 'change_filters', [])
|
||||||
monkeypatch.setattr(configinit, '_init_errors', None)
|
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
|
yield
|
||||||
try:
|
try:
|
||||||
objreg.delete('config-commands')
|
objreg.delete('config-commands')
|
||||||
@ -242,33 +239,23 @@ class TestQtArgs:
|
|||||||
assert configinit.qt_args(parsed) == [sys.argv[0], '--foo', '--bar']
|
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
|
# overridden by commandline arg
|
||||||
('webkit', 'auto', False, False, usertypes.Backend.QtWebKit),
|
('webkit', 'webengine', usertypes.Backend.QtWebKit),
|
||||||
# overridden by config
|
# set in config
|
||||||
(None, 'webkit', False, False, usertypes.Backend.QtWebKit),
|
(None, 'webkit', 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),
|
|
||||||
])
|
])
|
||||||
def test_get_backend(monkeypatch, fake_args, config_stub,
|
def test_get_backend(monkeypatch, fake_args, config_stub,
|
||||||
arg, confval, can_import, is_new_webkit, used):
|
arg, confval, used):
|
||||||
real_import = __import__
|
real_import = __import__
|
||||||
|
|
||||||
def fake_import(name, *args, **kwargs):
|
def fake_import(name, *args, **kwargs):
|
||||||
if name != 'PyQt5.QtWebKit':
|
if name != 'PyQt5.QtWebKit':
|
||||||
return real_import(name, *args, **kwargs)
|
return real_import(name, *args, **kwargs)
|
||||||
if can_import:
|
|
||||||
return None
|
|
||||||
raise ImportError
|
raise ImportError
|
||||||
|
|
||||||
fake_args.backend = arg
|
fake_args.backend = arg
|
||||||
config_stub.val.backend = confval
|
config_stub.val.backend = confval
|
||||||
monkeypatch.setattr(configinit.qtutils, 'is_new_qtwebkit',
|
|
||||||
lambda: is_new_webkit)
|
|
||||||
monkeypatch.setattr('builtins.__import__', fake_import)
|
monkeypatch.setattr('builtins.__import__', fake_import)
|
||||||
|
|
||||||
assert configinit.get_backend(fake_args) == used
|
assert configinit.get_backend(fake_args) == used
|
||||||
|
Loading…
Reference in New Issue
Block a user