mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-34160: Preserve order of attributes in minidom. (GH-10219)
This commit is contained in:
parent
f194479949
commit
5598cc90c7
4 changed files with 34 additions and 3 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
import copy
|
||||
import pickle
|
||||
import io
|
||||
import contextlib
|
||||
from test.support import findfile
|
||||
import unittest
|
||||
|
||||
|
@ -1560,5 +1562,24 @@ class MinidomTest(unittest.TestCase):
|
|||
pi = doc.createProcessingInstruction("y", "z")
|
||||
pi.nodeValue = "crash"
|
||||
|
||||
def test_minidom_attribute_order(self):
|
||||
xml_str = '<?xml version="1.0" ?><curriculum status="public" company="example"/>'
|
||||
doc = parseString(xml_str)
|
||||
output = io.StringIO()
|
||||
doc.writexml(output)
|
||||
self.assertEqual(output.getvalue(), xml_str)
|
||||
|
||||
def test_toxml_with_attributes_ordered(self):
|
||||
xml_str = '<?xml version="1.0" ?><curriculum status="public" company="example"/>'
|
||||
doc = parseString(xml_str)
|
||||
self.assertEqual(doc.toxml(), xml_str)
|
||||
|
||||
def test_toprettyxml_with_attributes_ordered(self):
|
||||
xml_str = '<?xml version="1.0" ?><curriculum status="public" company="example"/>'
|
||||
doc = parseString(xml_str)
|
||||
self.assertEqual(doc.toprettyxml(),
|
||||
'<?xml version="1.0" ?>\n'
|
||||
'<curriculum status="public" company="example"/>\n')
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue