在CircleCI上运行pytestqt

2024-05-15 15:01:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在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, 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

我正在使用这个配置文件:

^{pr2}$

如有任何帮助,我们将不胜感激。在


Tags: pytestprojecthomepytestnotqtcircleci
1条回答
网友
1楼 · 发布于 2024-05-15 15:01:58

我已经在本地提取了容器circleci/python:3.6.8-stretch,克隆了您的存储库并尝试执行测试,但是我可以重现错误。在

要做的第一件事是启用Qt运行时的调试模式,以便它打印错误信息。这可以通过设置环境变量QT_DEBUG_PLUGINS来完成:

$ QT_DEBUG_PLUGINS=1 pytest -sv

现在可以立即清除容器中缺少什么来运行测试。来自上述命令输出的代码段:

^{pr2}$

解决方法很简单-安装libxkbcommon-x11-0包:

$ sudo apt update && sudo apt install -y libxkbcommon-x11-0

在CircleCI配置中添加这一行(在测试作业之前的某个地方,例如在安装包依赖项的作业中),测试应该可以正常运行。在

除此之外,全局设置QT_DEBUG_PLUGINS=1是有意义的,这样您就可以在将来对Qt运行时的最终失败做出反应。在

xdpyinfo was not found, X start can not be checked! Please install xdpyinfo!

如果要消除该警告,请安装x11-utils

$ sudo apt install x11-utils

相关问题 更多 >