diff --git a/.travis.yml b/.travis.yml index 36fca3d..c93aa25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -sudo: false +sudo: true language: python dist: trusty python: 3.6 @@ -10,7 +10,8 @@ cache: install: - pip install PyQt5 - pip install -r test-requirements.txt + - sudo apt-get --yes install xvfb herbstluftwm script: - flake8 webmacs setup.py - - pytest --ignore tests/integration/ tests + - pytest tests diff --git a/test-requirements.txt b/test-requirements.txt index a8c1bc5..c007b81 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,4 +2,5 @@ pytest pytest-qt pytest-mock +pytest-xvfb flake8 diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 919aae3..905617f 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -1,6 +1,7 @@ import pytest import os import time +import subprocess from PyQt5.QtTest import QTest from PyQt5.QtWebEngineWidgets import QWebEngineView @@ -37,8 +38,30 @@ def iter_widgets_for_events(w): yield w +@pytest.fixture(scope="session") +def wm(xvfb): + if xvfb is None: + yield None + else: + if not any( + os.access(os.path.join(path, 'herbstluftwm'), os.X_OK) + for path in os.environ["PATH"].split(os.pathsep) + ): + raise RuntimeError("herbstluftwm is not installed, can not run" + " graphical tests.") + env = dict(os.environ) + env["DISPLAY"] = str(":%s" % xvfb.display) + proc = subprocess.Popen( + ["herbstluftwm"], env=env + ) + time.sleep(2) # wait for the wm to be active + yield proc + proc.kill() + proc.wait() + + @pytest.fixture(scope='session') -def qapp(qapp_args): +def qapp(wm, qapp_args): _app_requires() global _app # TODO FIXME use another path for tests