summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_minidom.py
diff options
context:
space:
mode:
authorVladimir Surjaninov <vsurjaninov@gmail.com>2019-03-27 05:58:49 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-03-27 05:58:49 (GMT)
commit384b81d923addd52125e94470b11d2574ca266a9 (patch)
treeb0482ea447e6a9123c9e6f46fffaf8edb49faa51 /Lib/test/test_minidom.py
parentf760610bddd7e8f8ac0914d5d59ef806bc16a73b (diff)
downloadcpython-384b81d923addd52125e94470b11d2574ca266a9.zip
cpython-384b81d923addd52125e94470b11d2574ca266a9.tar.gz
cpython-384b81d923addd52125e94470b11d2574ca266a9.tar.bz2
bpo-36407: Fix writing indentations of CDATA section (xml.dom.minidom). (GH-12514)
Diffstat (limited to 'Lib/test/test_minidom.py')
-rw-r--r--Lib/test/test_minidom.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py
index f3ef958..7096585 100644
--- a/Lib/test/test_minidom.py
+++ b/Lib/test/test_minidom.py
@@ -1631,5 +1631,21 @@ class MinidomTest(unittest.TestCase):
'<?xml version="1.0" ?>\n'
'<curriculum status="public" company="example"/>\n')
+ def test_toprettyxml_with_cdata(self):
+ xml_str = '<?xml version="1.0" ?><root><node><![CDATA[</data>]]></node></root>'
+ doc = parseString(xml_str)
+ self.assertEqual(doc.toprettyxml(),
+ '<?xml version="1.0" ?>\n'
+ '<root>\n'
+ '\t<node><![CDATA[</data>]]></node>\n'
+ '</root>\n')
+
+ def test_cdata_parsing(self):
+ xml_str = '<?xml version="1.0" ?><root><node><![CDATA[</data>]]></node></root>'
+ dom1 = parseString(xml_str)
+ self.checkWholeText(dom1.getElementsByTagName('node')[0].firstChild, '</data>')
+ dom2 = parseString(dom1.toprettyxml())
+ self.checkWholeText(dom2.getElementsByTagName('node')[0].firstChild, '</data>')
+
if __name__ == "__main__":
unittest.main()