mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
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.
This commit is contained in:
parent
a50ff1887d
commit
a9a2ef5550
4 changed files with 56 additions and 14 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue