def test_existing_url(self): mocker = Mocker() mock_url = mocker.replace("urllib2.urlopen") mock_url(ANY) mocker.result("<b>proves</b>") mocker.replay() soup = gh.get_soup_from_url("http://www.google.com") self.assertEquals(soup, BeautifulSoup("<b>proves</b>", "lxml", from_encoding="UTF8")) mocker.restore() mocker.verify()
def test_returns_correct_object(self): soup = gh.get_soup_from_url("http://www.google.com") self.assertEquals(type(soup), type(BeautifulSoup()))
def test_inexistent_url(self): try: gh.get_soup_from_url("invalid_url") self.fail("URL not valid") # pragma: no cover except ValueError: self.assertTrue(True)