Example #1
0
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
Example #2
0
def test_entityref():
    nodes = html.html_to_nodes('&')

    assert len(nodes) == 1
    assert nodes[0] == '&'

    content = html.node_to_html(nodes)
    assert content == '&'
Example #3
0
def test_charref():
    assert html.html_to_nodes('>')[0] == '>'
Example #4
0
def test_bad_tag():
    with pytest.raises(ValueError):
        html.html_to_nodes('<body></body>')
Example #5
0
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')