bdd: Add a --qute-delay argument.
This commit is contained in:
parent
90c1240ad4
commit
55992337b8
@ -353,6 +353,8 @@ def fail_tests_on_warnings():
|
|||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption('--no-xvfb', action='store_true', default=False,
|
parser.addoption('--no-xvfb', action='store_true', default=False,
|
||||||
help='Disable xvfb in tests.')
|
help='Disable xvfb in tests.')
|
||||||
|
parser.addoption('--qute-delay', action='store', default=0, type=int,
|
||||||
|
help="Delay between qutebrowser commands.")
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
import datetime
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
@ -114,6 +115,7 @@ class QuteProc(testprocess.Process):
|
|||||||
"""A running qutebrowser process used for tests.
|
"""A running qutebrowser process used for tests.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
_delay: Delay to wait between commands.
|
||||||
_ipc_socket: The IPC socket of the started instance.
|
_ipc_socket: The IPC socket of the started instance.
|
||||||
_httpbin: The HTTPBin webserver.
|
_httpbin: The HTTPBin webserver.
|
||||||
"""
|
"""
|
||||||
@ -123,8 +125,9 @@ class QuteProc(testprocess.Process):
|
|||||||
KEYS = ['timestamp', 'loglevel', 'category', 'module', 'function', 'line',
|
KEYS = ['timestamp', 'loglevel', 'category', 'module', 'function', 'line',
|
||||||
'message']
|
'message']
|
||||||
|
|
||||||
def __init__(self, httpbin, parent=None):
|
def __init__(self, httpbin, delay, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
self._delay = delay
|
||||||
self._httpbin = httpbin
|
self._httpbin = httpbin
|
||||||
self._ipc_socket = None
|
self._ipc_socket = None
|
||||||
|
|
||||||
@ -191,6 +194,8 @@ class QuteProc(testprocess.Process):
|
|||||||
def send_cmd(self, command, count=None):
|
def send_cmd(self, command, count=None):
|
||||||
assert self._ipc_socket is not None
|
assert self._ipc_socket is not None
|
||||||
|
|
||||||
|
time.sleep(self._delay / 1000)
|
||||||
|
|
||||||
if count is not None:
|
if count is not None:
|
||||||
command = ':{}:{}'.format(count, command.lstrip(':'))
|
command = ':{}:{}'.format(count, command.lstrip(':'))
|
||||||
|
|
||||||
@ -241,9 +246,10 @@ class QuteProc(testprocess.Process):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.yield_fixture(scope='module')
|
@pytest.yield_fixture(scope='module')
|
||||||
def quteproc(qapp, httpbin):
|
def quteproc(qapp, httpbin, request):
|
||||||
"""Fixture for qutebrowser process."""
|
"""Fixture for qutebrowser process."""
|
||||||
proc = QuteProc(httpbin)
|
delay = request.config.getoption('--qute-delay')
|
||||||
|
proc = QuteProc(httpbin, delay)
|
||||||
proc.start()
|
proc.start()
|
||||||
yield proc
|
yield proc
|
||||||
proc.terminate()
|
proc.terminate()
|
||||||
|
Loading…
Reference in New Issue
Block a user