diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 10:17:05 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-02-02 10:17:05 (GMT) |
commit | 1a4ed4ce1839646d64b5e147ea65f44ca5fcfefb (patch) | |
tree | fed87e641364e1971b81ea19e4c51dcd4669f8b1 /Lib | |
parent | 5a9c1a753f615bfcbccc99ed401f0ac922b07097 (diff) | |
download | cpython-1a4ed4ce1839646d64b5e147ea65f44ca5fcfefb.zip cpython-1a4ed4ce1839646d64b5e147ea65f44ca5fcfefb.tar.gz cpython-1a4ed4ce1839646d64b5e147ea65f44ca5fcfefb.tar.bz2 |
Fix tests for issue #11159.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_sax.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_sax.py b/Lib/test/test_sax.py index 7b989e8..a96f0a8 100644 --- a/Lib/test/test_sax.py +++ b/Lib/test/test_sax.py @@ -14,6 +14,7 @@ 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 os.path import shutil from test import support from test.support import findfile, run_unittest @@ -27,6 +28,18 @@ try: except UnicodeEncodeError: raise unittest.SkipTest("filename is not encodable to utf8") +supports_nonascii_filenames = True +if not os.path.supports_unicode_filenames: + try: + support.TESTFN_UNICODE.encode(support.TESTFN_ENCODING) + except (UnicodeError, TypeError): + # Either the file system encoding is None, or the file name + # cannot be encoded in the file system encoding. + supports_nonascii_filenames = False +requires_nonascii_filenames = unittest.skipUnless( + supports_nonascii_filenames, + 'Requires non-ascii filenames support') + ns_uri = "http://www.python.org/xml-ns/saxtest/" class XmlTestBase(unittest.TestCase): @@ -483,6 +496,7 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(result.getvalue(), xml_test_out) + @requires_nonascii_filenames def test_expat_file_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) @@ -636,6 +650,7 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(result.getvalue(), xml_test_out) + @requires_nonascii_filenames def test_expat_inpsource_sysid_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) @@ -724,6 +739,7 @@ class ExpatReaderTest(XmlTestBase): self.assertEqual(parser.getSystemId(), TEST_XMLFILE) self.assertEqual(parser.getPublicId(), None) + @requires_nonascii_filenames def test_expat_locator_withinfo_nonascii(self): fname = support.TESTFN_UNICODE shutil.copyfile(TEST_XMLFILE, fname) |