| 144 | self.assertEqual(template.generate(), bclass="st">"foo") |
| 145 | |
| 146 | def test_break_continue(self): |
| 147 | template = Template( |
| 148 | utf8( |
| 149 | class="st">"""\ |
| 150 | {% for i in range(10) %} |
| 151 | {% if i == 2 %} |
| 152 | {% continue %} |
| 153 | {% end %} |
| 154 | {{ i }} |
| 155 | {% if i == 6 %} |
| 156 | {% break %} |
| 157 | {% end %} |
| 158 | {% end %}class="st">""" |
| 159 | ) |
| 160 | ) |
| 161 | result = template.generate() |
| 162 | class="cm"># remove extraneous whitespace |
| 163 | result = bclass="st">"".join(result.split()) |
| 164 | self.assertEqual(result, bclass="st">"013456") |
| 165 | |
| 166 | def test_break_outside_loop(self): |
| 167 | with self.assertRaises(ParseError, msg=class="st">"Did not get expected exception"): |