summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-12-19 08:35:00 +0100
committerFlorian Bruhin <git@the-compiler.org>2017-12-19 08:55:35 +0100
commitf2c93a00611abfe4b94a63293d8dc35099d27554 (patch)
tree9e46440bb96fdd575b9025f0ed232b66dd9d3d6e
parent12ba64254746fc7dd55925f2f3b79844b719eea4 (diff)
downloadqutebrowser-f2c93a00611abfe4b94a63293d8dc35099d27554.tar.gz
qutebrowser-f2c93a00611abfe4b94a63293d8dc35099d27554.zip
Use request instead of pytestconfig
This unifies QuteProc and the other Process subclasses a bit.
-rw-r--r--tests/end2end/fixtures/quteprocess.py7
-rw-r--r--tests/end2end/fixtures/test_quteprocess.py7
-rw-r--r--tests/end2end/fixtures/test_testprocess.py20
-rw-r--r--tests/end2end/fixtures/testprocess.py10
-rw-r--r--tests/end2end/fixtures/webserver.py10
5 files changed, 30 insertions, 24 deletions
diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py
index 8c9acd6ce..a2947e5af 100644
--- a/tests/end2end/fixtures/quteprocess.py
+++ b/tests/end2end/fixtures/quteprocess.py
@@ -299,14 +299,13 @@ class QuteProc(testprocess.Process):
'message']
def __init__(self, request, *, parent=None):
- super().__init__(request.config, parent)
+ super().__init__(request, parent)
self._ipc_socket = None
self.basedir = None
self._focus_ready = False
self._load_ready = False
self._instance_id = next(instance_counter)
self._run_counter = itertools.count()
- self.request = request
def _is_ready(self, what):
"""Called by _parse_line if loading/focusing is done.
@@ -372,11 +371,11 @@ class QuteProc(testprocess.Process):
def _parse_line(self, line):
try:
- log_line = LogLine(self._pytestconfig, line)
+ log_line = LogLine(self.request.config, line)
except testprocess.InvalidLine:
if not line.strip():
return None
- elif (is_ignored_qt_message(self._pytestconfig, line) or
+ elif (is_ignored_qt_message(self.request.config, line) or
is_ignored_lowlevel_message(line) or
is_ignored_chromium_message(line) or
self.request.node.get_marker('no_invalid_lines')):
diff --git a/tests/end2end/fixtures/test_quteprocess.py b/tests/end2end/fixtures/test_quteprocess.py
index 528d29948..aa3fb5857 100644
--- a/tests/end2end/fixtures/test_quteprocess.py
+++ b/tests/end2end/fixtures/test_quteprocess.py
@@ -45,6 +45,10 @@ class FakeConfig:
'--qute-delay': 0,
'--color': True,
'--verbose': False,
+ '--capture': None,
+ }
+ INI = {
+ 'qt_log_ignore': [],
}
def __init__(self):
@@ -53,6 +57,9 @@ class FakeConfig:
def getoption(self, name):
return self.ARGS[name]
+ def getini(self, name):
+ return self.INI[name]
+
class FakeNode:
diff --git a/tests/end2end/fixtures/test_testprocess.py b/tests/end2end/fixtures/test_testprocess.py
index 733191415..6ceb032af 100644
--- a/tests/end2end/fixtures/test_testprocess.py
+++ b/tests/end2end/fixtures/test_testprocess.py
@@ -51,8 +51,8 @@ class PythonProcess(testprocess.Process):
"""A testprocess which runs the given Python code."""
- def __init__(self, pytestconfig):
- super().__init__(pytestconfig)
+ def __init__(self, request):
+ super().__init__(request)
self.proc.setReadChannel(QProcess.StandardOutput)
self.code = None
@@ -103,22 +103,22 @@ class NoReadyPythonProcess(PythonProcess):
@pytest.fixture
-def pyproc(pytestconfig):
- proc = PythonProcess(pytestconfig)
+def pyproc(request):
+ proc = PythonProcess(request)
yield proc
proc.terminate()
@pytest.fixture
-def quit_pyproc(pytestconfig):
- proc = QuitPythonProcess(pytestconfig)
+def quit_pyproc(request):
+ proc = QuitPythonProcess(request)
yield proc
proc.terminate()
@pytest.fixture
-def noready_pyproc(pytestconfig):
- proc = NoReadyPythonProcess(pytestconfig)
+def noready_pyproc(request):
+ proc = NoReadyPythonProcess(request)
yield proc
proc.terminate()
@@ -149,9 +149,9 @@ def test_process_never_started(qtbot, quit_pyproc):
quit_pyproc.after_test()
-def test_wait_signal_raising(qtbot):
+def test_wait_signal_raising(request, qtbot):
"""testprocess._wait_signal should raise by default."""
- proc = testprocess.Process()
+ proc = testprocess.Process(request)
with pytest.raises(qtbot.TimeoutError):
with proc._wait_signal(proc.proc.started, timeout=0):
pass
diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py
index e504bcc1b..3fb259e47 100644
--- a/tests/end2end/fixtures/testprocess.py
+++ b/tests/end2end/fixtures/testprocess.py
@@ -129,7 +129,7 @@ class Process(QObject):
_started: Whether the process was ever started.
proc: The QProcess for the underlying process.
exit_expected: Whether the process is expected to quit.
- pytestconfig: The pytestconfig fixture.
+ request: The request object for the current test.
Signals:
ready: Emitted when the server finished starting up.
@@ -140,9 +140,9 @@ class Process(QObject):
new_data = pyqtSignal(object)
KEYS = ['data']
- def __init__(self, pytestconfig, parent=None):
+ def __init__(self, request, parent=None):
super().__init__(parent)
- self._pytestconfig = pytestconfig
+ self.request = request
self.captured_log = []
self._started = False
self._invalid = []
@@ -153,7 +153,7 @@ class Process(QObject):
def _log(self, line):
"""Add the given line to the captured log output."""
- if self._pytestconfig.getoption('--capture') == 'no':
+ if self.request.config.getoption('--capture') == 'no':
print(line)
self.captured_log.append(line)
@@ -228,7 +228,7 @@ class Process(QObject):
"""Start the process and wait until it started."""
self._start(args, env=env)
self._started = True
- verbose = self._pytestconfig.getoption('--verbose')
+ verbose = self.request.config.getoption('--verbose')
timeout = 60 if 'CI' in os.environ else 20
for _ in range(timeout):
diff --git a/tests/end2end/fixtures/webserver.py b/tests/end2end/fixtures/webserver.py
index b86a55b35..93ef04f03 100644
--- a/tests/end2end/fixtures/webserver.py
+++ b/tests/end2end/fixtures/webserver.py
@@ -137,8 +137,8 @@ class WebserverProcess(testprocess.Process):
KEYS = ['verb', 'path']
- def __init__(self, pytestconfig, script, parent=None):
- super().__init__(pytestconfig, parent)
+ def __init__(self, request, script, parent=None):
+ super().__init__(request, parent)
self._script = script
self.port = utils.random_port()
self.new_data.connect(self.new_request)
@@ -174,9 +174,9 @@ class WebserverProcess(testprocess.Process):
@pytest.fixture(scope='session', autouse=True)
-def server(qapp, pytestconfig):
+def server(qapp, request):
"""Fixture for an server object which ensures clean setup/teardown."""
- server = WebserverProcess(pytestconfig, 'webserver_sub')
+ server = WebserverProcess(request, 'webserver_sub')
server.start()
yield server
server.terminate()
@@ -198,7 +198,7 @@ def ssl_server(request, qapp):
This needs to be explicitly used in a test, and overwrites the server log
used in that test.
"""
- server = WebserverProcess(request.config, 'webserver_sub_ssl')
+ server = WebserverProcess(request, 'webserver_sub_ssl')
request.node._server_log = server.captured_log
server.start()
yield server