Exemplo n.º 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
Exemplo n.º 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 == '&'
Exemplo n.º 3
0
def test_charref():
    assert html.html_to_nodes('>')[0] == '>'
Exemplo n.º 4
0
def test_bad_tag():
    with pytest.raises(ValueError):
        html.html_to_nodes('<body></body>')
Exemplo n.º 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')