~jonas-drange/ubuntu-start-page/1252899-mobile-friendly

« back to all changes in this revision

Viewing changes to src/Mako-0.1.9/test/lexer.py

  • Committer: Matthew Nuzum
  • Date: 2008-04-18 01:58:53 UTC
  • Revision ID: matthew.nuzum@canonical.com-20080418015853-2b8rf979z2c2exxl
adding files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
 
 
3
from mako.lexer import Lexer
 
4
from mako import exceptions
 
5
from util import flatten_result, result_lines
 
6
from mako.template import Template
 
7
import re
 
8
 
 
9
class LexerTest(unittest.TestCase):
 
10
    def test_text_and_tag(self):
 
11
        template = """
 
12
<b>Hello world</b>
 
13
        <%def name="foo()">
 
14
                this is a def.
 
15
        </%def>
 
16
        
 
17
        and some more text.
 
18
"""
 
19
        node = Lexer(template).parse()
 
20
        assert repr(node) == r"""TemplateNode({}, [Text(u'\n<b>Hello world</b>\n        ', (1, 1)), DefTag(u'def', {u'name': u'foo()'}, (3, 9), ["Text(u'\\n                this is a def.\\n        ', (3, 28))"]), Text(u'\n        \n        and some more text.\n', (5, 16))])"""
 
21
 
 
22
    def test_unclosed_tag(self):
 
23
        template = """
 
24
        
 
25
            <%def name="foo()">
 
26
             other text
 
27
        """
 
28
        try:
 
29
            nodes = Lexer(template).parse()
 
30
            assert False
 
31
        except exceptions.SyntaxException, e:
 
32
            assert str(e) == "Unclosed tag: <%def> at line: 5 char: 9"
 
33
 
 
34
    def test_onlyclosed_tag(self):
 
35
        template = """
 
36
            <%def name="foo()">
 
37
                foo
 
38
            </%def>
 
39
            
 
40
            </%namespace>
 
41
            
 
42
            hi.
 
43
        """
 
44
        try:
 
45
            nodes = Lexer(template).parse()
 
46
            assert False
 
47
        except exceptions.SyntaxException, e:
 
48
            assert str(e) == "Closing tag without opening tag: </%namespace> at line: 6 char: 13"
 
49
 
 
50
    def test_unmatched_tag(self):
 
51
        template = """
 
52
        <%namespace name="bar">
 
53
        <%def name="foo()">
 
54
            foo
 
55
            </%namespace>
 
56
        </%def>
 
57
        
 
58
        
 
59
        hi.
 
60
"""
 
61
        try:
 
62
            nodes = Lexer(template).parse()
 
63
            assert False
 
64
        except exceptions.SyntaxException, e:
 
65
            assert str(e) == "Closing tag </%namespace> does not match tag: <%def> at line: 5 char: 13"
 
66
 
 
67
    def test_nonexistent_tag(self):
 
68
        template = """
 
69
            <%lala x="5"/>
 
70
        """
 
71
        try:
 
72
            node = Lexer(template).parse()
 
73
            assert False
 
74
        except exceptions.CompileException, e:
 
75
            assert str(e) == "No such tag: 'lala' at line: 2 char: 13"
 
76
    
 
77
    def test_text_tag(self):
 
78
        template = """
 
79
        ## comment
 
80
        % if foo:
 
81
            hi
 
82
        % endif
 
83
        <%text>
 
84
            # more code
 
85
            
 
86
            % more code
 
87
            <%illegal compionent>/></>
 
88
            <%def name="laal()">def</%def>
 
89
            
 
90
            
 
91
        </%text>
 
92
 
 
93
        <%def name="foo()">this is foo</%def>
 
94
        
 
95
        % if bar:
 
96
            code
 
97
        % endif
 
98
        """
 
99
        node = Lexer(template).parse()
 
100
        assert repr(node) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), Comment(u'comment', (2, 1)), ControlLine(u'if', u'if foo:', False, (3, 1)), Text(u'            hi\n', (4, 1)), ControlLine(u'if', u'endif', True, (5, 1)), Text(u'        ', (6, 1)), TextTag(u'text', {}, (6, 9), ['Text(u\'\\n            # more code\\n            \\n            % more code\\n            <%illegal compionent>/></>\\n            <%def name="laal()">def</%def>\\n            \\n            \\n        \', (6, 16))']), Text(u'\n\n        ', (14, 17)), DefTag(u'def', {u'name': u'foo()'}, (16, 9), ["Text(u'this is foo', (16, 28))"]), Text(u'\n        \n', (16, 46)), ControlLine(u'if', u'if bar:', False, (18, 1)), Text(u'            code\n', (19, 1)), ControlLine(u'if', u'endif', True, (20, 1)), Text(u'        ', (21, 1))])"""
 
101
        
 
102
    def test_def_syntax(self):
 
103
        template = """
 
104
        <%def lala>
 
105
            hi
 
106
        </%def>
 
107
"""
 
108
        try:
 
109
            node = Lexer(template).parse()
 
110
            assert False
 
111
        except exceptions.CompileException, e:
 
112
            assert str(e) == "Missing attribute(s): 'name' at line: 2 char: 9"
 
113
    
 
114
    def test_def_syntax_2(self):
 
115
        template = """
 
116
        <%def name="lala">
 
117
            hi
 
118
        </%def>
 
119
    """
 
120
        try:
 
121
            node = Lexer(template).parse()
 
122
            assert False
 
123
        except exceptions.CompileException, e:
 
124
            assert str(e) == "Missing parenthesis in %def at line: 2 char: 9"
 
125
                
 
126
    def test_expr_in_attribute(self):
 
127
        """test some slightly trickier expressions.
 
128
        
 
129
        you can still trip up the expression parsing, though, unless we integrated really deeply somehow with AST."""
 
130
        template = """
 
131
            <%call expr="foo>bar and 'lala' or 'hoho'"/>
 
132
            <%call expr='foo<bar and hoho>lala and "x" + "y"'/>
 
133
        """
 
134
        nodes = Lexer(template).parse()
 
135
        #print nodes
 
136
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n            ', (1, 1)), CallTag(u'call', {u'expr': u"foo>bar and 'lala' or 'hoho'"}, (2, 13), []), Text(u'\n            ', (2, 57)), CallTag(u'call', {u'expr': u'foo<bar and hoho>lala and "x" + "y"'}, (3, 13), []), Text(u'\n        ', (3, 64))])"""
 
137
        
 
138
    def test_pagetag(self):
 
139
        template = """
 
140
            <%page cached="True", args="a, b"/>
 
141
            
 
142
            some template
 
143
        """    
 
144
        nodes = Lexer(template).parse()
 
145
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n            ', (1, 1)), PageTag(u'page', {u'cached': u'True', u'args': u'a, b'}, (2, 13), []), Text(u'\n            \n            some template\n        ', (2, 48))])"""
 
146
        
 
147
    def test_nesting(self):
 
148
        template = """
 
149
        
 
150
        <%namespace name="ns">
 
151
            <%def name="lala(hi, there)">
 
152
                <%call expr="something()"/>
 
153
            </%def>
 
154
        </%namespace>
 
155
        
 
156
        """
 
157
        nodes = Lexer(template).parse()
 
158
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        \n        ', (1, 1)), NamespaceTag(u'namespace', {u'name': u'ns'}, (3, 9), ["Text(u'\\n            ', (3, 31))", 'DefTag(u\'def\', {u\'name\': u\'lala(hi, there)\'}, (4, 13), ["Text(u\'\\\\n                \', (4, 42))", "CallTag(u\'call\', {u\'expr\': u\'something()\'}, (5, 17), [])", "Text(u\'\\\\n            \', (5, 44))"])', "Text(u'\\n        ', (6, 20))"]), Text(u'\n        \n        ', (7, 22))])"""
 
159
    
 
160
    def test_code(self):
 
161
        template = """
 
162
        some text
 
163
        
 
164
        <%
 
165
            print "hi"
 
166
            for x in range(1,5):
 
167
                print x
 
168
        %>
 
169
        
 
170
        more text
 
171
        
 
172
        <%!
 
173
            import foo
 
174
        %>
 
175
        """
 
176
        nodes = Lexer(template).parse()
 
177
        #print nodes
 
178
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        some text\n        \n        ', (1, 1)), Code(u'\nprint "hi"\nfor x in range(1,5):\n    print x\n        \n', False, (4, 9)), Text(u'\n        \n        more text\n        \n        ', (8, 11)), Code(u'\nimport foo\n        \n', True, (12, 9)), Text(u'\n        ', (14, 11))])"""
 
179
    
 
180
    def test_code_and_tags(self):
 
181
        template = """
 
182
<%namespace name="foo">
 
183
    <%def name="x()">
 
184
        this is x
 
185
    </%def>
 
186
    <%def name="y()">
 
187
        this is y
 
188
    </%def>
 
189
</%namespace>
 
190
 
 
191
<%
 
192
    result = []
 
193
    data = get_data()
 
194
    for x in data:
 
195
        result.append(x+7)
 
196
%>
 
197
 
 
198
    result: <%call expr="foo.x(result)"/>
 
199
"""
 
200
        nodes = Lexer(template).parse()
 
201
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), NamespaceTag(u'namespace', {u'name': u'foo'}, (2, 1), ["Text(u'\\n    ', (2, 24))", 'DefTag(u\'def\', {u\'name\': u\'x()\'}, (3, 5), ["Text(u\'\\\\n        this is x\\\\n    \', (3, 22))"])', "Text(u'\\n    ', (5, 12))", 'DefTag(u\'def\', {u\'name\': u\'y()\'}, (6, 5), ["Text(u\'\\\\n        this is y\\\\n    \', (6, 22))"])', "Text(u'\\n', (8, 12))"]), Text(u'\n\n', (9, 14)), Code(u'\nresult = []\ndata = get_data()\nfor x in data:\n    result.append(x+7)\n\n', False, (11, 1)), Text(u'\n\n    result: ', (16, 3)), CallTag(u'call', {u'expr': u'foo.x(result)'}, (18, 13), []), Text(u'\n', (18, 42))])"""
 
202
 
 
203
    def test_expression(self):
 
204
        template = """
 
205
        this is some ${text} and this is ${textwith | escapes, moreescapes}
 
206
        <%def name="hi()">
 
207
            give me ${foo()} and ${bar()}
 
208
        </%def>
 
209
        ${hi()}
 
210
"""
 
211
        nodes = Lexer(template).parse()
 
212
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        this is some ', (1, 1)), Expression(u'text', [], (2, 22)), Text(u' and this is ', (2, 29)), Expression(u'textwith ', ['escapes', 'moreescapes'], (2, 42)), Text(u'\n        ', (2, 76)), DefTag(u'def', {u'name': u'hi()'}, (3, 9), ["Text(u'\\n            give me ', (3, 27))", "Expression(u'foo()', [], (4, 21))", "Text(u' and ', (4, 29))", "Expression(u'bar()', [], (4, 34))", "Text(u'\\n        ', (4, 42))"]), Text(u'\n        ', (5, 16)), Expression(u'hi()', [], (6, 9)), Text(u'\n', (6, 16))])"""
 
213
        
 
214
 
 
215
    def test_tricky_expression(self):
 
216
        template = """
 
217
        
 
218
            ${x and "|" or "hi"}
 
219
        """
 
220
        nodes = Lexer(template).parse()
 
221
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        \n            ', (1, 1)), Expression(u'x and "|" or "hi"', [], (3, 13)), Text(u'\n        ', (3, 33))])"""
 
222
 
 
223
        template = """
 
224
        
 
225
            ${hello + '''heres '{|}' text | | }''' | escape1}
 
226
        """
 
227
        nodes = Lexer(template).parse()
 
228
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        \n            ', (1, 1)), Expression(u"hello + '''heres '{|}' text | | }''' ", ['escape1'], (3, 13)), Text(u'\n        ', (3, 62))])"""
 
229
 
 
230
    def test_tricky_code(self):
 
231
        template = """<% print 'hi %>' %>"""
 
232
        nodes = Lexer(template).parse()
 
233
        assert repr(nodes) == r"""TemplateNode({}, [Code(u"print 'hi %>' \n", False, (1, 1))])"""
 
234
        
 
235
        template = r"""
 
236
        <%
 
237
            lines = src.split('\n')
 
238
        %>
 
239
"""
 
240
        nodes = Lexer(template).parse()
 
241
    
 
242
    def test_tricky_code_2(self):
 
243
        template = """<% 
 
244
        # someone's comment
 
245
        %>
 
246
        """
 
247
        nodes = Lexer(template).parse()
 
248
        assert repr(nodes) == r"""TemplateNode({}, [Code(u" \n        # someone's comment\n        \n", False, (1, 1)), Text(u'\n        ', (3, 11))])"""
 
249
        
 
250
        template= """<%
 
251
            print 'hi'
 
252
            # this is a comment
 
253
            # another comment
 
254
            x = 7 # someone's '''comment
 
255
            print '''
 
256
        there
 
257
        '''
 
258
            # someone else's comment
 
259
        %> '''and now some text '''"""
 
260
        nodes = Lexer(template).parse()
 
261
        assert repr(nodes) == r"""TemplateNode({}, [Code(u"\nprint 'hi'\n# this is a comment\n# another comment\nx = 7 # someone's '''comment\nprint '''\n        there\n        '''\n# someone else's comment\n        \n", False, (1, 1)), Text(u" '''and now some text '''", (10, 11))])"""
 
262
        
 
263
    def test_control_lines(self):
 
264
        template = """
 
265
text text la la
 
266
% if foo():
 
267
 mroe text la la blah blah
 
268
% endif
 
269
 
 
270
        and osme more stuff
 
271
        % for l in range(1,5):
 
272
    tex tesl asdl l is ${l} kfmas d
 
273
      % endfor
 
274
    tetx text
 
275
    
 
276
"""
 
277
        nodes = Lexer(template).parse()
 
278
        #print nodes
 
279
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\ntext text la la\n', (1, 1)), ControlLine(u'if', u'if foo():', False, (3, 1)), Text(u' mroe text la la blah blah\n', (4, 1)), ControlLine(u'if', u'endif', True, (5, 1)), Text(u'\n        and osme more stuff\n', (6, 1)), ControlLine(u'for', u'for l in range(1,5):', False, (8, 1)), Text(u'    tex tesl asdl l is ', (9, 1)), Expression(u'l', [], (9, 24)), Text(u' kfmas d\n', (9, 28)), ControlLine(u'for', u'endfor', True, (10, 1)), Text(u'    tetx text\n    \n', (11, 1))])"""
 
280
 
 
281
    def test_control_lines_2(self):
 
282
        template = \
 
283
"""
 
284
 
 
285
 
 
286
% for file in requestattr['toc'].filenames:
 
287
    x
 
288
% endfor
 
289
"""
 
290
        nodes = Lexer(template).parse()
 
291
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n\n\n', (1, 1)), ControlLine(u'for', u"for file in requestattr['toc'].filenames:", False, (4, 1)), Text(u'    x\n', (5, 1)), ControlLine(u'for', u'endfor', True, (6, 1))])"""
 
292
 
 
293
    def test_long_control_lines(self):
 
294
        template = \
 
295
        """
 
296
    % for file in \\
 
297
        requestattr['toc'].filenames:
 
298
        x
 
299
    % endfor
 
300
        """
 
301
        nodes = Lexer(template).parse()
 
302
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), ControlLine(u'for', u"for file in \\\n        requestattr['toc'].filenames:", False, (2, 1)), Text(u'        x\n', (4, 1)), ControlLine(u'for', u'endfor', True, (5, 1)), Text(u'        ', (6, 1))])"""
 
303
 
 
304
    def test_unmatched_control(self):
 
305
        template = """
 
306
 
 
307
        % if foo:
 
308
            % for x in range(1,5):
 
309
        % endif
 
310
"""
 
311
        try:
 
312
            nodes = Lexer(template).parse()
 
313
            assert False
 
314
        except exceptions.SyntaxException, e:
 
315
            assert str(e) == "Keyword 'endif' doesn't match keyword 'for' at line: 5 char: 1"
 
316
 
 
317
    def test_unmatched_control_2(self):
 
318
        template = """
 
319
 
 
320
        % if foo:
 
321
            % for x in range(1,5):
 
322
            % endfor
 
323
"""
 
324
        try:
 
325
            nodes = Lexer(template).parse()
 
326
            assert False
 
327
        except exceptions.SyntaxException, e:
 
328
            assert str(e) == "Unterminated control keyword: 'if' at line: 3 char: 1"
 
329
 
 
330
    def test_unmatched_control_3(self):
 
331
        template = """
 
332
 
 
333
        % if foo:
 
334
            % for x in range(1,5):
 
335
            % endlala
 
336
        % endif
 
337
"""
 
338
        try:
 
339
            nodes = Lexer(template).parse()
 
340
            assert False
 
341
        except exceptions.SyntaxException, e:
 
342
            assert str(e) == "Keyword 'endlala' doesn't match keyword 'for' at line: 5 char: 1"
 
343
    
 
344
    def test_ternary_control(self):
 
345
        template = """
 
346
        % if x:
 
347
            hi
 
348
        % elif y+7==10:
 
349
            there
 
350
        % elif lala:
 
351
            lala
 
352
        % else:
 
353
            hi
 
354
        % endif
 
355
"""    
 
356
        nodes = Lexer(template).parse()
 
357
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), ControlLine(u'if', u'if x:', False, (2, 1)), Text(u'            hi\n', (3, 1)), ControlLine(u'elif', u'elif y+7==10:', False, (4, 1)), Text(u'            there\n', (5, 1)), ControlLine(u'elif', u'elif lala:', False, (6, 1)), Text(u'            lala\n', (7, 1)), ControlLine(u'else', u'else:', False, (8, 1)), Text(u'            hi\n', (9, 1)), ControlLine(u'if', u'endif', True, (10, 1))])"""
 
358
        
 
359
    def test_integration(self):
 
360
        template = """<%namespace name="foo" file="somefile.html"/>
 
361
 ## inherit from foobar.html
 
362
<%inherit file="foobar.html"/>
 
363
 
 
364
<%def name="header()">
 
365
     <div>header</div>
 
366
</%def>
 
367
<%def name="footer()">
 
368
    <div> footer</div>
 
369
</%def>
 
370
 
 
371
<table>
 
372
    % for j in data():
 
373
    <tr>
 
374
        % for x in j:
 
375
            <td>Hello ${x| h}</td>
 
376
        % endfor
 
377
    </tr>
 
378
    % endfor
 
379
</table>
 
380
"""
 
381
        nodes = Lexer(template).parse()
 
382
        assert repr(nodes) == r"""TemplateNode({}, [NamespaceTag(u'namespace', {u'name': u'foo', u'file': u'somefile.html'}, (1, 1), []), Text(u'\n', (1, 46)), Comment(u'inherit from foobar.html', (2, 1)), InheritTag(u'inherit', {u'file': u'foobar.html'}, (3, 1), []), Text(u'\n\n', (3, 31)), DefTag(u'def', {u'name': u'header()'}, (5, 1), ["Text(u'\\n     <div>header</div>\\n', (5, 23))"]), Text(u'\n', (7, 8)), DefTag(u'def', {u'name': u'footer()'}, (8, 1), ["Text(u'\\n    <div> footer</div>\\n', (8, 23))"]), Text(u'\n\n<table>\n', (10, 8)), ControlLine(u'for', u'for j in data():', False, (13, 1)), Text(u'    <tr>\n', (14, 1)), ControlLine(u'for', u'for x in j:', False, (15, 1)), Text(u'            <td>Hello ', (16, 1)), Expression(u'x', ['h'], (16, 23)), Text(u'</td>\n', (16, 30)), ControlLine(u'for', u'endfor', True, (17, 1)), Text(u'    </tr>\n', (18, 1)), ControlLine(u'for', u'endfor', True, (19, 1)), Text(u'</table>\n', (20, 1))])"""
 
383
        
 
384
    def test_comment_after_statement(self):
 
385
        template = """
 
386
        % if x: #comment
 
387
            hi
 
388
        % else: #next
 
389
            hi
 
390
        % endif #end
 
391
"""    
 
392
        nodes = Lexer(template).parse()
 
393
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n', (1, 1)), ControlLine(u'if', u'if x: #comment', False, (2, 1)), Text(u'            hi\n', (3, 1)), ControlLine(u'else', u'else: #next', False, (4, 1)), Text(u'            hi\n', (5, 1)), ControlLine(u'if', u'endif #end', True, (6, 1))])"""
 
394
 
 
395
    def test_crlf(self):
 
396
        template = file("./test_htdocs/crlf.html").read()
 
397
        nodes = Lexer(template).parse()
 
398
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'<html>\r\n\r\n', (1, 1)), PageTag(u'page', {u'args': u"a=['foo',\n                'bar']"}, (3, 1), []), Text(u'\r\n\r\nlike the name says.\r\n\r\n', (4, 26)), ControlLine(u'for', u'for x in [1,2,3]:', False, (8, 1)), Text(u'        ', (9, 1)), Expression(u'x', [], (9, 9)), Text(u'', (9, 13)), ControlLine(u'for', u'endfor', True, (10, 1)), Text(u'\r\n', (11, 1)), Expression(u"trumpeter == 'Miles' and trumpeter or \\\n      'Dizzy'", [], (12, 1)), Text(u'\r\n\r\n', (13, 15)), DefTag(u'def', {u'name': u'hi()'}, (15, 1), ["Text(u'\\r\\n    hi!\\r\\n', (15, 19))"]), Text(u'\r\n\r\n</html>\r\n', (17, 8))])"""
 
399
        assert flatten_result(Template(template).render()) == """<html> like the name says. 1 2 3 Dizzy </html>"""
 
400
    
 
401
    def test_comments(self):
 
402
        template = """
 
403
<style>
 
404
 #someselector
 
405
 # other non comment stuff
 
406
</style>
 
407
## a comment
 
408
 
 
409
# also not a comment
 
410
 
 
411
   ## this is a comment
 
412
   
 
413
this is ## not a comment
 
414
 
 
415
<%doc> multiline
 
416
comment
 
417
</%doc>
 
418
 
 
419
hi
 
420
"""
 
421
        nodes = Lexer(template).parse()
 
422
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n<style>\n #someselector\n # other non comment stuff\n</style>\n', (1, 1)), Comment(u'a comment', (6, 1)), Text(u'\n# also not a comment\n\n', (7, 1)), Comment(u'this is a comment', (10, 1)), Text(u'   \nthis is ## not a comment\n\n', (11, 1)), Comment(u' multiline\ncomment\n', (14, 1)), Text(u'\n\nhi\n', (16, 8))])"""
 
423
    
 
424
    def test_docs(self):
 
425
        template = """
 
426
        <%doc>
 
427
            this is a comment
 
428
        </%doc>
 
429
        <%def name="foo()">
 
430
            <%doc>
 
431
                this is the foo func
 
432
            </%doc>
 
433
        </%def>
 
434
        """
 
435
        nodes = Lexer(template).parse()
 
436
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n        ', (1, 1)), Comment(u'\n            this is a comment\n        ', (2, 9)), Text(u'\n        ', (4, 16)), DefTag(u'def', {u'name': u'foo()'}, (5, 9), ["Text(u'\\n            ', (5, 28))", "Comment(u'\\n                this is the foo func\\n            ', (6, 13))", "Text(u'\\n        ', (8, 20))"]), Text(u'\n        ', (9, 16))])"""
 
437
 
 
438
    def test_preprocess(self):
 
439
        def preproc(text):
 
440
            return re.sub(r'(?<=\n)\s*#[^#]', "##", text)
 
441
        template = """
 
442
    hi
 
443
    # old style comment
 
444
# another comment
 
445
"""
 
446
        nodes = Lexer(template, preprocessor=preproc).parse()
 
447
        assert repr(nodes) == r"""TemplateNode({}, [Text(u'\n    hi\n', (1, 1)), Comment(u'old style comment', (3, 1)), Comment(u'another comment', (4, 1))])"""
 
448
        
 
449
if __name__ == '__main__':
 
450
    unittest.main()