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

« back to all changes in this revision

Viewing changes to Tests/test_image_getdata.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
def test_sanity():
 
6
 
 
7
    data = lena().getdata()
 
8
 
 
9
    assert_no_exception(lambda: len(data))
 
10
    assert_no_exception(lambda: list(data))
 
11
 
 
12
    assert_equal(data[0], (223, 162, 133))
 
13
 
 
14
def test_roundtrip():
 
15
 
 
16
    def getdata(mode):
 
17
        im = lena(mode).resize((32, 30))
 
18
        data = im.getdata()
 
19
        return data[0], len(data), len(list(data))
 
20
 
 
21
    assert_equal(getdata("1"), (255, 960, 960))
 
22
    assert_equal(getdata("L"), (176, 960, 960))
 
23
    assert_equal(getdata("I"), (176, 960, 960))
 
24
    assert_equal(getdata("F"), (176.0, 960, 960))
 
25
    assert_equal(getdata("RGB"), ((223, 162, 133), 960, 960))
 
26
    assert_equal(getdata("RGBA"), ((223, 162, 133, 255), 960, 960))
 
27
    assert_equal(getdata("CMYK"), ((32, 93, 122, 0), 960, 960))
 
28
    assert_equal(getdata("YCbCr"), ((176, 103, 160), 960, 960))