Edgewall Software

Ticket #269: test_pyif_with_pystrip.py

File test_pyif_with_pystrip.py, 863 bytes (added by felix.schwarz@…, 15 years ago)

Testcase for the behavior

Line 
1#!/usr/bin/env python
2
3import unittest
4
5from genshi.template import MarkupTemplate
6
7tmpl_data = """<div xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
8   REPLACEME
9</div>"""
10
11simple_replace = """<py:if test="True" py:strip="">
12    var x = 'bar';
13</py:if>"""
14
15replace_and_variable = """<py:if test="True" py:strip="">
16    var x = '$d';
17</py:if>"""
18   
19
20
21class TestPyStripWithPyIf(unittest.TestCase):
22    def test_pystrip_and_pyif(self):
23        def generate(replacement_string):
24            data = tmpl_data.replace('REPLACEME', replacement_string)
25            tmpl = MarkupTemplate(data)
26            return tmpl.generate(d="bar").render('xhtml', doctype='xhtml')
27       
28        simple_output = generate(simple_replace)
29        wrong_output = generate(replace_and_variable)
30        self.assertEquals(simple_output, wrong_output)
31
32