Skip to content

Commit d3f77e6

Browse files
committed
Add a test for https://bugs.launchpad.net/lxml/+bug/1965070 leaving out the actual failure case.
1 parent 7f7f226 commit d3f77e6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/lxml/tests/test_htmlparser.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,31 @@ def test_boolean_attribute_xml_adds_empty_string(self):
653653
self.assertEqual(self.etree.tostring(html.fragment_fromstring(fragment)),
654654
_bytes('<tag attribute=""/>'))
655655

656+
def test_xhtml_as_html_as_xml(self):
657+
# parse XHTML as HTML, serialise as XML
658+
# See https://bugs.launchpad.net/lxml/+bug/1965070
659+
xhtml = (
660+
b'<?xml version="1.0" encoding="UTF-8"?>'
661+
b'<html xmlns="http://www.w3.org/1999/xhtml"></html>'
662+
)
663+
root = html.fromstring(xhtml)
664+
print(root.attrib)
665+
result = etree.tostring(root)
666+
self.assertEqual(result, b'<html xmlns="http://www.w3.org/1999/xhtml"/>')
667+
668+
# Adding an XHTML doctype makes libxml2 add the namespace, which wasn't parsed as such by the HTML parser.
669+
"""
670+
xhtml = (
671+
b'<?xml version="1.0" encoding="UTF-8"?>'
672+
b'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
673+
b'<html xmlns="http://www.w3.org/1999/xhtml"></html>'
674+
)
675+
root = html.fromstring(xhtml)
676+
print(root.attrib)
677+
result = etree.tostring(root)
678+
self.assertEqual(result, b'<html xmlns="http://www.w3.org/1999/xhtml"/>')
679+
"""
680+
656681

657682
def test_suite():
658683
suite = unittest.TestSuite()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy