2014-09-15 22:24:56 +04:00
|
|
|
from helper import unittest, PillowTestCase, hopper
|
2015-06-19 08:35:56 +03:00
|
|
|
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
2014-09-15 22:24:56 +04:00
|
|
|
|
|
|
|
from PIL import ImageQt
|
|
|
|
|
|
|
|
if ImageQt.qt_is_installed:
|
|
|
|
from PIL.ImageQt import QPixmap
|
|
|
|
|
|
|
|
|
|
|
|
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
|
|
|
|
|
|
|
def test_sanity(self):
|
2015-06-19 08:35:56 +03:00
|
|
|
PillowQtTestCase.setUp(self)
|
2015-06-21 09:31:51 +03:00
|
|
|
|
2014-09-15 22:24:56 +04:00
|
|
|
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
|
|
|
|
data = ImageQt.toqpixmap(hopper(mode))
|
2015-06-21 09:31:51 +03:00
|
|
|
|
2014-09-15 22:24:56 +04:00
|
|
|
self.assertTrue(isinstance(data, QPixmap))
|
|
|
|
self.assertFalse(data.isNull())
|
|
|
|
|
2015-06-21 09:31:51 +03:00
|
|
|
# Test saving the file
|
2015-06-29 07:59:05 +03:00
|
|
|
tempfile = self.tempfile('temp_{0}.png'.format(mode))
|
2015-06-21 09:31:51 +03:00
|
|
|
data.save(tempfile)
|
|
|
|
|
2014-09-15 22:24:56 +04:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|
|
|
|
|
|
|
|
# End of file
|