def test_stripStopAtHardNodes(self): content = "<root><p> <idref/><i> </i> This is a test. <i> </i><counter/></p></root>" root = etree.fromstring(content) plugin = strip.getInstance({}) plugin.process(root.find("./p"), "xhtml") plugin.flush() tree = etree.ElementTree(element=root) expected_result = b'<root><p><idref/><i> </i> This is a test. <i> </i><counter/></p></root>' result = etree.tostring(tree) self.assertEqual(result, expected_result)
def test_stripPlainTextContent(self): content = "<root><p> This is a test. </p></root>" root = etree.fromstring(content) plugin = strip.getInstance({}) plugin.process(root.find("./p"), "xhtml") plugin.flush() tree = etree.ElementTree(element=root) expected_result = b'<root><p>This is a test.</p></root>' result = etree.tostring(tree) self.assertEqual(result, expected_result)