Skip to content

Tests pass for PyQt5 but not PySide2 or PySide6 #5160

@hugovk

Description

@hugovk

What did you do?

python3 -m pip uninstall pyqt5 pyside2 -y
python3 -m pip install pyqt5  # currently 5.15.2
pytest Tests/test_*qt*
# Tests pass 👍

python3 -m pip uninstall pyqt5 pyside2 -y
python3 -m pip install pyside2  # currently 5.15.2
pytest Tests/test_*qt*
# Tests fail 👎 

What did you expect to happen?

Tests pass.

What actually happened?

...
Tests/test_imageqt.py ..                                                                                                                 [ 33%]
Tests/test_qt_image_fromqpixmap.py .                                                                                                     [ 50%]
Tests/test_qt_image_toqimage.py .F                                                                                                       [ 83%]
Tests/test_qt_image_toqpixmap.py E                                                                                                       [100%]

==================================================================== ERRORS ====================================================================
_________________________________________________ ERROR at setup of TestToQPixmap.test_sanity __________________________________________________

self = <class 'Tests.test_qt_image_toqpixmap.TestToQPixmap'>

    @classmethod
    def setup_class(self):
        try:
            if ImageQt.qt_version == "5":
                from PyQt5.QtGui import QGuiApplication
            elif ImageQt.qt_version == "side2":
                from PySide2.QtGui import QGuiApplication
        except ImportError:
            pytest.skip("QGuiApplication not installed")
            return

>       self.app = QGuiApplication([])
E       RuntimeError: Please destroy the QGuiApplication singleton before creating a new QGuiApplication instance.

Tests/test_imageqt.py:24: RuntimeError
=================================================================== FAILURES ===================================================================
________________________________________________________________ test_segfault _________________________________________________________________

    def test_segfault():
>       app = QApplication([])
E       RuntimeError: Please destroy the QGuiApplication singleton before creating a new QApplication instance.

Tests/test_qt_image_toqimage.py:55: RuntimeError
=========================================================== short test summary info ============================================================
ERROR Tests/test_qt_image_toqpixmap.py::TestToQPixmap::test_sanity - RuntimeError: Please destroy the QGuiApplication singleton before creati...
FAILED Tests/test_qt_image_toqimage.py::test_segfault - RuntimeError: Please destroy the QGuiApplication singleton before creating a new QApp...
===================================================== 1 failed, 4 passed, 1 error in 0.82s =====================================================

What are your OS, Python and Pillow versions?

  • OS: macOS Mojave
  • Python: 3.9.1
  • Pillow: master

A similar thing happens with PySide6 (6.0.0, once support added to Pillow).

We're only testing PyQt5 on the CI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QtQt for Python, PyQt, PySideTesting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions