summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2012-09-19 05:25:01 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2012-09-19 05:25:01 (GMT)
commitab9b661fdd4201e2471d7816dd5bf834385c9da2 (patch)
tree0113654c5432c245b8d6f2d3fe8346c098008d4d /Lib
parentda064d074556cb61309e13193d0b353668f76a49 (diff)
parentc90111f9ab617a1dbdde8952a4b81e6eecc36e7c (diff)
downloadcpython-ab9b661fdd4201e2471d7816dd5bf834385c9da2.zip
cpython-ab9b661fdd4201e2471d7816dd5bf834385c9da2.tar.gz
cpython-ab9b661fdd4201e2471d7816dd5bf834385c9da2.tar.bz2
#15970: merge with 3.2.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_xml_etree.py12
-rw-r--r--Lib/xml/etree/ElementTree.py2
2 files changed, 13 insertions, 1 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index da1ad09..97d64fc 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -1809,6 +1809,18 @@ class ElementTreeTest(unittest.TestCase):
mye = MyElement('joe')
self.assertEqual(mye.newmethod(), 'joe')
+ def test_html_empty_elems_serialization(self):
+ # issue 15970
+ # from http://www.w3.org/TR/html401/index/elements.html
+ for element in ['AREA', 'BASE', 'BASEFONT', 'BR', 'COL', 'FRAME', 'HR',
+ 'IMG', 'INPUT', 'ISINDEX', 'LINK', 'META', 'PARAM']:
+ for elem in [element, element.lower()]:
+ expected = '<%s>' % elem
+ serialized = serialize(ET.XML('<%s />' % elem), method='html')
+ self.assertEqual(serialized, expected)
+ serialized = serialize(ET.XML('<%s></%s>' % (elem,elem)),
+ method='html')
+ self.assertEqual(serialized, expected)
class ElementIterTest(unittest.TestCase):
def _ilist(self, elem, tag=None):
diff --git a/Lib/xml/etree/ElementTree.py b/Lib/xml/etree/ElementTree.py
index ea4fa7a..b9d8df6 100644
--- a/Lib/xml/etree/ElementTree.py
+++ b/Lib/xml/etree/ElementTree.py
@@ -995,7 +995,7 @@ def _serialize_xml(write, elem, qnames, namespaces):
write(_escape_cdata(elem.tail))
HTML_EMPTY = ("area", "base", "basefont", "br", "col", "frame", "hr",
- "img", "input", "isindex", "link", "meta" "param")
+ "img", "input", "isindex", "link", "meta", "param")
try:
HTML_EMPTY = set(HTML_EMPTY)