summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-08-13 08:51:18 (GMT)
committerGeorg Brandl <georg@python.org>2009-08-13 08:51:18 (GMT)
commitab91fdef1f1e556203a2eee98ba7d379e4790de9 (patch)
tree6f8f00dc18cc5f2801a675df277c2c595eb85ec8 /Lib/test/test_urllib2.py
parentef82be368abdea8e8032500e7ecc3a22f5f07851 (diff)
downloadcpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.zip
cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.gz
cpython-ab91fdef1f1e556203a2eee98ba7d379e4790de9.tar.bz2
Merged revisions 73715 via svnmerge from
svn+ssh://svn.python.org/python/branches/py3k ........ r73715 | benjamin.peterson | 2009-07-01 01:06:06 +0200 (Mi, 01 Jul 2009) | 1 line convert old fail* assertions to assert* ........
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py58
1 files changed, 29 insertions, 29 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 87d0116..8093f0e 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -519,15 +519,15 @@ class OpenerDirectorTests(unittest.TestCase):
# *_request
self.assertEqual((handler, name), calls[i])
self.assertEqual(len(args), 1)
- self.assert_(isinstance(args[0], Request))
+ self.assertTrue(isinstance(args[0], Request))
else:
# *_response
self.assertEqual((handler, name), calls[i])
self.assertEqual(len(args), 2)
- self.assert_(isinstance(args[0], Request))
+ self.assertTrue(isinstance(args[0], Request))
# response from opener.open is None, because there's no
# handler that defines http_open to handle it
- self.assert_(args[1] is None or
+ self.assertTrue(args[1] is None or
isinstance(args[1], MockResponse))
@@ -577,7 +577,7 @@ class HandlerTests(unittest.TestCase):
req.timeout = None
r = h.ftp_open(req)
# ftp authentication not yet implemented by FTPHandler
- self.assert_(h.user == h.passwd == "")
+ self.assertTrue(h.user == h.passwd == "")
self.assertEqual(h.host, socket.gethostbyname(host))
self.assertEqual(h.port, port)
self.assertEqual(h.dirs, dirs)
@@ -671,9 +671,9 @@ class HandlerTests(unittest.TestCase):
h.file_open(req)
# XXXX remove OSError when bug fixed
except (urllib.error.URLError, OSError):
- self.assert_(not ftp)
+ self.assertTrue(not ftp)
else:
- self.assert_(o.req is req)
+ self.assertTrue(o.req is req)
self.assertEqual(req.type, "ftp")
def test_http(self):
@@ -754,8 +754,8 @@ class HandlerTests(unittest.TestCase):
r = MockResponse(200, "OK", {}, "")
newreq = h.do_request_(req)
if data is None: # GET
- self.assert_("Content-length" not in req.unredirected_hdrs)
- self.assert_("Content-type" not in req.unredirected_hdrs)
+ self.assertTrue("Content-length" not in req.unredirected_hdrs)
+ self.assertTrue("Content-type" not in req.unredirected_hdrs)
else: # POST
self.assertEqual(req.unredirected_hdrs["Content-length"], "0")
self.assertEqual(req.unredirected_hdrs["Content-type"],
@@ -812,19 +812,19 @@ class HandlerTests(unittest.TestCase):
# all 2xx are passed through
r = MockResponse(200, "OK", {}, "", url)
newr = h.http_response(req, r)
- self.assert_(r is newr)
- self.assert_(not hasattr(o, "proto")) # o.error not called
+ self.assertTrue(r is newr)
+ self.assertTrue(not hasattr(o, "proto")) # o.error not called
r = MockResponse(202, "Accepted", {}, "", url)
newr = h.http_response(req, r)
- self.assert_(r is newr)
- self.assert_(not hasattr(o, "proto")) # o.error not called
+ self.assertTrue(r is newr)
+ self.assertTrue(not hasattr(o, "proto")) # o.error not called
r = MockResponse(206, "Partial content", {}, "", url)
newr = h.http_response(req, r)
- self.assert_(r is newr)
- self.assert_(not hasattr(o, "proto")) # o.error not called
+ self.assertTrue(r is newr)
+ self.assertTrue(not hasattr(o, "proto")) # o.error not called
# anything else calls o.error (and MockOpener returns None, here)
r = MockResponse(502, "Bad gateway", {}, "", url)
- self.assert_(h.http_response(req, r) is None)
+ self.assertTrue(h.http_response(req, r) is None)
self.assertEqual(o.proto, "http") # o.error called
self.assertEqual(o.args, (req, r, 502, "Bad gateway", {}))
@@ -836,12 +836,12 @@ class HandlerTests(unittest.TestCase):
req = Request("http://example.com/")
r = MockResponse(200, "OK", {}, "")
newreq = h.http_request(req)
- self.assert_(cj.ach_req is req is newreq)
+ self.assertTrue(cj.ach_req is req is newreq)
self.assertEquals(req.get_origin_req_host(), "example.com")
- self.assert_(not req.is_unverifiable())
+ self.assertTrue(not req.is_unverifiable())
newr = h.http_response(req, r)
- self.assert_(cj.ec_req is req)
- self.assert_(cj.ec_r is r is newr)
+ self.assertTrue(cj.ec_req is req)
+ self.assertTrue(cj.ec_r is r is newr)
def test_redirect(self):
from_url = "http://example.com/a.html"
@@ -864,12 +864,12 @@ class HandlerTests(unittest.TestCase):
MockHeaders({"location": to_url}))
except urllib.error.HTTPError:
# 307 in response to POST requires user OK
- self.assert_(code == 307 and data is not None)
+ self.assertTrue(code == 307 and data is not None)
self.assertEqual(o.req.get_full_url(), to_url)
try:
self.assertEqual(o.req.get_method(), "GET")
except AttributeError:
- self.assert_(not o.req.has_data())
+ self.assertTrue(not o.req.has_data())
# now it's a GET, there should not be headers regarding content
# (possibly dragged from before being a POST)
@@ -879,8 +879,8 @@ class HandlerTests(unittest.TestCase):
self.assertEqual(o.req.headers["Nonsense"],
"viking=withhold")
- self.assert_("Spam" not in o.req.headers)
- self.assert_("Spam" not in o.req.unredirected_hdrs)
+ self.assertTrue("Spam" not in o.req.headers)
+ self.assertTrue("Spam" not in o.req.unredirected_hdrs)
# loop detection
req = Request(from_url)
@@ -928,7 +928,7 @@ class HandlerTests(unittest.TestCase):
cp = urllib.request.HTTPCookieProcessor(cj)
o = build_test_opener(hh, hdeh, hrh, cp)
o.open("http://www.example.com/")
- self.assert_(not hh.req.has_header("Cookie"))
+ self.assertTrue(not hh.req.has_header("Cookie"))
def test_proxy(self):
o = OpenerDirector()
@@ -1128,7 +1128,7 @@ class MiscTests(unittest.TestCase):
if h.__class__ == handler_class:
break
else:
- self.assert_(False)
+ self.assertTrue(False)
class RequestTests(unittest.TestCase):
@@ -1143,10 +1143,10 @@ class RequestTests(unittest.TestCase):
self.assertEqual("GET", self.get.get_method())
def test_add_data(self):
- self.assert_(not self.get.has_data())
+ self.assertTrue(not self.get.has_data())
self.assertEqual("GET", self.get.get_method())
self.get.add_data("spam")
- self.assert_(self.get.has_data())
+ self.assertTrue(self.get.has_data())
self.assertEqual("POST", self.get.get_method())
def test_get_full_url(self):
@@ -1169,9 +1169,9 @@ class RequestTests(unittest.TestCase):
self.assertEqual("www.python.org", req.get_host())
def test_proxy(self):
- self.assert_(not self.get.has_proxy())
+ self.assertTrue(not self.get.has_proxy())
self.get.set_proxy("www.perl.org", "http")
- self.assert_(self.get.has_proxy())
+ self.assertTrue(self.get.has_proxy())
self.assertEqual("www.python.org", self.get.get_origin_req_host())
self.assertEqual("www.perl.org", self.get.get_host())