summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_sax.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-27 20:13:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-27 20:13:16 (GMT)
commitfc8e9b0e726c14d10cf33864710364b3cb4ae368 (patch)
tree0bfb71556470c4bdbbc4e40b8b1555c189ab6727 /Lib/test/test_sax.py
parent7a6915e17d1ea9d740c23772160c18fdd5a5395f (diff)
downloadcpython-fc8e9b0e726c14d10cf33864710364b3cb4ae368.zip
cpython-fc8e9b0e726c14d10cf33864710364b3cb4ae368.tar.gz
cpython-fc8e9b0e726c14d10cf33864710364b3cb4ae368.tar.bz2
Issue #22915: SAX parser now supports files opened with file descriptor or
bytes path.
Diffstat (limited to 'Lib/test/test_sax.py')
-rw-r--r--Lib/test/test_sax.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py
index cfa18f7..a6238b2 100644
--- a/Lib/test/test_sax.py
+++ b/Lib/test/test_sax.py
@@ -648,6 +648,30 @@ class ExpatReaderTest(XmlTestBase):
self.assertEqual(result.getvalue(), xml_test_out)
+ def test_expat_binary_file_bytes_name(self):
+ fname = os.fsencode(TEST_XMLFILE)
+ parser = create_parser()
+ result = BytesIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ with open(fname, 'rb') as f:
+ parser.parse(f)
+
+ self.assertEqual(result.getvalue(), xml_test_out)
+
+ def test_expat_binary_file_int_name(self):
+ parser = create_parser()
+ result = BytesIO()
+ xmlgen = XMLGenerator(result)
+
+ parser.setContentHandler(xmlgen)
+ with open(TEST_XMLFILE, 'rb') as f:
+ with open(f.fileno(), 'rb', closefd=False) as f2:
+ parser.parse(f2)
+
+ self.assertEqual(result.getvalue(), xml_test_out)
+
# ===== DTDHandler support
class TestDTDHandler: