Edgewall Software

Ticket #254: test_duplicated_item.py

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

This is a test case for the described problem (can reproduce it with the current 0.6 trunk, too)

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  <div py:match="div[@id='content'][@class='ticket']" py:attrs="select('@*')" once="true">
11    <ul id="tabbed_pane" />
12    ${select('*')}
13  </div>
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>Ticket X</h1>
28    </div>
29  </body>
30</html>"""
31
32class TestDuplicatedItems(unittest.TestCase):
33    def test_duplicated_items(self):
34        tmpl = MarkupTemplate(tmpl_data)
35        output = tmpl.generate().render('xhtml', doctype='xhtml')
36        matches = re.findall("tabbed_pane", output)
37        self.assertNotEqual(None, matches)
38        print output
39        self.assertEqual(1, len(matches))
40
41