diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-14 17:08:07 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2007-08-14 17:08:07 (GMT) |
commit | 3a38c913425aad7a494661560eda4d29389868b8 (patch) | |
tree | 3bc9f049fafa1b405f77f82b4a3156ecee8367ba /Lib/test/test_httplib.py | |
parent | 5d8a88a442f1f24b8bc3ff85ffae44d8d151b91c (diff) | |
download | cpython-3a38c913425aad7a494661560eda4d29389868b8.zip cpython-3a38c913425aad7a494661560eda4d29389868b8.tar.gz cpython-3a38c913425aad7a494661560eda4d29389868b8.tar.bz2 |
Remove Python 1.5 compatibility layer from httplib.
The two clients in the std library have been updated to use the newer
interface. A couple of minor changes to the httplib tests were
needed.
Also, reformat some long lines in the httplib tests.
Diffstat (limited to 'Lib/test/test_httplib.py')
-rw-r--r-- | Lib/test/test_httplib.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/Lib/test/test_httplib.py b/Lib/test/test_httplib.py index 4c104b7..18fde4a 100644 --- a/Lib/test/test_httplib.py +++ b/Lib/test/test_httplib.py @@ -94,21 +94,22 @@ class BasicTest(TestCase): # Check invalid host_port for hp in ("www.python.org:abc", "www.python.org:"): - self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp) + self.assertRaises(httplib.InvalidURL, httplib.HTTPConnection, hp) - for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000), + for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", + "fe80::207:e9ff:fe9b", 8000), ("www.python.org:80", "www.python.org", 80), ("www.python.org", "www.python.org", 80), ("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)): - http = httplib.HTTP(hp) - c = http._conn - if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host)) - if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host)) + c = httplib.HTTPConnection(hp) + self.assertEqual(h, c.host) + self.assertEqual(p, c.port) def test_response_headers(self): # test response with multiple message headers with the same field name. text = ('HTTP/1.1 200 OK\r\n' - 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n' + 'Set-Cookie: Customer="WILE_E_COYOTE"; ' + 'Version="1"; Path="/acme"\r\n' 'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";' ' Path="/acme"\r\n' '\r\n' @@ -120,8 +121,7 @@ class BasicTest(TestCase): r = httplib.HTTPResponse(s) r.begin() cookies = r.getheader("Set-Cookie") - if cookies != hdr: - self.fail("multiple headers not combined properly") + self.assertEqual(cookies, hdr) def test_read_head(self): # Test that the library doesn't attempt to read any data @@ -138,8 +138,8 @@ class BasicTest(TestCase): resp.close() def test_send_file(self): - expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \ - 'Accept-Encoding: identity\r\nContent-Length:' + expected = ('GET /foo HTTP/1.1\r\nHost: example.com\r\n' + 'Accept-Encoding: identity\r\nContent-Length:') body = open(__file__, 'rb') conn = httplib.HTTPConnection('example.com') @@ -169,9 +169,9 @@ class TimeoutTest(TestCase): self.serv = None def testTimeoutAttribute(self): - '''This will prove that the timeout gets through - HTTPConnection and into the socket. - ''' + # This will prove that the timeout gets through HTTPConnection + # and into the socket. + # default httpConn = httplib.HTTPConnection(HOST, PORT) httpConn.connect() |