Switch to pytest-xvfb. Fixes #1309.
This commit is contained in:
parent
aad8dfc0ce
commit
5c617b861c
@ -9,7 +9,7 @@ markers =
|
|||||||
osx: Tests which only can run on OS X.
|
osx: Tests which only can run on OS X.
|
||||||
not_osx: Tests which can not run on OS X.
|
not_osx: Tests which can not run on OS X.
|
||||||
not_frozen: Tests which can't be run if sys.frozen is True.
|
not_frozen: Tests which can't be run if sys.frozen is True.
|
||||||
not_xvfb: Tests which can't be run with Xvfb.
|
no_xvfb: Tests which can't be run with Xvfb.
|
||||||
frozen: Tests which can only be run if sys.frozen is True.
|
frozen: Tests which can only be run if sys.frozen is True.
|
||||||
integration: Tests which test a bigger portion of code, run without coverage.
|
integration: Tests which test a bigger portion of code, run without coverage.
|
||||||
skip: Always skipped test.
|
skip: Always skipped test.
|
||||||
|
@ -34,7 +34,6 @@ from helpers.messagemock import message_mock
|
|||||||
from helpers.fixtures import * # pylint: disable=wildcard-import
|
from helpers.fixtures import * # pylint: disable=wildcard-import
|
||||||
|
|
||||||
from PyQt5.QtCore import PYQT_VERSION
|
from PyQt5.QtCore import PYQT_VERSION
|
||||||
import xvfbwrapper
|
|
||||||
|
|
||||||
|
|
||||||
# Set hypothesis settings
|
# Set hypothesis settings
|
||||||
@ -55,8 +54,6 @@ def _apply_platform_markers(item):
|
|||||||
"Can't be run when frozen"),
|
"Can't be run when frozen"),
|
||||||
('frozen', not getattr(sys, 'frozen', False),
|
('frozen', not getattr(sys, 'frozen', False),
|
||||||
"Can only run when frozen"),
|
"Can only run when frozen"),
|
||||||
('not_xvfb', item.config.xvfb_display is not None,
|
|
||||||
"Can't be run with Xvfb."),
|
|
||||||
('skip', True, "Always skipped."),
|
('skip', True, "Always skipped."),
|
||||||
('pyqt531_or_newer', PYQT_VERSION < 0x050301,
|
('pyqt531_or_newer', PYQT_VERSION < 0x050301,
|
||||||
"Needs PyQt 5.3.1 or newer"),
|
"Needs PyQt 5.3.1 or newer"),
|
||||||
@ -147,41 +144,18 @@ def fail_tests_on_warnings():
|
|||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption('--no-xvfb', action='store_true', default=False,
|
|
||||||
help='Disable xvfb in tests.')
|
|
||||||
parser.addoption('--qute-delay', action='store', default=0, type=int,
|
parser.addoption('--qute-delay', action='store', default=0, type=int,
|
||||||
help="Delay between qutebrowser commands.")
|
help="Delay between qutebrowser commands.")
|
||||||
parser.addoption('--qute-profile-subprocs', action='store_true',
|
parser.addoption('--qute-profile-subprocs', action='store_true',
|
||||||
default=False, help="Run cProfile for subprocesses.")
|
default=False, help="Run cProfile for subprocesses.")
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
@pytest.fixture(scope='session', autouse=True)
|
||||||
"""Start Xvfb if we're on Linux, not on a CI and Xvfb is available.
|
def prevent_xvfb_on_buildbot(request):
|
||||||
|
if (not request.config.getoption('--no-xvfb') and
|
||||||
This is a lot nicer than having windows popping up.
|
'QUTE_BUILDBOT' in os.environ and
|
||||||
"""
|
request.config.xvfb is not None):
|
||||||
config.xvfb_display = None
|
raise Exception("Xvfb is running on buildbot!")
|
||||||
if os.environ.get('DISPLAY', None) == '':
|
|
||||||
# xvfbwrapper doesn't handle DISPLAY="" correctly
|
|
||||||
del os.environ['DISPLAY']
|
|
||||||
|
|
||||||
if (sys.platform.startswith('linux') and
|
|
||||||
not config.getoption('--no-xvfb') and
|
|
||||||
'QUTE_NO_DISPLAY' not in os.environ):
|
|
||||||
assert 'QUTE_BUILDBOT' not in os.environ
|
|
||||||
try:
|
|
||||||
disp = xvfbwrapper.Xvfb(width=800, height=600, colordepth=16)
|
|
||||||
disp.start()
|
|
||||||
except EnvironmentError:
|
|
||||||
# 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()
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
@pytest.hookimpl(tryfirst=True, hookwrapper=True)
|
||||||
|
@ -113,7 +113,7 @@ Feature: Keyboard input
|
|||||||
Then the javascript message "key press: 88" should be logged
|
Then the javascript message "key press: 88" should be logged
|
||||||
And the javascript message "key release: 88" should be logged
|
And the javascript message "key release: 88" should be logged
|
||||||
|
|
||||||
@not_xvfb @posix
|
@no_xvfb @posix
|
||||||
Scenario: :fake-key sending key to the website with other window focused
|
Scenario: :fake-key sending key to the website with other window focused
|
||||||
When I open data/keyinput/log.html
|
When I open data/keyinput/log.html
|
||||||
And I set general -> developer-extras to true
|
And I set general -> developer-extras to true
|
||||||
|
@ -108,7 +108,7 @@ Feature: Various utility commands.
|
|||||||
And I run :inspector
|
And I run :inspector
|
||||||
Then the error "Please enable developer-extras before using the webinspector!" should be shown
|
Then the error "Please enable developer-extras before using the webinspector!" should be shown
|
||||||
|
|
||||||
@not_xvfb @posix
|
@no_xvfb @posix
|
||||||
Scenario: Inspector smoke test
|
Scenario: Inspector smoke test
|
||||||
When I set general -> developer-extras to true
|
When I set general -> developer-extras to true
|
||||||
And I run :inspector
|
And I run :inspector
|
||||||
@ -124,7 +124,7 @@ Feature: Various utility commands.
|
|||||||
Then the error "Please enable developer-extras before using the webinspector!" should be shown
|
Then the error "Please enable developer-extras before using the webinspector!" should be shown
|
||||||
|
|
||||||
# Different code path as an inspector got created now
|
# Different code path as an inspector got created now
|
||||||
@not_xvfb @posix
|
@no_xvfb @posix
|
||||||
Scenario: Inspector smoke test 2
|
Scenario: Inspector smoke test 2
|
||||||
When I set general -> developer-extras to true
|
When I set general -> developer-extras to true
|
||||||
And I run :inspector
|
And I run :inspector
|
||||||
@ -202,7 +202,7 @@ Feature: Various utility commands.
|
|||||||
|
|
||||||
# :debug-console
|
# :debug-console
|
||||||
|
|
||||||
@not_xvfb
|
@no_xvfb
|
||||||
Scenario: :debug-console smoke test
|
Scenario: :debug-console smoke test
|
||||||
When I run :debug-console
|
When I run :debug-console
|
||||||
And I wait for "Focus object changed: <qutebrowser.misc.consolewidget.ConsoleLineEdit *>" in the log
|
And I wait for "Focus object changed: <qutebrowser.misc.consolewidget.ConsoleLineEdit *>" in the log
|
||||||
|
2
tox.ini
2
tox.ini
@ -38,12 +38,12 @@ deps =
|
|||||||
pytest-travis-fold==1.2.0
|
pytest-travis-fold==1.2.0
|
||||||
pytest-repeat==0.2
|
pytest-repeat==0.2
|
||||||
pytest-rerunfailures==1.0.1
|
pytest-rerunfailures==1.0.1
|
||||||
|
pytest-xvfb==0.1.0
|
||||||
six==1.10.0
|
six==1.10.0
|
||||||
termcolor==1.1.0
|
termcolor==1.1.0
|
||||||
vulture==0.8.1
|
vulture==0.8.1
|
||||||
Werkzeug==0.11.4
|
Werkzeug==0.11.4
|
||||||
wheel==0.29.0
|
wheel==0.29.0
|
||||||
xvfbwrapper==0.2.8
|
|
||||||
cherrypy==5.0.1
|
cherrypy==5.0.1
|
||||||
commands =
|
commands =
|
||||||
{envpython} scripts/link_pyqt.py --tox {envdir}
|
{envpython} scripts/link_pyqt.py --tox {envdir}
|
||||||
|
Loading…
Reference in New Issue
Block a user