pytest-dev / pytest-qt

pytest plugin for Qt (PyQt5/PyQt6 and PySide2/PySide6) application testing
https://pytest-qt.readthedocs.io
MIT License
409 stars 70 forks source link

Running pytest-qt with pytest-xvfb and importing QWebEnginePage leads to an X11 error in Github Actions #490

Closed sanjacob closed 1 year ago

sanjacob commented 1 year ago

Bug description

Running pytest-qt with pytest-xvfb and importing QWebEnginePage leads to an X11 error in Github Actions (ubuntu-latest).

Run pytest -vvvv

============================= test session starts ==============================
platform linux -- Python 3.10.11, pytest-7.3.1, pluggy-1.0.0 -- /opt/hostedtoolcache/Python/3.10.11/x64/bin/python
cachedir: .pytest_cache
PyQt5 5.15.9 -- Qt runtime 5.15.2 -- Qt compiled 5.15.2
rootdir: /home/runner/work/test-ga-pyqt-test/test-ga-pyqt-test
plugins: xvfb-2.0.0, qt-4.2.0
collecting ... collected 1 item

tests/test_qt.py::TestWorkflow::test_workflow_error PASSED               [100%]

============================== 1 passed in 0.63s ===============================
The X11 connection broke: I/O error (code 1)
XIO:  fatal IO error 0 (Success) on X server ":0"
      after 375 requests (373 known processed) with 0 events remaining.
Error: Process completed with exit code 1.

To Reproduce

To be run with pytest-xvfb:

import pytest
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtWidgets import QWidget

class TestWorkflow:

    def test_workflow_error(self, qtbot):
        widget = QWidget()
        qtbot.addWidget(widget)
        widget.show()
        assert widget.isVisible()
sanjacob commented 1 year ago

You can see a proof of concept on this repo: jacobszpz/test-ga-pyqt-test

The-Compiler commented 1 year ago

This doesn't seem like a pytest-qt issue, as it reproduces with just this:

import pytest

import sys
from PyQt5.QtWebEngineWidgets import QWebEnginePage
from PyQt5.QtWidgets import QWidget, QApplication

app = QApplication(sys.argv)

def test_widget():
    widget = QWidget()
    widget.show()

Assuming it's some sort of pytest-xvfb issue, though I'm still puzzled what's going on exactly. https://github.com/The-Compiler/pytest-xvfb/issues/11 would probably the right place to continue this.