From 4b9629b61fc2954ca9d530cb6276899a7d4e4eb1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 29 Oct 2021 14:34:31 +0530 Subject: [PATCH] Add a test for tostring on sub-trees --- src/calibre/ebooks/oeb/polish/tests/parsing.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/calibre/ebooks/oeb/polish/tests/parsing.py b/src/calibre/ebooks/oeb/polish/tests/parsing.py index 9f5df26063..d7443ef739 100644 --- a/src/calibre/ebooks/oeb/polish/tests/parsing.py +++ b/src/calibre/ebooks/oeb/polish/tests/parsing.py @@ -167,6 +167,13 @@ basic_checks = (nonvoid_cdata_elements, namespaces, space_characters, class ParsingTests(BaseTest): + def test_lxml_tostring(self): + ' Test for bug in some versions of lxml that causes incorrect serialization of sub-trees' + from html5_parser import parse + root = parse('

a

b

c') + p = root.xpath('//p')[0] + self.assertEqual(etree.tostring(p, encoding=str), '

a

') + def test_conversion_parser(self): ' Test parsing with the HTML5 parser used for conversion ' for test in basic_checks: