annotate genshi/template/tests/text.py @ 703:af57b12e3dd2 experimental-match-fastpaths

merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
author aflett
date Mon, 31 Mar 2008 22:47:50 +0000
parents 3ed5d7e47f38
children fc6d9d2a3527
rev   line source
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
2 #
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
3 # Copyright (C) 2006 Edgewall Software
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
4 # All rights reserved.
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
5 #
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
8 # are also available at http://genshi.edgewall.org/wiki/License.
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
9 #
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://genshi.edgewall.org/log/.
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
13
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
14 import doctest
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
15 import os
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
16 import shutil
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
17 import tempfile
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
18 import unittest
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
19
610
5e358de79e4c * XInclude elements in markup templates now support the `parse` attribute; when set to "xml" (the default), the include is processed as before, but when set to "text", the included template is parsed as a text template using the new syntax (ticket #101).
cmlenz
parents: 609
diff changeset
20 from genshi.template.base import TemplateSyntaxError
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
21 from genshi.template.loader import TemplateLoader
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
22 from genshi.template.text import OldTextTemplate, NewTextTemplate
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
23
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
24
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
25 class OldTextTemplateTestCase(unittest.TestCase):
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
26 """Tests for text template processing."""
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
27
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
28 def setUp(self):
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
29 self.dirname = tempfile.mkdtemp(suffix='markup_test')
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
30
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
31 def tearDown(self):
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
32 shutil.rmtree(self.dirname)
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
33
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
34 def test_escaping(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
35 tmpl = OldTextTemplate('\\#escaped')
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
36 self.assertEqual('#escaped', str(tmpl.generate()))
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
37
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
38 def test_comment(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
39 tmpl = OldTextTemplate('## a comment')
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
40 self.assertEqual('', str(tmpl.generate()))
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
41
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
42 def test_comment_escaping(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
43 tmpl = OldTextTemplate('\\## escaped comment')
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
44 self.assertEqual('## escaped comment', str(tmpl.generate()))
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
45
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
46 def test_end_with_args(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
47 tmpl = OldTextTemplate("""
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
48 #if foo
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
49 bar
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
50 #end 'if foo'""")
418
c478a6fa9e77 Make expression error handling more strict. Closes #88.
cmlenz
parents: 365
diff changeset
51 self.assertEqual('\n', str(tmpl.generate(foo=False)))
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
52
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
53 def test_latin1_encoded(self):
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
54 text = u'$foo\xf6$bar'.encode('iso-8859-1')
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
55 tmpl = OldTextTemplate(text, encoding='iso-8859-1')
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
56 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
57
512
ed9f1300f3bf Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
58 def test_unicode_input(self):
ed9f1300f3bf Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
59 text = u'$foo\xf6$bar'
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
60 tmpl = OldTextTemplate(text)
512
ed9f1300f3bf Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
61 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
ed9f1300f3bf Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
62
365
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
63 def test_empty_lines1(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
64 tmpl = OldTextTemplate("""Your items:
365
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
65
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
66 #for item in items
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
67 * ${item}
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
68 #end""")
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
69 self.assertEqual("""Your items:
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
70
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
71 * 0
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
72 * 1
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
73 * 2
605
d0345c64da65 Text templates now default to rendering as plain text; it is no longer necessary to explicitly specify the "text" method to the `render()` or `serialize()` method of the generated markup stream. See tickets #62 and #118.
cmlenz
parents: 592
diff changeset
74 """, tmpl.generate(items=range(3)).render())
365
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
75
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
76 def test_empty_lines2(self):
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
77 tmpl = OldTextTemplate("""Your items:
365
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
78
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
79 #for item in items
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
80 * ${item}
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
81
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
82 #end""")
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
83 self.assertEqual("""Your items:
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
84
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
85 * 0
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
86
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
87 * 1
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
88
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
89 * 2
4f431931d64e Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
90
605
d0345c64da65 Text templates now default to rendering as plain text; it is no longer necessary to explicitly specify the "text" method to the `render()` or `serialize()` method of the generated markup stream. See tickets #62 and #118.
cmlenz
parents: 592
diff changeset
91 """, tmpl.generate(items=range(3)).render())
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
92
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
93 def test_include(self):
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
94 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
95 try:
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
96 file1.write("Included\n")
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
97 finally:
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
98 file1.close()
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
99
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
100 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
101 try:
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
102 file2.write("""----- Included data below this line -----
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
103 #include tmpl1.txt
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
104 ----- Included data above this line -----""")
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
105 finally:
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
106 file2.close()
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
107
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
108 loader = TemplateLoader([self.dirname])
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
109 tmpl = loader.load('tmpl2.txt', cls=OldTextTemplate)
475
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
110 self.assertEqual("""----- Included data below this line -----
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
111 Included
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
112 ----- Included data above this line -----""",
b373f80f7763 Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
113 tmpl.generate().render())
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
114
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
115
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
116 class NewTextTemplateTestCase(unittest.TestCase):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
117 """Tests for text template processing."""
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
118
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
119 def setUp(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
120 self.dirname = tempfile.mkdtemp(suffix='markup_test')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
121
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
122 def tearDown(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
123 shutil.rmtree(self.dirname)
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
124
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
125 def test_escaping(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
126 tmpl = NewTextTemplate('\\{% escaped %}')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
127 self.assertEqual('{% escaped %}', str(tmpl.generate()))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
128
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
129 def test_comment(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
130 tmpl = NewTextTemplate('{# a comment #}')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
131 self.assertEqual('', str(tmpl.generate()))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
132
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
133 def test_comment_escaping(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
134 tmpl = NewTextTemplate('\\{# escaped comment #}')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
135 self.assertEqual('{# escaped comment #}', str(tmpl.generate()))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
136
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
137 def test_end_with_args(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
138 tmpl = NewTextTemplate("""
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
139 {% if foo %}
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
140 bar
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
141 {% end 'if foo' %}""")
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
142 self.assertEqual('\n', str(tmpl.generate(foo=False)))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
143
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
144 def test_latin1_encoded(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
145 text = u'$foo\xf6$bar'.encode('iso-8859-1')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
146 tmpl = NewTextTemplate(text, encoding='iso-8859-1')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
147 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
148
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
149 def test_unicode_input(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
150 text = u'$foo\xf6$bar'
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
151 tmpl = NewTextTemplate(text)
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
152 self.assertEqual(u'x\xf6y', unicode(tmpl.generate(foo='x', bar='y')))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
153
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
154 def test_empty_lines1(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
155 tmpl = NewTextTemplate("""Your items:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
156
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
157 {% for item in items %}\
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
158 * ${item}
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
159 {% end %}""")
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
160 self.assertEqual("""Your items:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
161
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
162 * 0
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
163 * 1
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
164 * 2
605
d0345c64da65 Text templates now default to rendering as plain text; it is no longer necessary to explicitly specify the "text" method to the `render()` or `serialize()` method of the generated markup stream. See tickets #62 and #118.
cmlenz
parents: 592
diff changeset
165 """, tmpl.generate(items=range(3)).render())
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
166
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
167 def test_empty_lines2(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
168 tmpl = NewTextTemplate("""Your items:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
169
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
170 {% for item in items %}\
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
171 * ${item}
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
172
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
173 {% end %}""")
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
174 self.assertEqual("""Your items:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
175
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
176 * 0
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
177
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
178 * 1
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
179
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
180 * 2
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
181
605
d0345c64da65 Text templates now default to rendering as plain text; it is no longer necessary to explicitly specify the "text" method to the `render()` or `serialize()` method of the generated markup stream. See tickets #62 and #118.
cmlenz
parents: 592
diff changeset
182 """, tmpl.generate(items=range(3)).render())
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
183
609
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
184 def test_exec_with_trailing_space(self):
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
185 """
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
186 Verify that a code block with trailing space does not cause a syntax
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
187 error (see ticket #127).
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
188 """
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
189 NewTextTemplate(u"""
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
190 {% python
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
191 bar = 42
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
192 $}
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
193 """)
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
194
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
195 def test_exec_import(self):
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
196 tmpl = NewTextTemplate(u"""{% python from datetime import timedelta %}
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
197 ${timedelta(days=2)}
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
198 """)
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
199 self.assertEqual("""
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
200 2 days, 0:00:00
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
201 """, str(tmpl.generate()))
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
202
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
203 def test_exec_def(self):
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
204 tmpl = NewTextTemplate(u"""{% python
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
205 def foo():
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
206 return 42
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
207 %}
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
208 ${foo()}
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
209 """)
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
210 self.assertEqual(u"""
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
211 42
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
212 """, str(tmpl.generate()))
6d4877844e28 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
213
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
214 def test_include(self):
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
215 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
216 try:
605
d0345c64da65 Text templates now default to rendering as plain text; it is no longer necessary to explicitly specify the "text" method to the `render()` or `serialize()` method of the generated markup stream. See tickets #62 and #118.
cmlenz
parents: 592
diff changeset
217 file1.write("Included")
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
218 finally:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
219 file1.close()
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
220
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
221 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
222 try:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
223 file2.write("""----- Included data below this line -----
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
224 {% include tmpl1.txt %}
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
225 ----- Included data above this line -----""")
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
226 finally:
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
227 file2.close()
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
228
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
229 loader = TemplateLoader([self.dirname])
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
230 tmpl = loader.load('tmpl2.txt', cls=NewTextTemplate)
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
231 self.assertEqual("""----- Included data below this line -----
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
232 Included
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
233 ----- Included data above this line -----""", tmpl.generate().render())
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
234
703
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
235 def test_include_expr(self):
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
236 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
237 try:
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
238 file1.write("Included")
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
239 finally:
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
240 file1.close()
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
241
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
242 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
243 try:
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
244 file2.write("""----- Included data below this line -----
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
245 {% include ${'%s.txt' % ('tmpl1',)} %}
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
246 ----- Included data above this line -----""")
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
247 finally:
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
248 file2.close()
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
249
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
250 loader = TemplateLoader([self.dirname])
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
251 tmpl = loader.load('tmpl2.txt', cls=NewTextTemplate)
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
252 self.assertEqual("""----- Included data below this line -----
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
253 Included
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
254 ----- Included data above this line -----""", tmpl.generate().render())
af57b12e3dd2 merge in trunk up through r818 - fundamentally changed the way MatchSet works, but actually is more consistent now
aflett
parents: 629
diff changeset
255
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
256
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
257 def suite():
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
258 suite = unittest.TestSuite()
592
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
259 suite.addTest(doctest.DocTestSuite(NewTextTemplate.__module__))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
260 suite.addTest(unittest.makeSuite(OldTextTemplateTestCase, 'test'))
1da8de3e5e51 Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents: 512
diff changeset
261 suite.addTest(unittest.makeSuite(NewTextTemplateTestCase, 'test'))
336
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
262 return suite
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
263
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
264 if __name__ == '__main__':
7763f7aec949 Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
265 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software