From: Senthil Kumaran Date: Tue, 12 Apr 2011 23:22:29 +0000 (+0800) Subject: merge from 3.1 X-Git-Tag: v3.2.1b1~143 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b17abb1af9e36c728e4fc9e27a9fd9441d3f77a2;p=thirdparty%2FPython%2Fcpython.git merge from 3.1 --- b17abb1af9e36c728e4fc9e27a9fd9441d3f77a2 diff --cc Lib/test/test_urllib.py index 11e5dad5bf5a,462a2b03f834..275b2eb81e90 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@@ -175,25 -171,16 +175,35 @@@ class urlopen_HttpTests(unittest.TestCa 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!') ++ self.fakehttp(b"HTTP/1.1 200 OK\r\n\r\nHello!") + try: + fp = urllib.request.urlopen(url) + self.assertEqual(fp.geturl(), url) + finally: + self.unfakehttp() + + def test_willclose(self): + self.fakehttp(b"HTTP/1.1 200 OK\r\n\r\nHello!") + try: + resp = urlopen("http://www.python.org") + self.assertTrue(resp.fp.will_close) + finally: + self.unfakehttp() + + def test_read_0_9(self): + # "0.9" response accepted (but not "simple responses" without + # a status line) + self.check_read(b"0.9") + + def test_read_1_0(self): + self.check_read(b"1.0") + + def test_read_1_1(self): + self.check_read(b"1.1") + def test_read_bogus(self): # urlopen() should raise IOError for many error codes. self.fakehttp(b'''HTTP/1.1 401 Authentication Required