def assertNoMatch(self, html_list, sample): """ Creates a Template from every string in html_list, then asserts that t.extract(sample) raises NoMatch. """ t = Template() for html in html_list: t.learn(html) self.assertRaises(NoMatch, t.extract, sample)
def assertExtracts(self, html_list, expected_data_list): """ Creates a Template from every string in html_list, then extracts the data from each of those strings, asserting that the data matches expected_data_list. """ t = Template(algorithm=self.algorithm) for html in html_list: t.learn(html) got_data_list = [] for html in html_list: got_data_list.append(t.extract(html)) self.assertEqual(got_data_list, expected_data_list)