Ejemplo n.º 1
0
 def test_include_live_group(self):
     '''Tests inclusion on a live group.'''
     testfilter = TextTemplate(
         '<table>$$tr1 <tr class="tr1"><td id="td1">$td1$'
         '</td><td id="td2">$td2$</td></tr>$$<p id="r">$r$</p></table>')
     testfilter.exclude('td1', 'td2')
     testfilter.include('td1', 'td2')
     self.assertEqual(True, len(testfilter.tr1) == 2)
Ejemplo n.º 2
0
 def test_exclude_live(self):
     '''Tests exclusion on a live root TextTemplate.'''
     testfilter = TextTemplate(
         '<table>$$tr1 <tr class="tr1"><td id="td1">$td1$'
         '</td><td id="td2">$td2$</td></tr>$$<p id="r">$r$</p></table>'
     )
     testfilter.exclude('tr1', 'r')
     self.assertEqual(True, len(testfilter) == 0)
Ejemplo n.º 3
0
 def test_exclude_group(self):
     '''Tests exclusion on a group.'''
     a = TextTemplate()
     a.exclude('tr1')
     a.fromstring(
         '<table>$$tr1 <tr class="tr1"><td id="td1">$td1$'
         '</td><td id="td2">$td2$</td></tr>$$<p id="r">$r$</p></table>',
     )
     self.assertEqual(True, len(a) == 1)
Ejemplo n.º 4
0
 def test_exclude(self):
     '''Tests exclusion on a root TextTemplate.'''
     a = TextTemplate()
     a.exclude('td1', 'td2')
     a.fromstring(
         '<tr><td id="td1">$td1$</td><td id="td2">$td2$</td>'
         '<td id="td3">$td3$</td></tr>'
     )
     self.assertEqual(True, len(a) == 1)
Ejemplo n.º 5
0
 def test_no_empty_group(self):
     '''Tests if empty groups are properly pruned.'''
     testfilter = TextTemplate()
     testfilter.exclude('td1')
     testfilter.fromstring('<div>$$tr1 <tr class="tr1">' \
         '<td id="td1">$td1</td></tr>$$</table></div>')
     testfilter.include('td1')
     self.assertEqual(False, hasattr(testfilter, 'thing'))
Ejemplo n.º 6
0
 def test_root_include(self):
     '''Tests inclusion on a TextTemplate.'''
     testfilter = TextTemplate()
     testfilter.exclude('td1')
     testfilter.fromstring(
         '<tr><td id="td1">$td1$</td><td id="td2">$td2$</td></tr>'
     )
     testfilter.include('td1')
     self.assertEqual(True, hasattr(testfilter, 'td1'))