diff options
author | Eli Bendersky <eliben@gmail.com> | 2013-01-13 14:04:43 (GMT) |
---|---|---|
committer | Eli Bendersky <eliben@gmail.com> | 2013-01-13 14:04:43 (GMT) |
commit | a9a2ef5550e19844a078b9466d98ebca76e88943 (patch) | |
tree | 460ea32821af6282385adbcb3c04c5bce7e2a1ad /Lib/test/test_xml_etree.py | |
parent | a50ff1887d706ff193b698013931516307972382 (diff) | |
download | cpython-a9a2ef5550e19844a078b9466d98ebca76e88943.zip cpython-a9a2ef5550e19844a078b9466d98ebca76e88943.tar.gz cpython-a9a2ef5550e19844a078b9466d98ebca76e88943.tar.bz2 |
Close #14377: Add a new parameter to ElementTree.write and some module-level
serialization functions - short_empty_elements. It controls how elements
without contents are emitted.
Patch by Serhiy Storchaka. Feature initially proposed by Ariel Poliak.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r-- | Lib/test/test_xml_etree.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py index b4edd74..f2bbb4c 100644 --- a/Lib/test/test_xml_etree.py +++ b/Lib/test/test_xml_etree.py @@ -2380,6 +2380,18 @@ class IOTest(unittest.TestCase): ET.tostring(root, 'utf-16'), b''.join(ET.tostringlist(root, 'utf-16'))) + def test_short_empty_elements(self): + root = ET.fromstring('<tag>a<x />b<y></y>c</tag>') + self.assertEqual( + ET.tostring(root, 'unicode'), + '<tag>a<x />b<y />c</tag>') + self.assertEqual( + ET.tostring(root, 'unicode', short_empty_elements=True), + '<tag>a<x />b<y />c</tag>') + self.assertEqual( + ET.tostring(root, 'unicode', short_empty_elements=False), + '<tag>a<x></x>b<y></y>c</tag>') + class ParseErrorTest(unittest.TestCase): def test_subclass(self): |