def test_module_parse_html_filelike(self): parser = self.etree.HTMLParser() f = SillyFileLike(self.html_str) tree = self.etree.parse(f, parser) html = self.etree.tostring(tree.getroot(), method="html", encoding='UTF-8') self.assertEqual(html, self.html_str)
def test_class_parse_unamed_fileobject(self): # (c)ElementTree class ElementTree has a 'parse' method that returns # the root of the tree # parse from unamed file object f = SillyFileLike() root = self.etree.ElementTree().parse(f) self.assertTrue(root.tag.endswith('foo'))