mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-26 15:14:45 +03:00
Merge dad0fd6d38
into ead5738961
This commit is contained in:
commit
8a2a88816f
|
@ -1,5 +1,5 @@
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper
|
||||||
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
from test_imageqt import PillowQPixmapTestCase
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
|
||||||
|
@ -7,10 +7,11 @@ from PIL import ImageQt
|
||||||
class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
||||||
|
|
||||||
def roundtrip(self, expected):
|
def roundtrip(self, expected):
|
||||||
PillowQtTestCase.setUp(self)
|
def test():
|
||||||
result = ImageQt.fromqpixmap(ImageQt.toqpixmap(expected))
|
result = ImageQt.fromqpixmap(ImageQt.toqpixmap(expected))
|
||||||
# Qt saves all pixmaps as rgb
|
# Qt saves all pixmaps as rgb
|
||||||
self.assert_image_equal(result, expected.convert('RGB'))
|
self.assert_image_equal(result, expected.convert('RGB'))
|
||||||
|
self.executeInSeparateProcess(test)
|
||||||
|
|
||||||
def test_sanity_1(self):
|
def test_sanity_1(self):
|
||||||
self.roundtrip(hopper('1'))
|
self.roundtrip(hopper('1'))
|
||||||
|
|
|
@ -25,7 +25,6 @@ if ImageQt.qt_is_installed:
|
||||||
class TestToQImage(PillowQtTestCase, PillowTestCase):
|
class TestToQImage(PillowQtTestCase, PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
PillowQtTestCase.setUp(self)
|
|
||||||
for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
|
for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
|
||||||
src = hopper(mode)
|
src = hopper(mode)
|
||||||
data = ImageQt.toqimage(src)
|
data = ImageQt.toqimage(src)
|
||||||
|
@ -61,12 +60,12 @@ class TestToQImage(PillowQtTestCase, PillowTestCase):
|
||||||
self.assert_image_equal(reloaded, src)
|
self.assert_image_equal(reloaded, src)
|
||||||
|
|
||||||
def test_segfault(self):
|
def test_segfault(self):
|
||||||
PillowQtTestCase.setUp(self)
|
def test():
|
||||||
|
app = QApplication([])
|
||||||
app = QApplication([])
|
ex = Example()
|
||||||
ex = Example()
|
assert(app) # Silence warning
|
||||||
assert(app) # Silence warning
|
assert(ex) # Silence warning
|
||||||
assert(ex) # Silence warning
|
self.executeInSeparateProcess(test)
|
||||||
|
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper
|
||||||
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
from test_imageqt import PillowQPixmapTestCase
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
|
||||||
|
@ -10,17 +10,17 @@ if ImageQt.qt_is_installed:
|
||||||
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
PillowQtTestCase.setUp(self)
|
def test():
|
||||||
|
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
|
||||||
|
data = ImageQt.toqpixmap(hopper(mode))
|
||||||
|
|
||||||
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
|
self.assertIsInstance(data, QPixmap)
|
||||||
data = ImageQt.toqpixmap(hopper(mode))
|
self.assertFalse(data.isNull())
|
||||||
|
|
||||||
self.assertIsInstance(data, QPixmap)
|
# Test saving the file
|
||||||
self.assertFalse(data.isNull())
|
tempfile = self.tempfile('temp_{}.png'.format(mode))
|
||||||
|
data.save(tempfile)
|
||||||
# Test saving the file
|
self.executeInSeparateProcess(test)
|
||||||
tempfile = self.tempfile('temp_{}.png'.format(mode))
|
|
||||||
data.save(tempfile)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -2,6 +2,7 @@ from helper import unittest, PillowTestCase, hopper
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
from PIL.ImageQt import qRgba
|
from PIL.ImageQt import qRgba
|
||||||
|
@ -18,6 +19,21 @@ class PillowQtTestCase(object):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
skip_if_qt_is_not_installed(self)
|
skip_if_qt_is_not_installed(self)
|
||||||
|
|
||||||
|
def executeInSeparateProcess(self, test):
|
||||||
|
def target():
|
||||||
|
if ImageQt.qt_version == '5':
|
||||||
|
from PyQt5.QtGui import QGuiApplication
|
||||||
|
elif ImageQt.qt_version == '4':
|
||||||
|
from PyQt4.QtGui import QGuiApplication
|
||||||
|
elif ImageQt.qt_version == 'side':
|
||||||
|
from PySide.QtGui import QGuiApplication
|
||||||
|
app = QGuiApplication([])
|
||||||
|
test()
|
||||||
|
app.quit()
|
||||||
|
p = multiprocessing.Process(target=target)
|
||||||
|
p.start()
|
||||||
|
p.join()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -36,12 +52,6 @@ class PillowQPixmapTestCase(PillowQtTestCase):
|
||||||
except ImportError:
|
except ImportError:
|
||||||
self.skipTest('QGuiApplication not installed')
|
self.skipTest('QGuiApplication not installed')
|
||||||
|
|
||||||
self.app = QGuiApplication([])
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
PillowQtTestCase.tearDown(self)
|
|
||||||
self.app.quit()
|
|
||||||
|
|
||||||
|
|
||||||
class TestImageQt(PillowQtTestCase, PillowTestCase):
|
class TestImageQt(PillowQtTestCase, PillowTestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user