summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sax.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-05-12 14:31:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2013-05-12 14:31:16 (GMT)
commit3eab6b363a968e907605fe749d12941c3be29761 (patch)
tree2a2bdf318b72e49e7c3e534b005ada224693cebb /Lib/test/test_sax.py
parent521ed521317ffd385afaabdd889879e7cb7461df (diff)
downloadcpython-3eab6b363a968e907605fe749d12941c3be29761.zip
cpython-3eab6b363a968e907605fe749d12941c3be29761.tar.gz
cpython-3eab6b363a968e907605fe749d12941c3be29761.tar.bz2
Issue #17606: Fixed support of encoded byte strings in the XMLGenerator
characters() and ignorableWhitespace() methods. Original patch by Sebastian Ortiz Vasquez.
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r--Lib/test/test_sax.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index 0261c6a..502c962 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -319,6 +319,24 @@ class XmlgenTest:
self.assertEqual(result.getvalue(), self.xml("<doc> </doc>"))
+ def test_xmlgen_encoding_bytes(self):
+ encodings = ('iso-8859-15', 'utf-8', 'utf-8-sig',
+ 'utf-16', 'utf-16be', 'utf-16le',
+ 'utf-32', 'utf-32be', 'utf-32le')
+ for encoding in encodings:
+ result = self.ioclass()
+ gen = XMLGenerator(result, encoding=encoding)
+
+ gen.startDocument()
+ gen.startElement("doc", {"a": '\u20ac'})
+ gen.characters("\u20ac".encode(encoding))
+ gen.ignorableWhitespace(" ".encode(encoding))
+ gen.endElement("doc")
+ gen.endDocument()
+
+ self.assertEqual(result.getvalue(),
+ self.xml('<doc a="\u20ac">\u20ac </doc>', encoding=encoding))
+
def test_xmlgen_ns(self):
result = self.ioclass()
gen = XMLGenerator(result)