Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d3f77e6

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

1 file changed

+25Lines changed: 25 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/lxml/tests/test_htmlparser.py‎

Copy file name to clipboardExpand all lines: src/lxml/tests/test_htmlparser.py
+25Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.