Use unittest specific methods for some urllib test cases. And replace urllib2 with urllib.request in comments.

This commit is contained in:
Florent Xicluna 2010-08-08 16:16:07 +00:00
parent 1f594ad424
commit 419e384601
3 changed files with 36 additions and 37 deletions

View file

@ -172,7 +172,7 @@ class DigestAuthHandler:
auth_validated = False
# MSIE uses short_path in its validation, but Python's
# urllib2 uses the full path, so we're going to see if
# urllib.request uses the full path, so we're going to see if
# either of them works here.
for path in [request_handler.path, request_handler.short_path]:
@ -340,7 +340,7 @@ def GetRequestHandler(responses):
class TestUrlopen(BaseTestCase):
"""Tests urllib2.urlopen using the network.
"""Tests urllib.request.urlopen using the network.
These tests are not exhaustive. Assuming that testing using files does a
good job overall of some of the basic interface features. There are no
@ -392,8 +392,8 @@ class TestUrlopen(BaseTestCase):
handler = self.start_server(responses)
data = self.urlopen("http://localhost:%s/" % handler.port)
self.assertEquals(data, expected_response)
self.assertEquals(handler.requests, ["/", "/somewhere_else"])
self.assertEqual(data, expected_response)
self.assertEqual(handler.requests, ["/", "/somewhere_else"])
def test_chunked(self):
expected_response = b"hello world"
@ -407,7 +407,7 @@ class TestUrlopen(BaseTestCase):
response = [(200, [("Transfer-Encoding", "chunked")], chunked_start)]
handler = self.start_server(response)
data = self.urlopen("http://localhost:%s/" % handler.port)
self.assertEquals(data, expected_response)
self.assertEqual(data, expected_response)
def test_404(self):
expected_response = b"Bad bad bad..."
@ -421,23 +421,23 @@ class TestUrlopen(BaseTestCase):
else:
self.fail("404 should raise URLError")
self.assertEquals(data, expected_response)
self.assertEquals(handler.requests, ["/weeble"])
self.assertEqual(data, expected_response)
self.assertEqual(handler.requests, ["/weeble"])
def test_200(self):
expected_response = b"pycon 2008..."
handler = self.start_server([(200, [], expected_response)])
data = self.urlopen("http://localhost:%s/bizarre" % handler.port)
self.assertEquals(data, expected_response)
self.assertEquals(handler.requests, ["/bizarre"])
self.assertEqual(data, expected_response)
self.assertEqual(handler.requests, ["/bizarre"])
def test_200_with_parameters(self):
expected_response = b"pycon 2008..."
handler = self.start_server([(200, [], expected_response)])
data = self.urlopen("http://localhost:%s/bizarre" % handler.port,
b"get=with_feeling")
self.assertEquals(data, expected_response)
self.assertEquals(handler.requests, ["/bizarre", b"get=with_feeling"])
self.assertEqual(data, expected_response)
self.assertEqual(handler.requests, ["/bizarre", b"get=with_feeling"])
def test_sending_headers(self):
handler = self.start_server()