Esempio n. 1
0
    def test_trim_before(self):
        from quotequail import _html

        html = '<div>A<span>B</span>C<span>D</span>E</div>'

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span'))
        self.assertEqual(_html.render_html_tree(tree), '<div><span>B</span>C<span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span[2]'))
        self.assertEqual(_html.render_html_tree(tree), '<div><span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span'), include_element=False)
        self.assertEqual(_html.render_html_tree(tree), '<div>C<span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span[2]'), include_element=False)
        self.assertEqual(_html.render_html_tree(tree), '<div>E</div>')
Esempio n. 2
0
    def test_trim_before(self):
        from quotequail import _html

        html = '<div>A<span>B</span>C<span>D</span>E</div>'

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span'))
        self.assertEqual(_html.render_html_tree(tree), '<div><span>B</span>C<span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span[2]'))
        self.assertEqual(_html.render_html_tree(tree), '<div><span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span'), include_element=False)
        self.assertEqual(_html.render_html_tree(tree), '<div>C<span>D</span>E</div>')

        tree = _html.get_html_tree(html)
        _html.trim_tree_before(tree.find('div/span[2]'), include_element=False)
        self.assertEqual(_html.render_html_tree(tree), '<div>E</div>')