Start Xvfb for tests.

Fixes #851.
This commit is contained in:
Florian Bruhin 2015-10-07 16:54:46 +02:00
parent b0671ef530
commit 52ced6c652
2 changed files with 24 additions and 0 deletions

View File

@ -39,6 +39,7 @@ from qutebrowser.config import config
from qutebrowser.utils import objreg
from PyQt5.QtNetwork import QNetworkCookieJar
import xvfbwrapper
def _apply_platform_markers(item):
@ -336,3 +337,25 @@ def fail_tests_on_warnings():
warnings.simplefilter('error')
yield
warnings.resetwarnings()
def pytest_configure(config):
"""Start Xvfb if we're on Linux, not on a CI and Xvfb is available.
This is a lot nicer than having windows popping up.
"""
config.xvfb_display = None
if sys.platform.startswith('linux') and 'CI' not in os.environ:
try:
disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16)
disp.start()
except FileNotFoundError:
# We run without Xvfb if it's unavailable.
pass
else:
config.xvfb_display = disp
def pytest_unconfigure(config):
if config.xvfb_display is not None:
config.xvfb_display.stop()

View File

@ -22,6 +22,7 @@ deps =
pytest-mock==0.8.1
pytest-html==1.6
pytest-faulthandler==1.0.1
xvfbwrapper==0.2.5
hypothesis==1.11.4
coverage==4.0.0
pytest-cov==2.2.0