def get_parent_and_soup(parent): if parent is None: soup = bs4.BeautifulSoup("<package><metadata/></package>", "xml") parent = soup.package.metadata else: soup = util.get_soup(parent) return parent, soup
def test_get_soup(self): html = '<html>' \ '<body>' \ '<table>' \ '<tbody>' \ '<tr>' \ '<td>' \ 'item' \ '</td>' \ '</tr>' \ '</tbody>' \ '</table>' \ '</body>' \ '</html>' soup = bs4.BeautifulSoup(html, "lxml") for child in soup.descendants: self.assertEqual(soup, util.get_soup(child))