Пример #1
0
    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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)