Use unittest specific methods for some urllib test cases. And replace urllib2 with urllib.request in comments.
diff --git a/Lib/test/test_urllib2_localnet.py b/Lib/test/test_urllib2_localnet.py
index 4489356..b478996 100644
--- a/Lib/test/test_urllib2_localnet.py
+++ b/Lib/test/test_urllib2_localnet.py
@@ -172,7 +172,7 @@
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 @@
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 @@
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 @@
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 @@
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()