mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-06-25 07:23:16 +03:00
Merge pull request #2394 from wiredfool/travis-docker
Additional docker builds, Arch and Debian Stretch, fix for QT tests.
This commit is contained in:
commit
5969a7445b
|
@ -9,22 +9,21 @@ notifications:
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
allow_failures:
|
|
||||||
- python: nightly
|
|
||||||
include:
|
include:
|
||||||
- python: "pypy"
|
- python: "pypy"
|
||||||
- python: "pypy3"
|
- python: "pypy3"
|
||||||
- python: '3.6'
|
- python: '3.6'
|
||||||
- python: '2.7'
|
- python: '2.7'
|
||||||
- env: DOCKER="alpine"
|
- env: DOCKER="alpine"
|
||||||
|
- env: DOCKER="arch" # contains PyQt5
|
||||||
- env: DOCKER="ubuntu-trusty-x86"
|
- env: DOCKER="ubuntu-trusty-x86"
|
||||||
- env: DOCKER="ubuntu-xenial-amd64"
|
- env: DOCKER="ubuntu-xenial-amd64"
|
||||||
- env: DOCKER="ubuntu-precise-amd64"
|
- env: DOCKER="ubuntu-precise-amd64"
|
||||||
|
- env: DOCKER="debian-stretch-x86"
|
||||||
- python: "2.7_with_system_site_packages" # For PyQt4
|
- python: "2.7_with_system_site_packages" # For PyQt4
|
||||||
- python: '3.5'
|
- python: '3.5'
|
||||||
- python: '3.4'
|
- python: '3.4'
|
||||||
- python: '3.3'
|
- python: '3.3'
|
||||||
- python: 'nightly'
|
|
||||||
|
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,12 @@ if sys.platform == 'win32':
|
||||||
else:
|
else:
|
||||||
IMCONVERT = 'convert'
|
IMCONVERT = 'convert'
|
||||||
|
|
||||||
|
def distro():
|
||||||
|
if os.path.exists('/etc/os-release'):
|
||||||
|
with open('/etc/os-release', 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
if 'ID=' in line:
|
||||||
|
return line.strip().split('=')[1]
|
||||||
|
|
||||||
class cached_property(object):
|
class cached_property(object):
|
||||||
def __init__(self, func):
|
def __init__(self, func):
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper, distro
|
||||||
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
|
||||||
|
@unittest.skipIf(ImageQt.qt_version == '5' and distro() == 'arch',
|
||||||
|
"Topixmap fails on Arch + QT5")
|
||||||
class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
class TestFromQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
||||||
|
|
||||||
def roundtrip(self, expected):
|
def roundtrip(self, expected):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper
|
||||||
from test_imageqt import PillowQtTestCase
|
from test_imageqt import PillowQtTestCase
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt, Image
|
||||||
|
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
|
@ -9,39 +9,66 @@ if ImageQt.qt_is_installed:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from PyQt5 import QtGui
|
from PyQt5 import QtGui
|
||||||
|
from PyQt5.QtWidgets import QWidget, QHBoxLayout, QLabel, QApplication
|
||||||
|
QT_VERSION = 5
|
||||||
except (ImportError, RuntimeError):
|
except (ImportError, RuntimeError):
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtGui
|
from PyQt4 import QtGui
|
||||||
|
from PyQt4.QtGui import QWidget, QHBoxLayout, QLabel, QApplication
|
||||||
|
QT_VERSION = 4
|
||||||
except (ImportError, RuntimeError):
|
except (ImportError, RuntimeError):
|
||||||
from PySide import QtGui
|
from PySide import QtGui
|
||||||
|
from PySide.QtGui import QWidget, QHBoxLayout, QLabel, QApplication
|
||||||
|
QT_VERSION = 4
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestToQImage(PillowQtTestCase, PillowTestCase):
|
class TestToQImage(PillowQtTestCase, PillowTestCase):
|
||||||
|
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
PillowQtTestCase.setUp(self)
|
PillowQtTestCase.setUp(self)
|
||||||
for mode in ('1', 'RGB', 'RGBA', 'L', 'P'):
|
for mode in ('RGB', 'RGBA', 'L', 'P', '1'):
|
||||||
data = ImageQt.toqimage(hopper(mode))
|
src = hopper(mode)
|
||||||
|
data = ImageQt.toqimage(src)
|
||||||
|
|
||||||
self.assertIsInstance(data, QImage)
|
self.assertIsInstance(data, QImage)
|
||||||
self.assertFalse(data.isNull())
|
self.assertFalse(data.isNull())
|
||||||
|
|
||||||
|
# reload directly from the qimage
|
||||||
|
rt = ImageQt.fromqimage(data)
|
||||||
|
if mode in ('L', 'P', '1'):
|
||||||
|
self.assert_image_equal(rt, src.convert('RGB'))
|
||||||
|
else:
|
||||||
|
self.assert_image_equal(rt, src)
|
||||||
|
|
||||||
|
if mode == '1':
|
||||||
|
# BW appears to not save correctly on QT4 and QT5
|
||||||
|
# kicks out errors on console:
|
||||||
|
# libpng warning: Invalid color type/bit depth combination in IHDR
|
||||||
|
# libpng error: Invalid IHDR data
|
||||||
|
continue
|
||||||
|
|
||||||
# Test saving the file
|
# Test saving the file
|
||||||
tempfile = self.tempfile('temp_{}.png'.format(mode))
|
tempfile = self.tempfile('temp_{}.png'.format(mode))
|
||||||
data.save(tempfile)
|
data.save(tempfile)
|
||||||
|
|
||||||
|
# Check that it actually worked.
|
||||||
|
reloaded = Image.open(tempfile)
|
||||||
|
# Gray images appear to come back in palette mode.
|
||||||
|
# They're roughly equivalent
|
||||||
|
if QT_VERSION == 4 and mode == 'L':
|
||||||
|
src = src.convert('P')
|
||||||
|
self.assert_image_equal(reloaded, src)
|
||||||
|
|
||||||
|
|
||||||
def test_segfault(self):
|
def test_segfault(self):
|
||||||
PillowQtTestCase.setUp(self)
|
PillowQtTestCase.setUp(self)
|
||||||
|
|
||||||
app = QtGui.QApplication([])
|
app = QApplication([])
|
||||||
ex = Example()
|
ex = Example()
|
||||||
|
|
||||||
|
|
||||||
if ImageQt.qt_is_installed:
|
if ImageQt.qt_is_installed:
|
||||||
class Example(QtGui.QWidget):
|
class Example(QWidget):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(Example, self).__init__()
|
super(Example, self).__init__()
|
||||||
|
@ -52,9 +79,9 @@ if ImageQt.qt_is_installed:
|
||||||
|
|
||||||
pixmap1 = QtGui.QPixmap.fromImage(qimage)
|
pixmap1 = QtGui.QPixmap.fromImage(qimage)
|
||||||
|
|
||||||
hbox = QtGui.QHBoxLayout(self)
|
hbox = QHBoxLayout(self)
|
||||||
|
|
||||||
lbl = QtGui.QLabel(self)
|
lbl = QLabel(self)
|
||||||
# Segfault in the problem
|
# Segfault in the problem
|
||||||
lbl.setPixmap(pixmap1.copy())
|
lbl.setPixmap(pixmap1.copy())
|
||||||
|
|
||||||
|
@ -62,7 +89,7 @@ if ImageQt.qt_is_installed:
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = QtGui.QApplication(sys.argv)
|
app = QApplication(sys.argv)
|
||||||
ex = Example()
|
ex = Example()
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from helper import unittest, PillowTestCase, hopper
|
from helper import unittest, PillowTestCase, hopper, distro
|
||||||
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
from test_imageqt import PillowQtTestCase, PillowQPixmapTestCase
|
||||||
|
|
||||||
from PIL import ImageQt
|
from PIL import ImageQt
|
||||||
|
@ -9,6 +9,8 @@ if ImageQt.qt_is_installed:
|
||||||
|
|
||||||
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
class TestToQPixmap(PillowQPixmapTestCase, PillowTestCase):
|
||||||
|
|
||||||
|
@unittest.skipIf(ImageQt.qt_version == '5' and distro() == 'arch',
|
||||||
|
"Topixmap fails on Arch + QT5")
|
||||||
def test_sanity(self):
|
def test_sanity(self):
|
||||||
PillowQtTestCase.setUp(self)
|
PillowQtTestCase.setUp(self)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user