Python 在CircleCI上运行pytest qt
我正在尝试在CircleCI上运行需要Python 在CircleCI上运行pytest qt,python,pytest,circleci,pytest-qt,Python,Pytest,Circleci,Pytest Qt,我正在尝试在CircleCI上运行需要pytest qt(用于测试PySide2对话框)的测试。我得到以下错误: xdpyinfo was not found, X start can not be checked! Please install xdpyinfo! ============================= test session starts ============================== platform linux -- Python 3.6.8, pyt
pytest qt
(用于测试PySide2对话框)的测试。我得到以下错误:
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
我正在使用此配置文件:
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
非常感谢您提供的任何帮助。我已在本地拉取容器
circleci/python:3.6.8-stretch
,克隆了您的存储库并尝试执行测试,而我可以重现错误
要做的第一件事是为Qt运行时启用调试模式,以便它打印一些错误信息。这可以通过设置环境变量QT\u DEBUG\u PLUGINS
:
$ QT_DEBUG_PLUGINS=1 pytest -sv
现在,运行测试的容器中缺少了什么就可以立即清除了。来自上述命令输出的代码段:
从插件元数据(“xcb”)获取密钥
QFactoryLoader::QFactoryLoader()正在检查目录路径“/usr/local/bin/platforms”。。。
无法加载library/home/circleci/.local/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so:(libxkbcommon-x11.so.0:无法打开共享对象文件:没有此类文件或目录)
QLibraryPrivate::loadPlugin在“/home/circleci/.local/lib/python3.6/site packages/PySide2/Qt/plugins/platforms/libqxcb.so”上失败:“无法加载库/home/circleci/.local/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so:(libxkbcommon-x11.so.0:无法打开共享对象文件:没有这样的文件或目录)”
qt.qpa.plugin:无法在“”中加载qt平台插件“xcb”,即使已找到该插件。
此应用程序无法启动,因为无法初始化Qt平台插件。重新安装应用程序可能会解决此问题。
可用的平台插件有:eglfs、linuxfb、minimal、minimalegl、offscreen、vnc、wayland egl、wayland、wayland xcomposite egl、wayland xcomposite glx、webgl、xcb。
中止(堆芯转储)
解决方法很简单-安装libxkbcommon-x11-0
软件包:
$ sudo apt update && sudo apt install -y libxkbcommon-x11-0
在CircleCI配置中添加这一行(在测试作业之前的某个位置,例如在安装包依赖项的作业中),测试应该可以正常运行
除此之外,全局设置QT_DEBUG_PLUGINS=1
是有意义的,这样您就可以在将来对最终的QT运行时故障做出反应
未找到xdpyinfo,无法检查X start!请安装xdpyinfo
如果要消除该警告,请安装x11 utils
:
$ sudo apt install x11-utils
仅在Centos6.5中运行:yum安装xdpyinfo并成功解决它您可以尝试读取转储的错误回溯吗?在
test\u label\u change\u on\u按钮中,按
函数,添加行import faulthandler
和faulthandler.enable()
,也许它会揭示错误。可能xfvb run
找不到显示,但如果没有错误消息,很难说。@hoefling看一看。