-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcase_test.py
More file actions
65 lines (55 loc) · 1.04 KB
/
case_test.py
File metadata and controls
65 lines (55 loc) · 1.04 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
from template import Template
from template.test import TestCase, main
class CaseTest(TestCase):
def testCase(self):
ttdef = Template({'POST_CHOMP': 1})
ttanycase = Template({'ANYCASE': 1, 'POST_CHOMP': 1})
tts = (('default', ttdef), ('anycase', ttanycase))
self.Expect(DATA, tts, self._callsign())
DATA = r"""
-- test --
[% include = a %]
[% for = b %]
i([% include %])
f([% for %])
-- expect --
i(alpha)
f(bravo)
-- test --
[% IF a AND b %]
good
[% ELSE %]
bad
[% END %]
-- expect --
good
-- test --
# 'and', 'or' and 'not' can ALWAYS be expressed in lower case, regardless
# of CASE sensitivity option.
[% IF a and b %]
good
[% ELSE %]
bad
[% END %]
-- expect --
good
-- test --
[% include = a %]
[% include %]
-- expect --
alpha
-- test --
-- use anycase --
[% include foo bar='baz' %]
[% BLOCK foo %]this is foo, bar = [% bar %][% END %]
-- expect --
this is foo, bar = baz
-- test --
[% 10 div 3 %] [% 10 DIV 3 +%]
[% 10 mod 3 %] [% 10 MOD 3 %]
-- expect --
3 3
1 1
"""
if __name__ == '__main__':
main()