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

« back to all changes in this revision

Viewing changes to Tests/test_imagepath.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
from PIL import ImagePath
 
5
 
 
6
import array
 
7
 
 
8
def test_path():
 
9
 
 
10
    p = ImagePath.Path(list(range(10)))
 
11
 
 
12
    # sequence interface
 
13
    assert_equal(len(p), 5)
 
14
    assert_equal(p[0], (0.0, 1.0))
 
15
    assert_equal(p[-1], (8.0, 9.0))
 
16
    assert_equal(list(p[:1]), [(0.0, 1.0)])
 
17
    assert_equal(list(p), [(0.0, 1.0), (2.0, 3.0), (4.0, 5.0), (6.0, 7.0), (8.0, 9.0)])
 
18
 
 
19
    # method sanity check
 
20
    assert_equal(p.tolist(), [(0.0, 1.0), (2.0, 3.0), (4.0, 5.0), (6.0, 7.0), (8.0, 9.0)])
 
21
    assert_equal(p.tolist(1), [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0])
 
22
 
 
23
    assert_equal(p.getbbox(), (0.0, 1.0, 8.0, 9.0))
 
24
 
 
25
    assert_equal(p.compact(5), 2)
 
26
    assert_equal(list(p), [(0.0, 1.0), (4.0, 5.0), (8.0, 9.0)])
 
27
 
 
28
    p.transform((1,0,1,0,1,1))
 
29
    assert_equal(list(p), [(1.0, 2.0), (5.0, 6.0), (9.0, 10.0)])
 
30
 
 
31
    # alternative constructors
 
32
    p = ImagePath.Path([0, 1])
 
33
    assert_equal(list(p), [(0.0, 1.0)])
 
34
    p = ImagePath.Path([0.0, 1.0])
 
35
    assert_equal(list(p), [(0.0, 1.0)])
 
36
    p = ImagePath.Path([0, 1])
 
37
    assert_equal(list(p), [(0.0, 1.0)])
 
38
    p = ImagePath.Path([(0, 1)])
 
39
    assert_equal(list(p), [(0.0, 1.0)])
 
40
    p = ImagePath.Path(p)
 
41
    assert_equal(list(p), [(0.0, 1.0)])
 
42
    p = ImagePath.Path(p.tolist(0))
 
43
    assert_equal(list(p), [(0.0, 1.0)])
 
44
    p = ImagePath.Path(p.tolist(1))
 
45
    assert_equal(list(p), [(0.0, 1.0)])
 
46
    p = ImagePath.Path(array.array("f", [0, 1]))
 
47
    assert_equal(list(p), [(0.0, 1.0)])
 
48
    p = ImagePath.Path(array.array("f", [0, 1]).tostring())
 
49
    assert_equal(list(p), [(0.0, 1.0)])