~ubuntu-branches/ubuntu/wily/python-imaging/wily

« back to all changes in this revision

Viewing changes to Tests/test_file_gif.py

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-01-31 20:49:20 UTC
  • mfrom: (27.1.1 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20130131204920-b5zshy6vgfvdionl
Tags: 1.1.7+1.7.8-1ubuntu1
Rewrite build dependencies to allow cross builds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from tester import *
 
2
 
 
3
from PIL import Image
 
4
 
 
5
codecs = dir(Image.core)
 
6
 
 
7
if "gif_encoder" not in codecs or "gif_decoder" not in codecs:
 
8
    skip("gif support not available") # can this happen?
 
9
 
 
10
# sample gif stream
 
11
file = "Images/lena.gif"
 
12
data = open(file, "rb").read()
 
13
 
 
14
def test_sanity():
 
15
    im = Image.open(file)
 
16
    im.load()
 
17
    assert_equal(im.mode, "P")
 
18
    assert_equal(im.size, (128, 128))
 
19
    assert_equal(im.format, "GIF")
 
20
 
 
21
def test_optimize():
 
22
    def test(optimize):
 
23
        im = Image.new("L", (1, 1), 0)
 
24
        file = BytesIO()
 
25
        im.save(file, "GIF", optimize=optimize)
 
26
        return len(file.getvalue())
 
27
    assert_equal(test(0), 800)
 
28
    assert_equal(test(1), 32)