diff options
author | Florent Xicluna <florent.xicluna@gmail.com> | 2010-08-14 18:24:40 (GMT) |
---|---|---|
committer | Florent Xicluna <florent.xicluna@gmail.com> | 2010-08-14 18:24:40 (GMT) |
commit | b4efb3d81e8a22f553d92cfb924258f9c3bca415 (patch) | |
tree | c6dfcbdd2d22ac9e31bb9f0326240e1a5bbe1e55 /Lib/test/test_urllib2.py | |
parent | 355447330926fc8e7c8d0163a0739a149d6844a2 (diff) | |
download | cpython-b4efb3d81e8a22f553d92cfb924258f9c3bca415.zip cpython-b4efb3d81e8a22f553d92cfb924258f9c3bca415.tar.gz cpython-b4efb3d81e8a22f553d92cfb924258f9c3bca415.tar.bz2 |
Merged revisions 83212,83829,83833,83838-83839,83878,84019,84025,84028,84032,84036 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r83212 | florent.xicluna | 2010-07-28 18:39:41 +0200 (mer., 28 juil. 2010) | 2 lines
Syntax cleanup.
........
r83829 | florent.xicluna | 2010-08-08 18:16:07 +0200 (dim., 08 août 2010) | 2 lines
Use unittest specific methods for some urllib test cases. And replace urllib2 with urllib.request in comments.
........
r83833 | florent.xicluna | 2010-08-08 18:25:27 +0200 (dim., 08 août 2010) | 2 lines
Add test case for the HTTPResponse being an iterable. Follow-up of issue #4608.
........
r83838 | florent.xicluna | 2010-08-08 20:03:44 +0200 (dim., 08 août 2010) | 2 lines
Typo.
........
r83839 | florent.xicluna | 2010-08-08 20:06:13 +0200 (dim., 08 août 2010) | 2 lines
Issue #7564: Skip test_ioctl if another process is attached to /dev/tty.
........
r83878 | florent.xicluna | 2010-08-09 10:29:08 +0200 (lun., 09 août 2010) | 1 line
Merge the 2to3 script from /sandbox/trunk/2to3/2to3, revision 72867 (latest).
........
r84019 | florent.xicluna | 2010-08-14 17:56:42 +0200 (sam., 14 août 2010) | 11 lines
Merged manually from 2.7 branch to 3.x trunk.
------------------------------------------------------------------------
r79925 | nick.coghlan | 2010-04-10 16:24:36 +0200 (sam. 10 avril 2010)
Try to turn some buildbots green by allowing test_multiprocessing to
pass even if it hits the sys.exc_clear code in the threading module, and
improve the test coverage by making the ctypes dependencies a bit more
granular (two of the cited ctypes objects don't exist on my system)
------------------------------------------------------------------------
........
r84025 | florent.xicluna | 2010-08-14 18:56:27 +0200 (sam., 14 août 2010) | 1 line
List Misc/python-config.in in Misc/README. Fix few typos.
........
r84028 | florent.xicluna | 2010-08-14 19:02:49 +0200 (sam., 14 août 2010) | 1 line
Fix order.
........
r84032 | florent.xicluna | 2010-08-14 19:15:31 +0200 (sam., 14 août 2010) | 1 line
Convert to spaces.
........
r84036 | florent.xicluna | 2010-08-14 20:03:19 +0200 (sam., 14 août 2010) | 1 line
Remove bad merge (from svnmerge r82301)
........
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r-- | Lib/test/test_urllib2.py | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 83bd467..0f8395e 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -46,7 +46,7 @@ class TrivialTests(unittest.TestCase): ('a="b\\"c", d="e\\,f", g="h\\\\i"', ['a="b"c"', 'd="e,f"', 'g="h\\i"'])] for string, list in tests: - self.assertEquals(urllib.request.parse_http_list(string), list) + self.assertEqual(urllib.request.parse_http_list(string), list) def test_request_headers_dict(): @@ -744,9 +744,9 @@ class HandlerTests(unittest.TestCase): h.file_open(req) # XXXX remove OSError when bug fixed except (urllib.error.URLError, OSError): - self.assertTrue(not ftp) + self.assertFalse(ftp) else: - self.assertTrue(o.req is req) + self.assertIs(o.req, req) self.assertEqual(req.type, "ftp") self.assertEqual(req.type is "ftp", ftp) @@ -849,19 +849,19 @@ class HandlerTests(unittest.TestCase): # all 2xx are passed through r = MockResponse(200, "OK", {}, "", url) newr = h.http_response(req, r) - self.assertTrue(r is newr) - self.assertTrue(not hasattr(o, "proto")) # o.error not called + self.assertIs(r, newr) + self.assertFalse(hasattr(o, "proto")) # o.error not called r = MockResponse(202, "Accepted", {}, "", url) newr = h.http_response(req, r) - self.assertTrue(r is newr) - self.assertTrue(not hasattr(o, "proto")) # o.error not called + self.assertIs(r, newr) + self.assertFalse(hasattr(o, "proto")) # o.error not called r = MockResponse(206, "Partial content", {}, "", url) newr = h.http_response(req, r) - self.assertTrue(r is newr) - self.assertTrue(not hasattr(o, "proto")) # o.error not called + self.assertIs(r, newr) + self.assertFalse(hasattr(o, "proto")) # o.error not called # anything else calls o.error (and MockOpener returns None, here) r = MockResponse(502, "Bad gateway", {}, "", url) - self.assertTrue(h.http_response(req, r) is None) + self.assertIsNone(h.http_response(req, r)) self.assertEqual(o.proto, "http") # o.error called self.assertEqual(o.args, (req, r, 502, "Bad gateway", {})) @@ -873,12 +873,14 @@ class HandlerTests(unittest.TestCase): req = Request("http://example.com/") r = MockResponse(200, "OK", {}, "") newreq = h.http_request(req) - self.assertTrue(cj.ach_req is req is newreq) - self.assertEquals(req.get_origin_req_host(), "example.com") - self.assertTrue(not req.is_unverifiable()) + self.assertIs(cj.ach_req, req) + self.assertIs(cj.ach_req, newreq) + self.assertEqual(req.get_origin_req_host(), "example.com") + self.assertFalse(req.is_unverifiable()) newr = h.http_response(req, r) - self.assertTrue(cj.ec_req is req) - self.assertTrue(cj.ec_r is r is newr) + self.assertIs(cj.ec_req, req) + self.assertIs(cj.ec_r, r) + self.assertIs(r, newr) def test_redirect(self): from_url = "http://example.com/a.html" @@ -906,7 +908,7 @@ class HandlerTests(unittest.TestCase): try: self.assertEqual(o.req.get_method(), "GET") except AttributeError: - self.assertTrue(not o.req.has_data()) + self.assertFalse(o.req.has_data()) # now it's a GET, there should not be headers regarding content # (possibly dragged from before being a POST) @@ -965,7 +967,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.assertTrue(not hh.req.has_header("Cookie")) + self.assertFalse(hh.req.has_header("Cookie")) def test_proxy(self): o = OpenerDirector() @@ -1199,11 +1201,8 @@ class MiscTests(unittest.TestCase): self.opener_has_handler(o, MyOtherHTTPHandler) def opener_has_handler(self, opener, handler_class): - for h in opener.handlers: - if h.__class__ == handler_class: - break - else: - self.assertTrue(False) + self.assertTrue(any(h.__class__ == handler_class + for h in opener.handlers)) class RequestTests(unittest.TestCase): @@ -1218,7 +1217,7 @@ class RequestTests(unittest.TestCase): self.assertEqual("GET", self.get.get_method()) def test_add_data(self): - self.assertTrue(not self.get.has_data()) + self.assertFalse(self.get.has_data()) self.assertEqual("GET", self.get.get_method()) self.get.add_data("spam") self.assertTrue(self.get.has_data()) @@ -1244,7 +1243,7 @@ class RequestTests(unittest.TestCase): self.assertEqual("www.python.org", req.get_host()) def test_proxy(self): - self.assertTrue(not self.get.has_proxy()) + self.assertFalse(self.get.has_proxy()) self.get.set_proxy("www.perl.org", "http") self.assertTrue(self.get.has_proxy()) self.assertEqual("www.python.org", self.get.get_origin_req_host()) |