Exemplo n.º 1
0
 def test_ancestors_and_parent(self):
     parsed = parse('{{a|{{#if:{{b{{c<!---->}}}}}}}}')
     self.assertEqual(parsed.parent(), None)
     self.assertEqual(parsed.ancestors(), [])
     c = parsed.comments[0]
     c_parent = c.parent()
     self.assertEqual(c_parent.string, '{{c<!---->}}')
     self.assertEqual(c_parent.parent().string, '{{b{{c<!---->}}}}')
     self.assertEqual(len(c.ancestors()), 4)
     self.assertEqual(len(c.ancestors(type_='Template')), 3)
     self.assertEqual(len(c.ancestors(type_='ParserFunction')), 1)
     t = Template('{{a}}')
     self.assertEqual(t.ancestors(), [])
     self.assertIsNone(t.parent())
Exemplo n.º 2
0
def test_ancestors_and_parent():
    parsed = parse('{{a|{{#if:{{b{{c<!---->}}}}}}}}')
    assert parsed.parent() is None
    assert parsed.ancestors() == []
    c = parsed.comments[0]
    c_parent = c.parent()
    assert c_parent.string == '{{c<!---->}}'
    assert c_parent.parent().string == '{{b{{c<!---->}}}}'
    assert len(c.ancestors()) == 4
    assert len(c.ancestors(type_='Template')) == 3
    assert len(c.ancestors(type_='ParserFunction')) == 1
    t = Template('{{a}}')
    assert t.ancestors() == []
    assert t.parent() is None