当前位置: 首页 > 面试题库 >

在CircleCI上运行pytest-qt

盖嘉庆
2023-03-14
问题内容

我试图pytest-qt在CircleCI上运行需要(用于测试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_DEBUG_PLUGINS

$ QT_DEBUG_PLUGINS=1 pytest -sv

现在可以立即清除运行测试的容器中缺少的内容。上面命令输出的摘录:

Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/bin/platforms" ...
**Cannot load library /home/circleci/.local/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)**
QLibraryPrivate::loadPlugin failed on "/home/circleci/.local/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so" : "Cannot load library /home/circleci/.local/lib/python3.6/site-packages/PySide2/Qt/plugins/platforms/libqxcb.so: (libxkbcommon-x11.so.0: cannot open shared object file: No such file or directory)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

修复很容易-安装libxkbcommon-x11-0软件包:

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

将此行添加到CircleCI配置中(在测试作业之前的某个位置,例如在安装软件包依赖项的作业中),然后测试应该可以正常运行。

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

找不到xdpyinfo,无法检查X启动!请安装xdpyinfo!

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

$ sudo apt install x11-utils


 类似资料:
  • 面对使用覆盖率运行pytest时出现的问题,我已经浏览了SO帖子,但无法解决此问题,我相信我在这里遗漏了一些东西。。 获取以下错误,其中用户是我项目的应用程序 我的测试。ini文件内容 [pytest]DJANGO_设置_模块=cloudstack。设置 python\u文件=测试。py测试*。py*\u测试。py addopts=-v--ignore=venv--cov=--cov报告=html

  • null 在这些命令之后,您就进入了克隆的keras存储库,这是下面代码示例的工作目录。 首先,我想运行现有的测试,看看它们是做什么的。看起来它们可以简单地作为python文件运行: 但是这个: 我使用的是PyCharm,如果我从PyCharm中运行测试(我承认我首先尝试了),它只会产生上面的消息。 显然,我没有正确配置它。Pytest无法获取测试套件。为了找到一个参考配置,我查看了Keras C

  • CircleCI Documentation This is the public repository for CircleCI Docs, astatic website generated by Jekyll. If you find anyerrors in our docs or have suggestions, please follow our ContributingGuide

  • Ember-CircleCI CircleCI configuration generator for your Ember projects. The generated configuration is compatible with applications and addons.In addition, it uses parallel jobs to optimize CI time.

  • circleci-cli | Powerful CircleCI CLI via pure bash A pure bash, feature rich command line interface for CircleCI. Sample use cases: Programmatically interact with the CircleCI API OS X notification in

  • 我只是向类的构造函数添加了一些语句。 这直接导致了大约10项测试失败。 而不是摆弄那些测试,我只想在Python的优化中运行pytest,并打开(开关,这意味着都被忽略)。但是看了这些文件,搜索了一下,我找不到一个方法来做到这一点。 我有点想知道这是否是一种不好的做法,因为在测试期间可能是查看s是否失败的时候。 另一方面,另一个想法是,您可能有某些测试(集成测试等)。)应该在没有优化的情况下运行,

  • 这是我第一次使用circleCi(和Yii2),我面临一个与composer相关的问题:在这里您可以看到构建 正如您所看到的,composer找不到php的包 cebe/降价1.0。1需要php 我在这里能做什么?我在网上搜索没有成功。 谢谢和问候

  • 我希望看到输出正在打印(而不是在测试结束后)。 我在用Pycharm。在命令行中,我应该添加参数。