drive = urllib.parse.quote(comp[0].upper())
components = comp[1].split('\\')
- path = '///' + drive + '|'
+ path = '///' + drive + ':'
for comp in components:
if comp:
path = path + '/' + urllib.parse.quote(comp)
self.assertEqual(('user', 'a\vb'),urllib.parse.splitpasswd('user:a\vb'))
self.assertEqual(('user', 'a:b'),urllib.parse.splitpasswd('user:a:b'))
+
+class URLopener_Tests(unittest.TestCase):
+ """Testcase to test the open method of URLopener class."""
+
+ def test_quoted_open(self):
+ class DummyURLopener(urllib.request.URLopener):
+ def open_spam(self, url):
+ return url
+
+ self.assertEqual(DummyURLopener().open(
+ 'spam://example/ /'),'//example/%20/')
+
# Just commented them out.
# Can't really tell why keep failing in windows and sparc.
# Everywhere else they work ok, but on those machines, someteimes
urlencode_Tests,
Pathname_Tests,
Utility_Tests,
+ URLopener_Tests,
#FTPWrapperTests,
)
def open(self, fullurl, data=None):
"""Use URLopener().open(file) instead of open(file, 'r')."""
fullurl = unwrap(to_bytes(fullurl))
+ fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]")
if self.tempcache and fullurl in self.tempcache:
filename, headers = self.tempcache[fullurl]
fp = open(filename, 'rb')