Skip to content

Commit

Permalink
Tests with xvfb on travis, requiring herbstluftwm
Browse files Browse the repository at this point in the history
A window manager is required to better test qt application under xvfb.
  • Loading branch information
parkouss committed Aug 19, 2018
1 parent 2791248 commit 29fd52d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
@@ -1,4 +1,4 @@
sudo: false
sudo: true
language: python
dist: trusty
python: 3.6
Expand All @@ -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
1 change: 1 addition & 0 deletions test-requirements.txt
Expand Up @@ -2,4 +2,5 @@
pytest
pytest-qt
pytest-mock
pytest-xvfb
flake8
25 changes: 24 additions & 1 deletion 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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 29fd52d

Please sign in to comment.