def test_find_multiple(fake_html_1): soup = Soup(fake_html_1) result = soup.find("div", {"class": "baz"}) if len(result) != 2: raise AssertionError if str(result[1]) != '<div class="baz">Oh No!</div>': raise AssertionError
def test_find_with_attrs(fake_html_1): soup = Soup(fake_html_1) result = soup.find("p", {"id": "blarg"}) assert str(result) == '<p id="blarg">Try for 2</p>'
def test_undocumented_random_mode(fake_html_6): soup = Soup(fake_html_6) pset = set([soup.find("p", mode="random").attrs["id"] for _ in range(10)]) if len(pset) <= 1: raise AssertionError
def test_find_strict(fake_html_2): with pytest.warns(FutureWarning): soup = Soup(fake_html_2) soup.find("div", {"class": "foo"}, strict=True)
def test_find_no_match_auto(fake_html_1): soup = Soup(fake_html_1) result = soup.find("a", mode="auto") if result is not None: raise AssertionError
def test_find_mutliple_imgs(fake_html_3): soup = Soup(fake_html_3) middle = soup.find("img")[1] if middle.attrs["src"] != "bye.jpg": raise AssertionError
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
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
def test_find_no_match_first(fake_html_1): soup = Soup(fake_html_1) result = soup.find("a", mode="first") assert result == None
def test_find_mutliple_imgs(fake_html_3): soup = Soup(fake_html_3) middle = soup.find("img")[1] assert middle.attrs["src"] == "bye.jpg"
def test_find_nested_empty_tag(fake_html_3): soup = Soup(fake_html_3) result = soup.find("a", {"class": "foo"}) assert len(result) == 2
def test_find_partial_false(fake_html_2): soup = Soup(fake_html_2) result = soup.find("div", {"class": "foo"}, partial=False, mode="all") assert len(result) == 1
def test_find_nested_groups(fake_html_2): soup = Soup(fake_html_2) results = soup.find("div", {"class": "foo"}) assert len(results) == 2
def test_find_text(fake_html_1): soup = Soup(fake_html_1) result = soup.find("p", {"id": "blarg"}) assert result.text == "Try for 2"
def test_find_multiple(fake_html_1): soup = Soup(fake_html_1) result = soup.find("div", {"class": "baz"}) assert len(result) == 2 assert str(result[1]) == '<div class="baz">Oh No!</div>'
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
def test_find_no_match_all(fake_html_1): soup = Soup(fake_html_1) result = soup.find("a", mode="all") assert result == []
def test_find_no_match_auto(fake_html_1): soup = Soup(fake_html_1) result = soup.find("a", mode="auto") assert result == None
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
def test_malformed_void_tags(fake_html_5): soup = Soup(fake_html_5) result = soup.find("img") assert len(result) == 3
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
def test_undocumented_random_mode(fake_html_6): soup = Soup(fake_html_6) pset = set([soup.find("p", mode="random").attrs["id"] for _ in range(10)]) assert len(pset) > 1
def test_find_no_match_all(fake_html_1): soup = Soup(fake_html_1) result = soup.find("a", mode="all") if result != []: raise AssertionError
def test_undocumented_last_mode(fake_html_6): soup = Soup(fake_html_6) assert soup.find("p", mode="last").text == "G"
def test_malformed_void_tags(fake_html_5): soup = Soup(fake_html_5) result = soup.find("img") if len(result) != 3: raise AssertionError
def test_find(fake_html_1): soup = Soup(fake_html_1) result = soup.find("span") if str(result) != "<span>Hi</span>": raise AssertionError
def test_bad_mode_argument(fake_html_1): with pytest.raises(ValueError): soup = Soup(fake_html_1) soup.find("div", mode="bad")
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
def test_undocumented_last_mode(fake_html_6): soup = Soup(fake_html_6) if soup.find("p", mode="last").text != "G": raise AssertionError
def test_find_first(fake_html_1): soup = Soup(fake_html_1) result = soup.find("p", mode="first") assert str(result) == "<p>'IDK!'</p>"