diff --git a/tests/end2end/fixtures/quteprocess.py b/tests/end2end/fixtures/quteprocess.py index df2818888..7a6e83413 100644 --- a/tests/end2end/fixtures/quteprocess.py +++ b/tests/end2end/fixtures/quteprocess.py @@ -293,6 +293,15 @@ class QuteProc(testprocess.Process): function='javaScriptConsoleMessage', message='[*] {}'.format(message)) + def wait_for(self, timeout=None, **kwargs): + """Extend wait_for to add divisor if a test is xfailing.""" + xfail = self.request.node.get_marker('xfail') + if xfail and xfail.args[0]: + kwargs['divisor'] = 10 + else: + kwargs['divisor'] = 1 + return super().wait_for(timeout=timeout, **kwargs) + def _is_error_logline(self, msg): """Check if the given LogLine is some kind of error message.""" is_js_error = (msg.category == 'js' and diff --git a/tests/end2end/fixtures/test_quteprocess.py b/tests/end2end/fixtures/test_quteprocess.py index d2d7a5f41..84c88f3d6 100644 --- a/tests/end2end/fixtures/test_quteprocess.py +++ b/tests/end2end/fixtures/test_quteprocess.py @@ -22,7 +22,6 @@ import logging import datetime import json -import collections import pytest @@ -50,6 +49,16 @@ class FakeConfig: def getoption(self, name): return self.ARGS[name] +class FakeNode: + + """Fake for request.node""" + + def __init__(self, call): + self.rep_call = call + + def get_marker(self, _name): + return None + class FakeRequest: @@ -70,7 +79,7 @@ def request_mock(quteproc, monkeypatch, httpbin): """Patch out a pytest request.""" fake_call = FakeRepCall() fake_config = FakeConfig() - fake_node = collections.namedtuple('FakeNode', ['rep_call'])(fake_call) + fake_node = FakeNode(fake_call) fake_request = FakeRequest(fake_node, fake_config, httpbin) assert not hasattr(fake_request.node.rep_call, 'wasxfail') monkeypatch.setattr(quteproc, 'request', fake_request) diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py index 1b624ce29..cb45671ad 100644 --- a/tests/end2end/fixtures/testprocess.py +++ b/tests/end2end/fixtures/testprocess.py @@ -424,7 +424,7 @@ class Process(QObject): pass def wait_for(self, timeout=None, *, override_waited_for=False, - do_skip=False, **kwargs): + do_skip=False, divisor=1, **kwargs): """Wait until a given value is found in the data. Keyword arguments to this function get interpreted as attributes of the @@ -436,6 +436,7 @@ class Process(QObject): override_waited_for: If set, gets triggered by previous messages again. do_skip: If set, call pytest.skip on a timeout. + divisor: A factor to decrease the timeout by. Return: The matched line. @@ -449,6 +450,9 @@ class Process(QObject): timeout = 15000 else: timeout = 5000 + + timeout /= divisor + if not kwargs: raise TypeError("No keyword arguments given!") for key in kwargs: