def test_html_to_nodes(): nodes = html.html_to_nodes(HTML) assert isinstance(nodes, list) for item in nodes: assert isinstance(item, NodeElement) assert nodes == NODES
def test_entityref(): nodes = html.html_to_nodes('&') assert len(nodes) == 1 assert nodes[0] == '&' content = html.node_to_html(nodes) assert content == '&'
def test_charref(): assert html.html_to_nodes('>')[0] == '>'
def test_bad_tag(): with pytest.raises(ValueError): html.html_to_nodes('<body></body>')
def test_invalid_html(): with pytest.raises(ValueError): html.html_to_nodes('<p><a href="#">test</p></a>') with pytest.raises(ValueError): html.html_to_nodes('<p>text')