예제 #1
0
 def test_find_all_follow_on_links(self):
     all_links = hundredgreatest.get_links_in_soup(self.soup)
     follow_on_links_numbers = []
     all_links_as_str = [str(l) for l in all_links]
     pattern = re.compile(r"^<a.*(\S+)(\?page=)(\d)\S+</a>")
     for l in all_links_as_str:
         m = re.match(pattern, l)
         if m:
             follow_on_links_numbers.append(m.group(3))
     theset = set(follow_on_links_numbers)
     self.assertEqual(hundredgreatest.get_follow_on_link_numbers(self.soup), theset)
예제 #2
0
 def test_get_all_links_as_strings(self):
     links_as_strings = set()
     for l in hundredgreatest.get_links_in_soup(self.soup):
         links_as_strings.add(str(l))
     self.assertEqual(hundredgreatest.all_links_as_strings(self.soup), links_as_strings)
예제 #3
0
 def test_get_links_in_soup(self):
     links = self.soup.find_all("a")
     self.assertEqual(hundredgreatest.get_links_in_soup(self.soup), links)