def testExtractText(self): pattern = "<a>$text</a>" _scraper = Scraper(pattern) exp = BeautifulSoup(pattern) # one text actual = BeautifulSoup("<a>hello world</a>") self.assertEqual('hello world', _scraper.extractText(exp.contents[0], actual.contents[0])['text'])