summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2016-09-12 06:18:03 (GMT)
committerRaymond Hettinger <python@rcn.com>2016-09-12 06:18:03 (GMT)
commit076366c2a52b1446eb684806f95e10c91366094a (patch)
treecb8d617ff122ea64fb9c8a3d45a59faa4a53d826 /Lib/test
parent4b73676c3d260b37b91dedbc0b286c4e779350e4 (diff)
downloadcpython-076366c2a52b1446eb684806f95e10c91366094a.zip
cpython-076366c2a52b1446eb684806f95e10c91366094a.tar.gz
cpython-076366c2a52b1446eb684806f95e10c91366094a.tar.bz2
Issue #17582: xml.etree.ElementTree nows preserves whitespaces in attributes
(Patch by Duane Griffin. Reviewed and approved by Stefan Behnel.)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_xml_etree.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index bc1dd14..fbfc0b0 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -405,6 +405,14 @@ class ElementTreeTest(unittest.TestCase):
self.assertEqual(ET.tostring(elem),
b'<test testa="testval" testb="test1" testc="test2">aa</test>')
+ elem = ET.Element('test')
+ elem.set('a', '\r')
+ elem.set('b', '\r\n')
+ elem.set('c', '\t\n\r ')
+ elem.set('d', '\n\n')
+ self.assertEqual(ET.tostring(elem),
+ b'<test a="&#10;" b="&#10;" c="&#09;&#10;&#10; " d="&#10;&#10;" />')
+
def test_makeelement(self):
# Test makeelement handling.