Browse files

bdd: Wait less for xfailing tests

We now divide all timeouts by ten for xfailing tests, with the hope to
still catch newly passing tests, but not spend too much time waiting.

With a quick test, this reduced the testsuite run length from 12 to
7-8 minutes.
  • Loading branch information...
The-Compiler committed Aug 19, 2016
1 parent 362c236 commit 2eae6a06030f72a224bad1fe258f9f0f28edae3e
@@ -293,6 +293,15 @@ def wait_for_js(self, message):
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
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
@@ -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)
@@ -424,7 +424,7 @@ def _maybe_skip(self):
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 @@ def wait_for(self, timeout=None, *, override_waited_for=False,
override_waited_for: If set, gets triggered by previous messages
do_skip: If set, call pytest.skip on a timeout.
divisor: A factor to decrease the timeout by.
The matched line.
@@ -449,6 +450,9 @@ def wait_for(self, timeout=None, *, override_waited_for=False,
timeout = 15000
timeout = 5000
timeout /= divisor
if not kwargs:
raise TypeError("No keyword arguments given!")
for key in kwargs:

0 comments on commit 2eae6a0

Please sign in to comment.