annotate genshi/template/tests/text.py @ 938:a5a1c9a11135 tip

update tags
author convert-repo
date Tue, 31 May 2011 20:05:15 +0000
parents 6638c9db9e8c
children
rev   line source
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
2 #
854
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
3 # Copyright (C) 2006-2009 Edgewall Software
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
4 # All rights reserved.
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
5 #
5f2c7782cd8a 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
5f2c7782cd8a 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
5f2c7782cd8a 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.
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
9 #
5f2c7782cd8a 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
5f2c7782cd8a 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
5f2c7782cd8a 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/.
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
13
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
14 import doctest
475
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
15 import os
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
16 import shutil
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
17 import tempfile
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
18 import unittest
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
19
610
6a37018199fd * 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
bb939ed3058c 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
7145e4eba2ec 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
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
23
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
24
592
7145e4eba2ec 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
5f2c7782cd8a 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."""
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
27
475
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
28 def setUp(self):
bb939ed3058c 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')
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
30
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
31 def tearDown(self):
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
32 shutil.rmtree(self.dirname)
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
33
336
5f2c7782cd8a 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
7145e4eba2ec 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')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
36 self.assertEqual('#escaped', tmpl.generate().render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
37
5f2c7782cd8a 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
7145e4eba2ec 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')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
40 self.assertEqual('', tmpl.generate().render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
41
5f2c7782cd8a 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
7145e4eba2ec 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')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
44 self.assertEqual('## escaped comment',
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
45 tmpl.generate().render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
46
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
47 def test_end_with_args(self):
592
7145e4eba2ec 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
48 tmpl = OldTextTemplate("""
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
49 #if foo
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
50 bar
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
51 #end 'if foo'""")
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
52 self.assertEqual('\n', tmpl.generate(foo=False).render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
53
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
54 def test_latin1_encoded(self):
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
55 text = u'$foo\xf6$bar'.encode('iso-8859-1')
592
7145e4eba2ec 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
56 tmpl = OldTextTemplate(text, encoding='iso-8859-1')
854
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
57 self.assertEqual(u'x\xf6y',
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
58 tmpl.generate(foo='x', bar='y').render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
59
512
bdaf75981ec7 Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
60 def test_unicode_input(self):
bdaf75981ec7 Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
61 text = u'$foo\xf6$bar'
592
7145e4eba2ec 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
62 tmpl = OldTextTemplate(text)
854
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
63 self.assertEqual(u'x\xf6y',
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
64 tmpl.generate(foo='x', bar='y').render(encoding=None))
512
bdaf75981ec7 Fix for #125 (text template handling unicode source). Thanks to Christian Boos for the patch.
cmlenz
parents: 475
diff changeset
65
365
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
66 def test_empty_lines1(self):
592
7145e4eba2ec 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
67 tmpl = OldTextTemplate("""Your items:
365
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
68
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
69 #for item in items
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
70 * ${item}
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
71 #end""")
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
72 self.assertEqual("""Your items:
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
73
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
74 * 0
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
75 * 1
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
76 * 2
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
77 """, tmpl.generate(items=range(3)).render(encoding=None))
365
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
78
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
79 def test_empty_lines2(self):
592
7145e4eba2ec 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
80 tmpl = OldTextTemplate("""Your items:
365
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
81
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
82 #for item in items
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
83 * ${item}
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
84
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
85 #end""")
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
86 self.assertEqual("""Your items:
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
87
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
88 * 0
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
89
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
90 * 1
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
91
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
92 * 2
85d910b8f9e5 Fix for #62: preserve whitespace in front of directives.
cmlenz
parents: 336
diff changeset
93
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
94 """, tmpl.generate(items=range(3)).render(encoding=None))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
95
475
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
96 def test_include(self):
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
97 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
98 try:
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
99 file1.write("Included\n")
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
100 finally:
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
101 file1.close()
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
102
475
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
103 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
104 try:
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
105 file2.write("""----- Included data below this line -----
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
106 #include tmpl1.txt
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
107 ----- Included data above this line -----""")
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
108 finally:
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
109 file2.close()
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
110
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
111 loader = TemplateLoader([self.dirname])
592
7145e4eba2ec 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
112 tmpl = loader.load('tmpl2.txt', cls=OldTextTemplate)
475
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
113 self.assertEqual("""----- Included data below this line -----
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
114 Included
bb939ed3058c Added include directive for text templates (#115). Thanks to Alastair for the original patch.
cmlenz
parents: 418
diff changeset
115 ----- Included data above this line -----""",
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
116 tmpl.generate().render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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
7145e4eba2ec 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 class NewTextTemplateTestCase(unittest.TestCase):
7145e4eba2ec 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 """Tests for text template processing."""
7145e4eba2ec 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
7145e4eba2ec 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 setUp(self):
7145e4eba2ec 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 self.dirname = tempfile.mkdtemp(suffix='markup_test')
7145e4eba2ec 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
7145e4eba2ec 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 tearDown(self):
7145e4eba2ec 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 shutil.rmtree(self.dirname)
7145e4eba2ec 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
7145e4eba2ec 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 def test_escaping(self):
7145e4eba2ec 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 tmpl = NewTextTemplate('\\{% escaped %}')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
130 self.assertEqual('{% escaped %}',
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
131 tmpl.generate().render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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(self):
7145e4eba2ec 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('{# a comment #}')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
135 self.assertEqual('', tmpl.generate().render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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_comment_escaping(self):
7145e4eba2ec 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('\\{# escaped comment #}')
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
139 self.assertEqual('{# escaped comment #}',
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
140 tmpl.generate().render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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 def test_end_with_args(self):
7145e4eba2ec 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 tmpl = NewTextTemplate("""
7145e4eba2ec 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 {% if foo %}
7145e4eba2ec 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 bar
7145e4eba2ec 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 {% end 'if foo' %}""")
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
147 self.assertEqual('\n', tmpl.generate(foo=False).render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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_latin1_encoded(self):
7145e4eba2ec 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'.encode('iso-8859-1')
7145e4eba2ec 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, encoding='iso-8859-1')
854
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
152 self.assertEqual(u'x\xf6y',
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
153 tmpl.generate(foo='x', bar='y').render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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 def test_unicode_input(self):
7145e4eba2ec 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 text = u'$foo\xf6$bar'
7145e4eba2ec 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 tmpl = NewTextTemplate(text)
854
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
158 self.assertEqual(u'x\xf6y',
0d9e87c6cf6e More work on reducing the size of the diff produced by 2to3.
cmlenz
parents: 714
diff changeset
159 tmpl.generate(foo='x', bar='y').render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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 def test_empty_lines1(self):
7145e4eba2ec 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 tmpl = NewTextTemplate("""Your items:
7145e4eba2ec 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
7145e4eba2ec 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 {% for item in items %}\
7145e4eba2ec 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
165 * ${item}
7145e4eba2ec 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 {% end %}""")
7145e4eba2ec 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 self.assertEqual("""Your items:
7145e4eba2ec 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
7145e4eba2ec 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 * 0
7145e4eba2ec 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 * 1
7145e4eba2ec 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 * 2
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
172 """, tmpl.generate(items=range(3)).render(encoding=None))
592
7145e4eba2ec 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
7145e4eba2ec 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 def test_empty_lines2(self):
7145e4eba2ec 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 tmpl = NewTextTemplate("""Your items:
7145e4eba2ec 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
7145e4eba2ec 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 {% for item in items %}\
7145e4eba2ec 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 * ${item}
7145e4eba2ec 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
7145e4eba2ec 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 {% end %}""")
7145e4eba2ec 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 self.assertEqual("""Your items:
7145e4eba2ec 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
182
7145e4eba2ec 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 * 0
7145e4eba2ec 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
184
7145e4eba2ec 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
185 * 1
7145e4eba2ec 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
186
7145e4eba2ec 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
187 * 2
7145e4eba2ec 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
188
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
189 """, tmpl.generate(items=range(3)).render(encoding=None))
592
7145e4eba2ec 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
190
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
191 def test_exec_with_trailing_space(self):
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
192 """
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
193 Verify that a code block with trailing space does not cause a syntax
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
194 error (see ticket #127).
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
195 """
858
df860bdad9ca Yet more 2to3 diff size reduction.
cmlenz
parents: 854
diff changeset
196 NewTextTemplate("""
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
197 {% python
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
198 bar = 42
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
199 $}
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
200 """)
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
201
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
202 def test_exec_import(self):
858
df860bdad9ca Yet more 2to3 diff size reduction.
cmlenz
parents: 854
diff changeset
203 tmpl = NewTextTemplate("""{% python from datetime import timedelta %}
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
204 ${timedelta(days=2)}
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
205 """)
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
206 self.assertEqual("""
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
207 2 days, 0:00:00
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
208 """, tmpl.generate().render(encoding=None))
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
209
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
210 def test_exec_def(self):
858
df860bdad9ca Yet more 2to3 diff size reduction.
cmlenz
parents: 854
diff changeset
211 tmpl = NewTextTemplate("""{% python
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
212 def foo():
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
213 return 42
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
214 %}
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
215 ${foo()}
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
216 """)
858
df860bdad9ca Yet more 2to3 diff size reduction.
cmlenz
parents: 854
diff changeset
217 self.assertEqual("""
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
218 42
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
219 """, tmpl.generate().render(encoding=None))
609
237050080827 Add support for Python code blocks in text templates using the new syntax.
cmlenz
parents: 605
diff changeset
220
592
7145e4eba2ec 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 def test_include(self):
7145e4eba2ec 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 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
7145e4eba2ec 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 try:
605
bc5faca93699 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
224 file1.write("Included")
592
7145e4eba2ec 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 finally:
7145e4eba2ec 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 file1.close()
7145e4eba2ec 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
7145e4eba2ec 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 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
7145e4eba2ec 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 try:
7145e4eba2ec 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 file2.write("""----- Included data below this line -----
7145e4eba2ec 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 {% include tmpl1.txt %}
7145e4eba2ec 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 data above this line -----""")
7145e4eba2ec 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 finally:
7145e4eba2ec 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 file2.close()
7145e4eba2ec 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
235
7145e4eba2ec 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
236 loader = TemplateLoader([self.dirname])
7145e4eba2ec 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
237 tmpl = loader.load('tmpl2.txt', cls=NewTextTemplate)
7145e4eba2ec 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
238 self.assertEqual("""----- Included data below this line -----
7145e4eba2ec 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
239 Included
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
240 ----- Included data above this line -----""",
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
241 tmpl.generate().render(encoding=None))
592
7145e4eba2ec 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
242
693
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
243 def test_include_expr(self):
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
244 file1 = open(os.path.join(self.dirname, 'tmpl1.txt'), 'w')
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
245 try:
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
246 file1.write("Included")
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
247 finally:
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
248 file1.close()
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
249
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
250 file2 = open(os.path.join(self.dirname, 'tmpl2.txt'), 'w')
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
251 try:
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
252 file2.write("""----- Included data below this line -----
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
253 {% include ${'%s.txt' % ('tmpl1',)} %}
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
254 ----- Included data above this line -----""")
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
255 finally:
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
256 file2.close()
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
257
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
258 loader = TemplateLoader([self.dirname])
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
259 tmpl = loader.load('tmpl2.txt', cls=NewTextTemplate)
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
260 self.assertEqual("""----- Included data below this line -----
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
261 Included
865
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
262 ----- Included data above this line -----""",
6638c9db9e8c Also skip the encoding step in the template tests.
cmlenz
parents: 858
diff changeset
263 tmpl.generate().render(encoding=None))
693
fa8a55fe2d57 Enable use of expressions in include directives of text templates. Closes #194. Thanks to Oliver Cope for reporting the issue.
cmlenz
parents: 629
diff changeset
264
592
7145e4eba2ec 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
265
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
266 def suite():
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
267 suite = unittest.TestSuite()
592
7145e4eba2ec 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
268 suite.addTest(doctest.DocTestSuite(NewTextTemplate.__module__))
7145e4eba2ec 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
269 suite.addTest(unittest.makeSuite(OldTextTemplateTestCase, 'test'))
7145e4eba2ec 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
270 suite.addTest(unittest.makeSuite(NewTextTemplateTestCase, 'test'))
336
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
271 return suite
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
272
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
273 if __name__ == '__main__':
5f2c7782cd8a Refactoring: `genshi.template` is now a package, it was getting way to crowded in that file.
cmlenz
parents:
diff changeset
274 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software