-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathimage_test.py
More file actions
84 lines (70 loc) · 1.82 KB
/
image_test.py
File metadata and controls
84 lines (70 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import os
import sys
from unittest import skipIf
from template.test import TestCase, main
PY3 = sys.version_info[0] >= 3
@skipIf(PY3, 'Not working on PY3')
class ImageTest(TestCase):
def testImage(self):
dir = os.path.join(os.pardir, "images")
vars = {"dir": dir,
"file": {"logo": os.path.join(dir, "ttdotorg.gif"),
"power": os.path.join(dir, "tt2power.gif"),
"lname": "ttdotorg.gif"}}
self.Expect(DATA, None, vars)
DATA = r"""
-- test --
[% USE Image(file.logo) -%]
file: [% Image.file %]
size: [% Image.size.join(', ') %]
width: [% Image.width %]
height: [% Image.height %]
-- expect --
-- process --
file: [% file.logo %]
size: 110, 60
width: 110
height: 60
-- test --
[% USE image( name = file.power) -%]
name: [% image.name %]
file: [% image.file %]
width: [% image.width %]
height: [% image.height %]
size: [% image.size.join(', ') %]
-- expect --
-- process --
name: [% file.power %]
file: [% file.power %]
width: 78
height: 47
size: 78, 47
-- test --
[% USE image file.logo -%]
attr: [% image.attr %]
-- expect --
attr: width="110" height="60"
-- test --
[% USE image file.logo -%]
tag: [% image.tag %]
tag: [% image.tag(class="myimage", alt="image") %]
-- expect --
-- process --
tag: <img src="[% file.logo %]" width="110" height="60" alt="" />
tag: <img src="[% file.logo %]" width="110" height="60" alt="image" class="myimage" />
# test "root"
-- test --
[% USE image( root=dir name=file.lname ) -%]
[% image.tag %]
-- expect --
-- process --
<img src="[% file.lname %]" width="110" height="60" alt="" />
# test separate file and name
-- test --
[% USE image( file= file.logo name = "other.jpg" alt="myfile") -%]
[% image.tag %]
-- expect --
<img src="other.jpg" width="110" height="60" alt="myfile" />
"""
if __name__ == '__main__':
main()