QApplication实例/qtbot固定装置导致travis-ci中止和核心转储 [英] QApplication instance/qtbot fixture causes travis-ci to abort and core dump

查看:151
本文介绍了QApplication实例/qtbot固定装置导致travis-ci中止和核心转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

致力于了解如何进行基于PySide2的应用程序的自动化单元测试.但是,每当我尝试在测试中初始化QApplication实例时,无论是通过PySide2本身还是通过pytest-qt的qtbot固定装置,travis-ci都将中止测试.但是,它可以在本地运行.

Working on understanding how to go about automated unit testing for PySide2-based applications. However, whenever I attempt to initialize a QApplication instance within the tests, be it through PySide2 itself or through pytest-qt's qtbot fixture, travis-ci aborts the test. It works locally, however.

我尝试使用pytest-qt中的qtbotqapp固定装置,尝试使用xenialtrusty等不同的travis-ci发行版,并包括pytest-xvfb插件可以看到类似的stackoverflow问题的答案所推荐的方法,但以上方法的任何组合均无效.

I've attempted using the qtbot and qapp fixtures from pytest-qt, trying different travis-ci distros like xenial and trusty, as well as including the pytest-xvfb plugin as I've seen recommended by a similar stackoverflow question's answer, but nothing worked in any combination of the above.

# .travis.yml
language: python
python:
  - "3.6"
cache: pip
dist: xenial
install: pip install -r requirements.txt
# running from top folder level to keep package on the path
script: python -m pytest tests/

# tests/test_central.py
from lysiaa.central import MyWindow

def test_giveBack(qapp):
    window = MyWindow()
    assert window.giveBack(1) == 1

# lysiaa/central.py
class MyWindow(QMainWindow):
    def __init__(self):
        super().__init__()

    def giveBack(self, param):
        return param

但是,当travis-ci尝试运行此命令时,它将因核心转储而中止.有人可以帮我解决这个问题吗?

When travis-ci tries running this, however, it aborts with a core dump. Could anyone please help me with this issue?

============================= test session starts ==============================
platform linux -- Python 3.6.7, pytest-4.5.0, py-1.8.0, pluggy-0.11.0
PySide2 5.12.3 -- Qt runtime 5.12.3 -- Qt compiled 5.12.3
rootdir: /home/travis/build/robert-clayton/LYSIAA
plugins: xvfb-1.2.0, qt-3.2.2
collected 1 item                                                               
tests/test_central.py /home/travis/.travis/functions: line 104:  4092 Aborted                 (core dumped) python -m pytest tests/
The command "python -m pytest tests/" exited with 134.

推荐答案

我刚刚想出了类似的项目.我认为这是相关的: 在CircleCI上运行pytest-qt

I just figured this out for a similar project. I think this is related: Running pytest-qt on CircleCI

我试图在Travis-CI中将QT_DEBUG_PLUGINS=1设置为环境变量,但没有得到任何信息.但是,我成功添加了

I tried to set QT_DEBUG_PLUGINS=1 as an environment variable in Travis-CI, but did not get any information out of that. However, I succeeded by adding

addons:
  apt:
    packages:
    - x11-utils
    - libxkbcommon-x11-0
services: xvfb
dist: xenial

.travis.yml.请注意,由于某些原因,您必须确保.travis.yml中没有before-install部分.

to .travis.yml. Note that for some reason you have to make sure that there is no before-install section in .travis.yml.

这是有效的travis.yml: https://github.com/AFM-analysis/PyJibe/blob/c4406fd712d778e2f644d6d03fce0db5688801bb/.travis.yml

Here is a working travis.yml: https://github.com/AFM-analysis/PyJibe/blob/c4406fd712d778e2f644d6d03fce0db5688801bb/.travis.yml

之前的Travis-CI: https://travis-ci.org/AFM-analysis/PyJibe/jobs/564834411

Travis-CI before: https://travis-ci.org/AFM-analysis/PyJibe/jobs/564834411

Trivis-CI之后: https://travis-ci.org/AFM-analysis/PyJibe/jobs/565690825

Trivis-CI after: https://travis-ci.org/AFM-analysis/PyJibe/jobs/565690825

这篇关于QApplication实例/qtbot固定装置导致travis-ci中止和核心转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆