diff options
author | Diego Rojas <rojastorrado@gmail.com> | 2018-11-07 14:09:04 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2018-11-07 14:09:04 (GMT) |
commit | 5598cc90c745dab827e55fadded42dbe85e31d33 (patch) | |
tree | 9bda930fd528affec3133a00711a069153f71fd2 /Lib/test/test_minidom.py | |
parent | f19447994983902aa88362d8fffe645f1ea2f2aa (diff) | |
download | cpython-5598cc90c745dab827e55fadded42dbe85e31d33.zip cpython-5598cc90c745dab827e55fadded42dbe85e31d33.tar.gz cpython-5598cc90c745dab827e55fadded42dbe85e31d33.tar.bz2 |
bpo-34160: Preserve order of attributes in minidom. (GH-10219)
Diffstat (limited to 'Lib/test/test_minidom.py')
-rw-r--r-- | Lib/test/test_minidom.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index e91cdba..ad5be2f 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -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() |