[Python-Dev] [Python-checkins] r83778 - in python/branches/py3k/Lib/test: test_import.py test_sax.py test_sys.py test_urllib.py test_urllib2.py test_xml_etree.py (original) (raw)
Ezio Melotti ezio.melotti at gmail.com
Sat Aug 7 14:49:05 CEST 2010
- Previous message: [Python-Dev] builtin round 2.7
- Next message: [Python-Dev] mingw support?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
On 07/08/2010 13.09, victor.stinner wrote:
Author: victor.stinner Date: Sat Aug 7 12:09:35 2010 New Revision: 83778
Log: Issue #9425: skip tests if a filename is not encodable Modified: python/branches/py3k/Lib/test/testimport.py python/branches/py3k/Lib/test/testsax.py python/branches/py3k/Lib/test/testsys.py python/branches/py3k/Lib/test/testurllib.py python/branches/py3k/Lib/test/testurllib2.py python/branches/py3k/Lib/test/testxmletree.py Modified: python/branches/py3k/Lib/test/testimport.py ============================================================================== --- python/branches/py3k/Lib/test/testimport.py (original) +++ python/branches/py3k/Lib/test/testimport.py Sat Aug 7 12:09:35 2010 @@ -291,6 +291,11 @@ def testimportbyfilename(self): path = os.path.abspath(TESTFN) + encoding = sys.getfilesystemencoding() + try: + path.encode(encoding) + except UnicodeEncodeError: + self.skipTest('path is not encodable to {}'.format(encoding)) with self.assertRaises(ImportError) as c: import(path) self.assertEqual("Import by filename is not supported.", Modified: python/branches/py3k/Lib/test/testsax.py ============================================================================== --- python/branches/py3k/Lib/test/testsax.py (original) +++ python/branches/py3k/Lib/test/testsax.py Sat Aug 7 12:09:35 2010 @@ -18,6 +18,11 @@ TESTXMLFILE = findfile("test.xml", subdir="xmltestdata") TESTXMLFILEOUT = findfile("test.xml.out", subdir="xmltestdata") +try: + TESTXMLFILE.encode("utf8") + TESTXMLFILEOUT.encode("utf8") +except UnicodeEncodeError: + raise unittest.SkipTest("filename is not encodable to utf8") nsuri = "http://www.python.org/xml-ns/saxtest/"
Modified: python/branches/py3k/Lib/test/testsys.py ============================================================================== --- python/branches/py3k/Lib/test/testsys.py (original) +++ python/branches/py3k/Lib/test/testsys.py Sat Aug 7 12:09:35 2010 @@ -509,8 +509,10 @@ p = subprocess.Popen([sys.executable, "-c", code], stderr=subprocess.PIPE) stdout, stderr = p.communicate() self.assertEqual(p.returncode, 1) - self.assert(b"UnicodeEncodeError:" in stderr, - "%r not in %s" % (b"UniodeEncodeError:", ascii(stderr))) + self.assertIn( + br"UnicodeEncodeError: 'utf-8' codec can't encode character " + br"'\udcff' in position 7: surrogates not allowed", + stderr)
This caused some failures in the buildbots:
test test_sys failed -- Traceback (most recent call last): File "/home2/buildbot/slave/3.x.loewis-sun/build/Lib/test/test_sys.py", line 515, in test_main_invalid_unicode stderr) AssertionError: b"UnicodeEncodeError: 'utf-8' codec can't encode character '\udcff' in position 7: surrogates not allowed" not found in b'Traceback (most recent call last):\n File "", line 1, in\nUnicodeEncodeError: 'ascii' codec can't encode character '\xff' in position 0: ordinal not in range(128)\n[32513 refs]\n'
def testsysflags(self): self.assertTrue(sys.flags) Modified: python/branches/py3k/Lib/test/testurllib.py ============================================================================== --- python/branches/py3k/Lib/test/testurllib.py (original) +++ python/branches/py3k/Lib/test/testurllib.py Sat Aug 7 12:09:35 2010 @@ -232,8 +232,12 @@ except: pass def constructLocalFileUrl(self, filePath): - return "file://%s" % urllib.request.pathname2url( - os.path.abspath(filePath)) + filePath = os.path.abspath(filePath) + try: + filePath.encode("utf8") + except UnicodeEncodeError: + raise unittest.SkipTest("filePath is not encodable to utf8") + return "file://%s" % urllib.request.pathname2url(filePath) def createNewTempFile(self, data=b""): """Creates a new temporary file containing the specified data, Modified: python/branches/py3k/Lib/test/testurllib2.py ============================================================================== --- python/branches/py3k/Lib/test/testurllib2.py (original) +++ python/branches/py3k/Lib/test/testurllib2.py Sat Aug 7 12:09:35 2010 @@ -597,6 +597,10 @@
def sanepathname2url(path): + try: + path.encode("utf8") + except UnicodeEncodeError: + raise unittest.SkipTest("path is not encodable to utf8") urlpath = urllib.request.pathname2url(path) if os.name == "nt" and urlpath.startswith("///"): urlpath = urlpath[2:] Modified: python/branches/py3k/Lib/test/testxmletree.py ============================================================================== --- python/branches/py3k/Lib/test/testxmletree.py (original) +++ python/branches/py3k/Lib/test/testxmletree.py Sat Aug 7 12:09:35 2010 @@ -13,6 +13,7 @@ import sys import cgi +import unittest from test import support from test.support import findfile @@ -20,6 +21,10 @@ from xml.etree import ElementTree as ET SIMPLEXMLFILE = findfile("simple.xml", subdir="xmltestdata") +try: + SIMPLEXMLFILE.encode("utf8") +except UnicodeEncodeError: + raise unittest.SkipTest("filename is not encodable to utf8") SIMPLENSXMLFILE = findfile("simple-ns.xml", subdir="xmltestdata") _SAMPLEXML = """_
Python-checkins mailing list Python-checkins at python.org http://mail.python.org/mailman/listinfo/python-checkins
Best Regards, Ezio Melotti
- Previous message: [Python-Dev] builtin round 2.7
- Next message: [Python-Dev] mingw support?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]