Pillow/Tests/test_qt_image_toqpixmap.py
2020-02-23 00:06:21 +11:00

21 lines
589 B
Python

from PIL import ImageQt
from .helper import PillowTestCase, hopper
from .test_imageqt import PillowQPixmapTestCase
if ImageQt.qt_is_installed:
from PIL.ImageQt import QPixmap
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
def test_sanity(self):
for mode in ("1", "RGB", "RGBA", "L", "P"):
data = ImageQt.toqpixmap(hopper(mode))
assert isinstance(data, QPixmap)
assert not data.isNull()
# Test saving the file
tempfile = self.tempfile("temp_{}.png".format(mode))
data.save(tempfile)