summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_xml_etree.py
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2015-09-23 01:14:35 (GMT)
committerMartin Panter <vadmium+py@gmail.com>2015-09-23 01:14:35 (GMT)
commit89f76d3f913e0527fbcc0d15cb3c17fbf6ca8618 (patch)
tree424af9f48cbd50e1e1dc00aaa2230a57dd816a8b /Lib/test/test_xml_etree.py
parentf94471c1401e06df3021eafdde99c9be2c344dcb (diff)
downloadcpython-89f76d3f913e0527fbcc0d15cb3c17fbf6ca8618.zip
cpython-89f76d3f913e0527fbcc0d15cb3c17fbf6ca8618.tar.gz
cpython-89f76d3f913e0527fbcc0d15cb3c17fbf6ca8618.tar.bz2
Issue #25047: Respect case writing XML encoding declarations
This restores the ability to write encoding names in uppercase like "UTF-8", which worked in Python 2.
Diffstat (limited to 'Lib/test/test_xml_etree.py')
-rw-r--r--Lib/test/test_xml_etree.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/test/test_xml_etree.py b/Lib/test/test_xml_etree.py
index 1c6a939..b87b098 100644
--- a/Lib/test/test_xml_etree.py
+++ b/Lib/test/test_xml_etree.py
@@ -2396,14 +2396,21 @@ class IOTest(unittest.TestCase):
elem = ET.Element("tag")
elem.text = "abc"
self.assertEqual(serialize(elem), '<tag>abc</tag>')
- self.assertEqual(serialize(elem, encoding="utf-8"),
- b'<tag>abc</tag>')
- self.assertEqual(serialize(elem, encoding="us-ascii"),
- b'<tag>abc</tag>')
+ for enc in ("utf-8", "us-ascii"):
+ with self.subTest(enc):
+ self.assertEqual(serialize(elem, encoding=enc),
+ b'<tag>abc</tag>')
+ self.assertEqual(serialize(elem, encoding=enc.upper()),
+ b'<tag>abc</tag>')
for enc in ("iso-8859-1", "utf-16", "utf-32"):
- self.assertEqual(serialize(elem, encoding=enc),
- ("<?xml version='1.0' encoding='%s'?>\n"
- "<tag>abc</tag>" % enc).encode(enc))
+ with self.subTest(enc):
+ self.assertEqual(serialize(elem, encoding=enc),
+ ("<?xml version='1.0' encoding='%s'?>\n"
+ "<tag>abc</tag>" % enc).encode(enc))
+ upper = enc.upper()
+ self.assertEqual(serialize(elem, encoding=upper),
+ ("<?xml version='1.0' encoding='%s'?>\n"
+ "<tag>abc</tag>" % upper).encode(enc))
elem = ET.Element("tag")
elem.text = "<&\"\'>"