diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 08:32:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 08:32:11 (GMT) |
commit | 765122fcb541ea9d3dd3a768e94f7238fb16a6f8 (patch) | |
tree | 38862817f3a61901732dfe86de33cbe17a7a265c /Lib | |
parent | c1eb48a8fd6b1730e02e383988208469900ce363 (diff) | |
parent | efbf40f9e1db0c5e4298d8ea7b4187226e8dfab0 (diff) | |
download | cpython-765122fcb541ea9d3dd3a768e94f7238fb16a6f8.zip cpython-765122fcb541ea9d3dd3a768e94f7238fb16a6f8.tar.gz cpython-765122fcb541ea9d3dd3a768e94f7238fb16a6f8.tar.bz2 |
Issue #11159: Add tests for testing SAX parser support of non-ascii file names.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sax.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 7bb30cd..c4b3276 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -14,6 +14,8 @@ from xml.sax.expatreader import create_parser from xml.sax.handler import feature_namespaces from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl from io import StringIO +import shutil +from test import support from test.support import findfile, run_unittest import unittest @@ -481,6 +483,20 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(result.getvalue(), xml_test_out) + def test_expat_file_nonascii(self): + fname = support.TESTFN_UNICODE + shutil.copyfile(TEST_XMLFILE, fname) + self.addCleanup(support.unlink, fname) + + parser = create_parser() + result = StringIO() + xmlgen = XMLGenerator(result) + + parser.setContentHandler(xmlgen) + parser.parse(open(fname)) + + self.assertEqual(result.getvalue(), xml_test_out) + # ===== DTDHandler support class TestDTDHandler: @@ -620,6 +636,20 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(result.getvalue(), xml_test_out) + def test_expat_inpsource_sysid_nonascii(self): + fname = support.TESTFN_UNICODE + shutil.copyfile(TEST_XMLFILE, fname) + self.addCleanup(support.unlink, fname) + + parser = create_parser() + result = StringIO() + xmlgen = XMLGenerator(result) + + parser.setContentHandler(xmlgen) + parser.parse(InputSource(fname)) + + self.assertEqual(result.getvalue(), xml_test_out) + def test_expat_inpsource_stream(self): parser = create_parser() result = StringIO() @@ -694,6 +724,20 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(parser.getSystemId(), TEST_XMLFILE) self.assertEqual(parser.getPublicId(), None) + def test_expat_locator_withinfo_nonascii(self): + fname = support.TESTFN_UNICODE + shutil.copyfile(TEST_XMLFILE, fname) + self.addCleanup(support.unlink, fname) + + result = StringIO() + xmlgen = XMLGenerator(result) + parser = create_parser() + parser.setContentHandler(xmlgen) + parser.parse(fname) + + self.assertEqual(parser.getSystemId(), fname) + self.assertEqual(parser.getPublicId(), None) + # =========================================================================== # |