Author: victor.stinner Date: Wed Jul 14 01:47:50 2010 New Revision: 82863 Log: Skip test_urllib and test_urllib2 if the filename is not encodable to utf-8 Modified: python/branches/import_unicode/Lib/test/test_urllib.py python/branches/import_unicode/Lib/test/test_urllib2.py Modified: python/branches/import_unicode/Lib/test/test_urllib.py ============================================================================== --- python/branches/import_unicode/Lib/test/test_urllib.py (original) +++ python/branches/import_unicode/Lib/test/test_urllib.py Wed Jul 14 01:47:50 2010 @@ -221,8 +221,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/import_unicode/Lib/test/test_urllib2.py ============================================================================== --- python/branches/import_unicode/Lib/test/test_urllib2.py (original) +++ python/branches/import_unicode/Lib/test/test_urllib2.py Wed Jul 14 01:47:50 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:] @@ -1151,6 +1155,7 @@ self.assertEqual(len(http_handler.requests), 1) self.assertFalse(http_handler.requests[0].has_header(auth_header)) + class MiscTests(unittest.TestCase): def test_build_opener(self):
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4