Mercurial > genshi > mirror
comparison markup/tests/template.py @ 181:e103b75a96ce trunk
Some error message improvements for template directives. Thanks to Christian Boos for the patch!
author | cmlenz |
---|---|
date | Mon, 21 Aug 2006 19:51:07 +0000 |
parents | 13909179e5e1 |
children | 181d292eafa2 |
comparison
equal
deleted
inserted
replaced
180:061491fb4ea8 | 181:e103b75a96ce |
---|---|
132 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> | 132 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> |
133 <div py:when="xy" /> | 133 <div py:when="xy" /> |
134 </doc>""") | 134 </doc>""") |
135 self.assertRaises(TemplateSyntaxError, str, tmpl.generate()) | 135 self.assertRaises(TemplateSyntaxError, str, tmpl.generate()) |
136 | 136 |
137 def test_when_outside_choose(self): | 137 def test_otherwise_outside_choose(self): |
138 """ | 138 """ |
139 Verify that an `otherwise` directive outside of a `choose` directive is | 139 Verify that an `otherwise` directive outside of a `choose` directive is |
140 reported as an error. | 140 reported as an error. |
141 """ | 141 """ |
142 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> | 142 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> |
143 <div py:otherwise="" /> | 143 <div py:otherwise="" /> |
144 </doc>""") | 144 </doc>""") |
145 self.assertRaises(TemplateSyntaxError, str, tmpl.generate()) | 145 self.assertRaises(TemplateSyntaxError, str, tmpl.generate()) |
146 | |
147 def test_when_without_test(self): | |
148 """ | |
149 Verify that an `when` directive that doesn't have a `test` attribute | |
150 is reported as an error. | |
151 """ | |
152 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> | |
153 <div py:choose="" py:strip=""> | |
154 <py:when>foo</py:when> | |
155 </div> | |
156 </doc>""") | |
157 self.assertRaises(TemplateSyntaxError, str, tmpl.generate()) | |
158 | |
159 def test_otherwise_without_test(self): | |
160 """ | |
161 Verify that an `otherwise` directive can be used without a `test` | |
162 attribute. | |
163 """ | |
164 tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> | |
165 <div py:choose="" py:strip=""> | |
166 <py:otherwise>foo</py:otherwise> | |
167 </div> | |
168 </doc>""") | |
169 self.assertEqual("""<doc> | |
170 foo | |
171 </doc>""", str(tmpl.generate())) | |
146 | 172 |
147 def test_as_element(self): | 173 def test_as_element(self): |
148 """ | 174 """ |
149 Verify that the directive can also be used as an element. | 175 Verify that the directive can also be used as an element. |
150 """ | 176 """ |