Scrapy, a fast high-level web crawling & scraping framework for Python.
Fixed test_utils_url, broken on Windows after recent Python urllib change. Closes #251
Pablo Hoffman5d4e0655d089
diff --git a/scrapy/tests/test_utils_url.py b/scrapy/tests/test_utils_url.pyindex 6884b81a9..1292a84f6 100644--- a/scrapy/tests/test_utils_url.py+++ b/scrapy/tests/test_utils_url.py@@ -277,7 +277,7 @@ class UrlUtilsTest(unittest.TestCase):def test_path_to_file_uri(self):if os.name == 'nt':self.assertEqual(path_to_file_uri("C:\\windows\clock.avi"),- "file:///C|/windows/clock.avi")+ "file:///C:/windows/clock.avi")else:self.assertEqual(path_to_file_uri("/some/path.txt"),"file:///some/path.txt")@@ -289,9 +289,9 @@ class UrlUtilsTest(unittest.TestCase):def test_file_uri_to_path(self):if os.name == 'nt':- self.assertEqual(file_uri_to_path("file:///C|/windows/clock.avi"),+ self.assertEqual(file_uri_to_path("file:///C:/windows/clock.avi"),"C:\\windows\clock.avi")- uri = "file:///C|/windows/clock.avi"+ uri = "file:///C:/windows/clock.avi"uri2 = path_to_file_uri(file_uri_to_path(uri))self.assertEqual(uri, uri2)else:@@ -309,7 +309,7 @@ class UrlUtilsTest(unittest.TestCase):def test_any_to_uri(self):if os.name == 'nt':self.assertEqual(any_to_uri("C:\\windows\clock.avi"),- "file:///C|/windows/clock.avi")+ "file:///C:/windows/clock.avi")else:self.assertEqual(any_to_uri("/some/path.txt"),"file:///some/path.txt")diff --git a/scrapy/utils/url.py b/scrapy/utils/url.pyindex 552f343f5..ae010cb9e 100644--- a/scrapy/utils/url.py+++ b/scrapy/utils/url.py@@ -161,6 +161,8 @@ def path_to_file_uri(path):http://en.wikipedia.org/wiki/File_URI_scheme"""x = urllib.pathname2url(os.path.abspath(path))+ if os.name == 'nt':+ x = x.replace('|', ':') # http://bugs.python.org/issue5861return 'file:///%s' % x.lstrip('/')def file_uri_to_path(uri):