Additional test images for sun raster files

This commit is contained in:
wiredfool 2016-11-22 06:47:33 -08:00
parent 816c74ac81
commit 82caa13a02
3 changed files with 35 additions and 0 deletions

View File

@ -48,6 +48,10 @@ install:
# libimagequant
- pushd depends && ./install_imagequant.sh && popd
# extra test images
- pushd depends && ./install_extra_test_images.sh && popd
before_script:
# Qt needs a display for some of the tests, and it's only run on the system site packages install
- "export DISPLAY=:99.0"

View File

@ -2,6 +2,9 @@ from helper import unittest, PillowTestCase, hopper
from PIL import Image, SunImagePlugin
import os
EXTRA_DIR = 'Tests/images/sunraster'
class TestFileSun(PillowTestCase):
@ -27,5 +30,22 @@ class TestFileSun(PillowTestCase):
target = Image.open('Tests/images/sunraster.im1.png')
self.assert_image_equal(im, target)
@unittest.skipIf(not os.path.exists(EXTRA_DIR),
"Extra image files not installed")
def test_others(self):
files = (os.path.join(EXTRA_DIR, f) for f in
os.listdir(EXTRA_DIR) if os.path.splitext(f)[1]
in ('.sun', '.SUN', '.ras'))
for path in files:
print (path)
with Image.open(path) as im:
im.load()
self.assertIsInstance(im, SunImagePlugin.SunImageFile)
target_path = "%s.png" % os.path.splitext(path)[0]
#im.save(target_file)
with Image.open(target_path) as target:
self.assert_image_equal(im, target)
if __name__ == '__main__':
unittest.main()

View File

@ -0,0 +1,11 @@
#!/bin/bash
# install extra test images
if [ ! -f test_images.tar.gz ]; then
wget -O 'test_images.tar.gz' 'https://github.com/python-pillow/pillow-depends/blob/master/test_images.tar.gz?raw=true'
fi
rm -r test_images
tar -xvzf test_images.tar.gz
cp -r test_images/* ../Tests/images