Edgewall Software

Ticket #254: test_no_match_with_single_slash.py

File test_no_match_with_single_slash.py, 1.3 KB (added by felix.schwarz@…, 15 years ago)

Actually, I found another problem in our code which was caused by the mentioned commits. However, for this second problem there is a workaround by using h1 as match expression (see the second testcase)

Line 
1#!/usr/bin/env python
2
3import unittest
4import re
5
6from genshi.template import MarkupTemplate
7
8tmpl_data="""<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
10
11  <py:match path="div[@id='content']/h1" once="True">
12      <h1>Create New Foo</h1>
13  </py:match>
14   
15  <py:match path="body" once="true" buffer="false"><body>
16    ${select('*|text()')}
17  </body></py:match>
18
19  <py:match path="body" once="true" buffer="false"><body>
20    <div id="main">
21      ${select('*|text()')}
22    </div>
23  </body></py:match>
24
25  <body>
26    <div id="content" class="ticket">
27      <h1>Create New Ticket</h1>
28    </div>
29  </body>
30</html>"""
31
32
33class TestNoMatchWithSingleSlash(unittest.TestCase):
34    def test_no_match(self):
35        tmpl = MarkupTemplate(tmpl_data)
36        output = tmpl.generate().render('xhtml', doctype='xhtml')
37        print output
38        self.assertTrue("Create New Foo" in output)
39
40    def test_match_with_double_slash(self):
41        # Not sure if this is the wanted behavior
42        tmpl = MarkupTemplate(tmpl_data.replace("]/h1", "]//h1"))
43        output = tmpl.generate().render('xhtml', doctype='xhtml')
44        self.assertTrue("Create New Foo" in output)
45
46