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.
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
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.