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'))
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)
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'))
def test_include_group(self): '''Tests inclusion on a group.''' a = TextTemplate() a.exclude('td1', 'td2') a.fromstring( '<table>$$tr1 <tr class="tr1"><td id="td1">$td1$' '</td><td id="td2">$td2$</td></tr>$$<p id="r">$r$</p></table>' ) a.include('td1', 'td2') self.assertEqual(True, len(a.tr1) == 2)