This commit is contained in:
Fahad Al-Saidi 2016-12-26 13:24:48 +00:00 committed by GitHub
commit 0410a75838
5 changed files with 31 additions and 1 deletions

View File

@ -4,6 +4,12 @@ from PIL import Image
import sys import sys
# The the default version of PyPy in Trusty is PyPy 5.4.1.
# There is a known error in it: TypeError: PyPy does not yet implement the new buffer interface (issue #2163).
SKIP_5_4_1_PYPY = hasattr(sys, 'pypy_version_info') and (
sys.pypy_version_info >= (5, 4, 1, 'final', 0))
# sample icon file # sample icon file
TEST_FILE = "Tests/images/pillow.icns" TEST_FILE = "Tests/images/pillow.icns"
@ -35,6 +41,7 @@ class TestFileIcns(PillowTestCase):
self.assertEqual(reread.size, (1024, 1024)) self.assertEqual(reread.size, (1024, 1024))
self.assertEqual(reread.format, "ICNS") self.assertEqual(reread.format, "ICNS")
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_sizes(self): def test_sizes(self):
# Check that we can load all of the sizes, and that the final pixel # Check that we can load all of the sizes, and that the final pixel
# dimensions are as expected # dimensions are as expected
@ -48,6 +55,7 @@ class TestFileIcns(PillowTestCase):
self.assertEqual(im2.mode, 'RGBA') self.assertEqual(im2.mode, 'RGBA')
self.assertEqual(im2.size, (wr, hr)) self.assertEqual(im2.size, (wr, hr))
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_older_icon(self): def test_older_icon(self):
# This icon was made with Icon Composer rather than iconutil; it still # This icon was made with Icon Composer rather than iconutil; it still
# uses PNG rather than JP2, however (since it was made on 10.9). # uses PNG rather than JP2, however (since it was made on 10.9).
@ -61,6 +69,7 @@ class TestFileIcns(PillowTestCase):
self.assertEqual(im2.mode, 'RGBA') self.assertEqual(im2.mode, 'RGBA')
self.assertEqual(im2.size, (wr, hr)) self.assertEqual(im2.size, (wr, hr))
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_jp2_icon(self): def test_jp2_icon(self):
# This icon was made by using Uli Kusterer's oldiconutil to replace # This icon was made by using Uli Kusterer's oldiconutil to replace
# the PNG images with JPEG 2000 ones. The advantage of doing this is # the PNG images with JPEG 2000 ones. The advantage of doing this is

View File

@ -1,8 +1,14 @@
from helper import unittest, PillowTestCase, hopper from helper import unittest, PillowTestCase, hopper
import io import io
import sys
from PIL import Image, IcoImagePlugin from PIL import Image, IcoImagePlugin
# The the default version of PyPy in Trusty is PyPy 5.4.1.
# There is a known error in it: TypeError: PyPy does not yet implement the new buffer interface (issue #2163).
SKIP_5_4_1_PYPY = hasattr(sys, 'pypy_version_info') and (
sys.pypy_version_info >= (5, 4, 1, 'final', 0))
# sample ppm stream # sample ppm stream
TEST_ICO_FILE = "Tests/images/hopper.ico" TEST_ICO_FILE = "Tests/images/hopper.ico"
@ -61,6 +67,7 @@ class TestFileIco(PillowTestCase):
# Assert # Assert
self.assertEqual(im_saved.size, (256, 256)) self.assertEqual(im_saved.size, (256, 256))
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_only_save_relevant_sizes(self): def test_only_save_relevant_sizes(self):
"""Issue #2266 https://github.com/python-pillow/Pillow/issues/2266 """Issue #2266 https://github.com/python-pillow/Pillow/issues/2266
Should save in 16x16, 24x24, 32x32, 48x48 sizes Should save in 16x16, 24x24, 32x32, 48x48 sizes

View File

@ -1,7 +1,13 @@
import sys
from helper import unittest, PillowTestCase, hopper from helper import unittest, PillowTestCase, hopper
from PIL import Image from PIL import Image
# The the default version of PyPy in Trusty is PyPy 5.4.1.
# There is a known error in it: TypeError: PyPy does not yet implement the new buffer interface (issue #2163).
SKIP_5_4_1_PYPY = hasattr(sys, 'pypy_version_info') and (
sys.pypy_version_info >= (5, 4, 1, 'final', 0))
im = hopper().resize((128, 100)) im = hopper().resize((128, 100))
@ -24,6 +30,7 @@ class TestImageArray(PillowTestCase):
self.assertEqual(test("RGBA"), (3, (100, 128, 4), '|u1', 51200)) self.assertEqual(test("RGBA"), (3, (100, 128, 4), '|u1', 51200))
self.assertEqual(test("RGBX"), (3, (100, 128, 4), '|u1', 51200)) self.assertEqual(test("RGBX"), (3, (100, 128, 4), '|u1', 51200))
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_fromarray(self): def test_fromarray(self):
class Wrapper(object): class Wrapper(object):

View File

@ -6,6 +6,12 @@ from PIL import Image
from PIL import ImageFile from PIL import ImageFile
from PIL import EpsImagePlugin from PIL import EpsImagePlugin
import sys
# The the default version of PyPy in Trusty is PyPy 5.4.1.
# There is a known error in it: TypeError: PyPy does not yet implement the new buffer interface (issue #2163).
SKIP_5_4_1_PYPY = hasattr(sys, 'pypy_version_info') and (
sys.pypy_version_info >= (5, 4, 1, 'final', 0))
codecs = dir(Image.core) codecs = dir(Image.core)
@ -71,6 +77,7 @@ class TestImageFile(PillowTestCase):
self.assertRaises(IOError, lambda: roundtrip("PDF")) self.assertRaises(IOError, lambda: roundtrip("PDF"))
@unittest.skipIf(SKIP_5_4_1_PYPY, "PyPy does not yet implement the new buffer interface")
def test_ico(self): def test_ico(self):
with open('Tests/images/python.ico', 'rb') as f: with open('Tests/images/python.ico', 'rb') as f:
data = f.read() data = f.read()

View File

@ -59,7 +59,7 @@ class TestImagePath(PillowTestCase):
if hasattr(arr, 'tobytes'): if hasattr(arr, 'tobytes'):
p = ImagePath.Path(arr.tobytes()) p = ImagePath.Path(arr.tobytes())
else: else:
p = ImagePath.Path(arr.tostring()) p = ImagePath.Path((arr.tostring(),))
self.assertEqual(list(p), [(0.0, 1.0)]) self.assertEqual(list(p), [(0.0, 1.0)])
def test_overflow_segfault(self): def test_overflow_segfault(self):