MCPcopy Index your code
hub / github.com/python-pillow/Pillow / test_path

Function test_path

Tests/test_imagepath.py:13–43  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13def test_path() -> None:
14 p = ImagePath.Path(list(range(10)))
15
16 # sequence interface
17 assert len(p) == 5
18 assert p[0] == (0.0, 1.0)
19 assert p[-1] == (8.0, 9.0)
20 assert list(p[:1]) == [(0.0, 1.0)]
21 assert list(p[-1:]) == [(8.0, 9.0)]
22 with pytest.raises(TypeError) as cm:
23 p["foo"]
24 assert str(cm.value) == "Path indices must be integers, not str"
25 assert list(p) == [(0.0, 1.0), (2.0, 3.0), (4.0, 5.0), (6.0, 7.0), (8.0, 9.0)]
26
27 # method sanity check
28 assert p.tolist() == [
29 (0.0, 1.0),
30 (2.0, 3.0),
31 (4.0, 5.0),
32 (6.0, 7.0),
33 (8.0, 9.0),
34 ]
35 assert p.tolist(True) == [0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
36
37 assert p.getbbox() == (0.0, 1.0, 8.0, 9.0)
38
39 assert p.compact(5) == 2
40 assert list(p) == [(0.0, 1.0), (4.0, 5.0), (8.0, 9.0)]
41
42 p.transform((1, 0, 1, 0, 1, 1))
43 assert list(p) == [(1.0, 2.0), (5.0, 6.0), (9.0, 10.0)]
44
45
46@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 2

getbboxMethod · 0.45
transformMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…