Fix Issue11703 - urllib2.geturl() does not return correct url when the original url contains #fragment. Patch Contribution by Santoso Wijaya.

This commit is contained in:
Senthil Kumaran 2011-04-13 07:01:19 +08:00
parent 3780542039
commit 2643041970
4 changed files with 31 additions and 5 deletions

View file

@ -171,6 +171,16 @@ class urlopen_HttpTests(unittest.TestCase):
finally:
self.unfakehttp()
def test_url_fragment(self):
# Issue #11703: geturl() omits fragments in the original URL.
url = 'http://docs.python.org/library/urllib.html#OK'
self.fakehttp(b'Hello!')
try:
fp = urllib.request.urlopen(url)
self.assertEqual(fp.geturl(), url)
finally:
self.unfakehttp()
def test_read_bogus(self):
# urlopen() should raise IOError for many error codes.
self.fakehttp(b'''HTTP/1.1 401 Authentication Required