Pillow/Tests/test_image_toqimage.py

28 lines
683 B
Python
Raw Normal View History

from helper import unittest, PillowTestCase, hopper
from test_imageqt import PillowQtTestCase
from PIL import ImageQt
if ImageQt.qt_is_installed:
from PIL.ImageQt import QImage
class TestToQImage(PillowQtTestCase, PillowTestCase):
def test_sanity(self):
2015-06-19 08:35:56 +03:00
PillowQtTestCase.setUp(self)
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
data = ImageQt.toqimage(hopper(mode))
2015-06-21 09:31:51 +03:00
self.assertIsInstance(data, QImage)
self.assertFalse(data.isNull())
2015-06-21 09:31:51 +03:00
# Test saving the file
2015-06-29 06:50:17 +03:00
tempfile = self.tempfile('temp_{0}.png'.format(mode))
2015-06-21 09:31:51 +03:00
data.save(tempfile)
if __name__ == '__main__':
unittest.main()