Beispiel #1
0
def test_find_nested_empty_tag(fake_html_3):
    soup = Soup(fake_html_3)
    result = soup.find("a", {"class": "foo"})
    if len(result) != 2:
        raise AssertionError
Beispiel #2
0
def test_find_nested_groups(fake_html_2):
    soup = Soup(fake_html_2)
    results = soup.find("div", {"class": "foo"})
    if len(results) != 2:
        raise AssertionError
Beispiel #3
0
def test_find_partial_false(fake_html_2):
    soup = Soup(fake_html_2)
    result = soup.find("div", {"class": "foo"}, partial=False, mode="all")
    if len(result) != 1:
        raise AssertionError
Beispiel #4
0
def test_find_text(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", {"id": "blarg"})
    if result.text != "Try for 2":
        raise AssertionError
Beispiel #5
0
def test_find_with_attrs(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", {"id": "blarg"})
    if str(result) != '<p id="blarg">Try for 2</p>':
        raise AssertionError
Beispiel #6
0
def test_find_first(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("p", mode="first")
    if str(result) != "<p>'IDK!'</p>":
        raise AssertionError
Beispiel #7
0
def test_find(fake_html_1):
    soup = Soup(fake_html_1)
    result = soup.find("span")
    if str(result) != "<span>Hi</span>":
        raise AssertionError
Beispiel #8
0
def test_find_inner_text():
    html = """<p>&pound;600m</p>"""
    soup = Soup(html)
    result = soup.text
    if result != "£600m":
        raise AssertionError