Pillow/Tests/test_image_getdata.py
Brian Crowell ad784eb808 py3k: Import Christoph Gohlke's test suite
This is Christoph Gohlke's test suite from his personal PIL package found
at http://www.lfd.uci.edu/~gohlke/pythonlibs/.

This is just to bring it in as a separate commit. Future commits will align
it with Pillow.
2013-01-10 08:46:39 -06:00

29 lines
845 B
Python

from tester import *
from PIL import Image
def test_sanity():
data = lena().getdata()
assert_no_exception(lambda: len(data))
assert_no_exception(lambda: list(data))
assert_equal(data[0], (223, 162, 133))
def test_roundtrip():
def getdata(mode):
im = lena(mode).resize((32, 30))
data = im.getdata()
return data[0], len(data), len(list(data))
assert_equal(getdata("1"), (255, 960, 960))
assert_equal(getdata("L"), (176, 960, 960))
assert_equal(getdata("I"), (176, 960, 960))
assert_equal(getdata("F"), (176.0, 960, 960))
assert_equal(getdata("RGB"), ((223, 162, 133), 960, 960))
assert_equal(getdata("RGBA"), ((223, 162, 133, 255), 960, 960))
assert_equal(getdata("CMYK"), ((32, 93, 122, 0), 960, 960))
assert_equal(getdata("YCbCr"), ((176, 103, 160), 960, 960))