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

« back to all changes in this revision

Viewing changes to Tests/test_lib_image.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_setmode():
 
6
 
 
7
    im = Image.new("L", (1, 1), 255)
 
8
    im.im.setmode("1")
 
9
    assert_equal(im.im.getpixel((0, 0)), 255)
 
10
    im.im.setmode("L")
 
11
    assert_equal(im.im.getpixel((0, 0)), 255)
 
12
 
 
13
    im = Image.new("1", (1, 1), 1)
 
14
    im.im.setmode("L")
 
15
    assert_equal(im.im.getpixel((0, 0)), 255)
 
16
    im.im.setmode("1")
 
17
    assert_equal(im.im.getpixel((0, 0)), 255)
 
18
 
 
19
    im = Image.new("RGB", (1, 1), (1, 2, 3))
 
20
    im.im.setmode("RGB")
 
21
    assert_equal(im.im.getpixel((0, 0)), (1, 2, 3))
 
22
    im.im.setmode("RGBA")
 
23
    assert_equal(im.im.getpixel((0, 0)), (1, 2, 3, 255))
 
24
    im.im.setmode("RGBX")
 
25
    assert_equal(im.im.getpixel((0, 0)), (1, 2, 3, 255))
 
26
    im.im.setmode("RGB")
 
27
    assert_equal(im.im.getpixel((0, 0)), (1, 2, 3))
 
28
 
 
29
    assert_exception(ValueError, lambda: im.im.setmode("L"))
 
30
    assert_exception(ValueError, lambda: im.im.setmode("RGBABCDE"))