Failing test for messed up P image on write only format

This commit is contained in:
wiredfool 2014-07-05 10:25:16 -07:00
parent a035ecc2ca
commit cedd8c2106
3 changed files with 33 additions and 4 deletions

View File

@ -14,7 +14,7 @@ python:
- 3.4
install:
- "sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-qt4 ghostscript libffi-dev cmake"
- "sudo apt-get -qq install libfreetype6-dev liblcms2-dev python-qt4 ghostscript libffi-dev cmake imagemagick"
- "pip install cffi"
- "pip install coveralls nose pyroma nose-cov"
- if [ "$TRAVIS_PYTHON_VERSION" == "2.6" ]; then pip install unittest2; fi

View File

@ -131,6 +131,17 @@ class PillowTestCase(unittest.TestCase):
self.addCleanup(self.delete_tempfile, path)
return path
def open_withImagemagick(self, f):
if not imagemagick_available():
raise IOError()
outfile = self.tempfile("temp.png")
if command_succeeds(['convert', f, outfile]):
from PIL import Image
return Image.open(outfile)
raise IOError()
# helpers
import sys
@ -194,4 +205,7 @@ def netpbm_available():
return command_succeeds(["ppmquant", "--help"]) and \
command_succeeds(["ppmtogif", "--help"])
def imagemagick_available():
return command_succeeds(['convert', '-version'])
# End of file

View File

@ -1,10 +1,11 @@
from helper import unittest, PillowTestCase, tearDownModule, lena
from helper import unittest, PillowTestCase, tearDownModule, lena, imagemagick_available
import os.path
class TestFilePalm(PillowTestCase):
_roundtrip = imagemagick_available()
def helper_save_as_palm(self, mode):
# Arrange
im = lena(mode)
@ -17,12 +18,25 @@ class TestFilePalm(PillowTestCase):
self.assertTrue(os.path.isfile(outfile))
self.assertGreater(os.path.getsize(outfile), 0)
def roundtrip(self, mode):
if not self._roundtrip:
return
im = lena(mode)
outfile = self.tempfile("temp.palm")
im.save(outfile)
converted = self.open_withImagemagick(outfile)
self.assert_image_equal(converted, im)
def test_monochrome(self):
# Arrange
mode = "1"
# Act / Assert
self.helper_save_as_palm(mode)
self.roundtrip(mode)
def test_p_mode(self):
# Arrange
@ -30,7 +44,8 @@ class TestFilePalm(PillowTestCase):
# Act / Assert
self.helper_save_as_palm(mode)
self.roundtrip(mode)
def test_rgb_ioerror(self):
# Arrange
mode = "RGB"