Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug report: test failures with PyQt5 #1255

Open
opoplawski opened this issue Aug 14, 2023 · 4 comments
Open

Bug report: test failures with PyQt5 #1255

opoplawski opened this issue Aug 14, 2023 · 4 comments

Comments

@opoplawski
Copy link
Contributor

Environment

OS: Fedora Rawhide
Python version: 3.12
Toolkit: Qt 5.15.10
Qt API: PyQt5 5.15.9

Description

======================================================================
ERROR: test_create_bitmap (pyface.tests.test_pil_image.TestPILImage.test_create_bitmap)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/tests/test_pil_image.py", line 52, in test_create_bitmap
    bitmap = image.create_bitmap()
             ^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/i_pil_image.py", line 55, in create_bitmap
    return image_to_bitmap(self.create_image(size))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/ui/qt/util/image_helpers.py", line 48, in image_to_bitmap
    bitmap = QPixmap.fromImage(image)
             ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: fromImage(image: QImage, flags: Union[Qt.ImageConversionFlags, Qt.ImageConversionFlag] = Qt.AutoColor): argument 1 has unexpected type 'ImageQt'
======================================================================
ERROR: test_create_icon (pyface.tests.test_pil_image.TestPILImage.test_create_icon)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/tests/test_pil_image.py", line 59, in test_create_icon
    icon = image.create_icon()
           ^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/i_pil_image.py", line 73, in create_icon
    return bitmap_to_icon(self.create_bitmap(size))
                          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/i_pil_image.py", line 55, in create_bitmap
    return image_to_bitmap(self.create_image(size))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/builddir/build/BUILDROOT/python-pyface-8.0.0-1.fc40~bootstrap.noarch/usr/lib/python3.12/site-packages/pyface/ui/qt/util/image_helpers.py", line 48, in image_to_bitmap
    bitmap = QPixmap.fromImage(image)
             ^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: fromImage(image: QImage, flags: Union[Qt.ImageConversionFlags, Qt.ImageConversionFlag] = Qt.AutoColor): argument 1 has unexpected type 'ImageQt'
----------------------------------------------------------------------

Steps to Reproduce

+ export QT_API=pyqt5
+ QT_API=pyqt5
+ case $toolkit in
+ export ETS_TOOLKIT=qt
+ ETS_TOOLKIT=qt
+ export EXCLUDE_TESTS=wx
+ EXCLUDE_TESTS=wx
+ xvfb-run /usr/bin/python3 -Xfaulthandler -s -m unittest discover -v pyface
@corranwebster
Copy link
Contributor

Which version of Pillow are you using? Pillow dropped support for Qt5 in Pillow 10 so we've been seeing issues with other ETS projects when pip-installing Pillow into Qt5-based environments.

@opoplawski
Copy link
Contributor Author

This is indeed with pillow 10.0.0. Is this a show stopper for pyface and Qt5 then?

@corranwebster
Copy link
Contributor

corranwebster commented Aug 17, 2023

The only work-around is to restrict to pillow < 10.0 or not use Pillow at all.

Pillow is nominally an optional dependency of Pyface for Qt backends - it should work without Pillow installed as long as the application code avoids using PILImage. I expect that if you test in an environment without Pillow installed, tests should pass (the PILImage tests will be skipped).

The end-user failure mode if pillow 10 is installed will only occur if a PILImage is created by application code. PILImage is a fairly new class, so it's probably not in a lot of downstream code.

I don't know if this helps your use-case.

@opoplawski
Copy link
Contributor Author

Thank you, that's very helpful information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants