I am attempting to run tests which require pytest-qt
(for testing PySide2 dialogs) on CircleCI. I am getting the following error:
xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-5.0.0, py-1.8.0, pluggy-0.12.0 -- /home/circleci/project-caveman/venv/bin/python3
cachedir: .pytest_cache
PySide2 5.13.0 -- Qt runtime 5.13.0 -- Qt compiled 5.13.0
rootdir: /home/circleci/project-caveman
plugins: cov-2.7.1, xvfb-1.2.0, qt-3.2.2
collected 1 item
tests/test_main.py::test_label_change_on_button_press Fatal Python error: Aborted
Aborted (core dumped)
Exited with code 134
And I am using this configuration file:
version: 2
jobs:
build:
working_directory: ~/project-caveman
docker:
- image: circleci/python:3.6.8-stretch
steps:
- checkout
# Dependencies
- restore_cache:
keys:
- venv-{{ .Branch }}-{{ checksum "setup.py" }}
- venv-{{ .Branch }}-
- venv-
- run:
name: Install dependencies
command: |
python3 -m venv venv
. venv/bin/activate
pip install -e .[test] --progress-bar off
- save_cache:
key: venv-{{ .Branch }}-{{ checksum "setup.py" }}
paths:
- "venv"
# Tests
- run:
name: Pytest
command: |
mkdir test-reports
. venv/bin/activate
xvfb-run -a pytest -s -v --doctest-modules --junitxml test-reports/junit.xml --cov=coveralls --cov-report term-missing
- store_test_results:
path: test-reports
- run:
name: Coveralls
command: coveralls
Any help is greatly appreciated, thanks in advance.
I have pulled the container
circleci/python:3.6.8-stretch
locally, cloned your repository and tried to execute the tests, whereas I could reproduce the error.First thing to do is to enable the debug mode for Qt runtime so it prints some info on errors. This can be done by settings the environment variable
QT_DEBUG_PLUGINS
:Now it's immediately clear what's missing in the container to run the tests. A snippet from the output of the above command:
The fix for that is easy - install the
libxkbcommon-x11-0
package:Add this line in the CircleCI config (somewhere before the tests job, for example in the job where you install package dependencies) and the test should run fine.
Aside from that, it makes sense to set
QT_DEBUG_PLUGINS=1
globally so you can react on eventual Qt runtime failures in future.If you want to get rid of that warning, install
x11-utils
: