-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathblocks_test.py
More file actions
73 lines (58 loc) · 1.57 KB
/
blocks_test.py
File metadata and controls
73 lines (58 loc) · 1.57 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
import os
from template import Template
from template.test import TestCase, main
class BlocksTest(TestCase):
def testBlocks(self):
dir = os.getcwd() + "/test/lib"
tt1 = Template({'INCLUDE_PATH': ['test/lib'],
'ABSOLUTE': True})
tt2 = Template({'INCLUDE_PATH': ['test/lib'],
'EXPOSE_BLOCKS': True,
'ABSOLUTE': True})
vars = {'a': 'alpha', 'b': 'bravo', 'dir': dir}
self.Expect(DATA, (('off', tt1), ('on', tt2)), vars)
DATA = r"""
-- test --
[% TRY; INCLUDE blockdef/block1; CATCH; error; END %]
-- expect --
file error - blockdef/block1: not found
-- test --
-- use on --
[% INCLUDE blockdef/block1 %]
-- expect --
This is block 1, defined in blockdef, a is alpha
-- test --
[% INCLUDE blockdef/block1 a='amazing' %]
-- expect --
This is block 1, defined in blockdef, a is amazing
-- test --
[% TRY; INCLUDE blockdef/none; CATCH; error; END %]
-- expect --
file error - blockdef/none: not found
-- test --
[% INCLUDE "$dir/blockdef/block1" a='abstract' %]
-- expect --
This is block 1, defined in blockdef, a is abstract
-- test --
[% BLOCK one -%]
block one
[% BLOCK two -%]
this is block two, b is [% b %]
[% END -%]
two has been defined, let's now include it
[% INCLUDE one/two b='brilliant' -%]
end of block one
[% END -%]
[% INCLUDE one -%]
=
[% INCLUDE one/two b='brazen'-%]
--expect --
block one
two has been defined, let's now include it
this is block two, b is brilliant
end of block one
=
this is block two, b is brazen
"""
if __name__ == '__main__':
main()