]> granicus.if.org Git - python/commitdiff
#17471 - Increasing the urllib.error test coverage. Bringing it to 100%. Based on...
authorSenthil Kumaran <senthil@uthcode.com>
Tue, 19 Mar 2013 23:11:07 +0000 (16:11 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Tue, 19 Mar 2013 23:11:07 +0000 (16:11 -0700)
Lib/test/test_urllib2.py

index a9776ac8571d7f5b0cd02a8c48f6b63decb508cc..70fbb64f558bf4ed4687da356bfab4dfede6ed3c 100644 (file)
@@ -1446,10 +1446,18 @@ class RequestTests(unittest.TestCase):
         Issue 13211 reveals that HTTPError didn't implement the URLError
         interface even though HTTPError is a subclass of URLError.
 
-        >>> err = urllib.error.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None)
+        >>> msg = 'something bad happened'
+        >>> url = code = fp = None
+        >>> hdrs = 'Content-Length: 42'
+        >>> err = urllib.error.HTTPError(url, code, msg, hdrs, fp)
         >>> assert hasattr(err, 'reason')
         >>> err.reason
         'something bad happened'
+        >>> assert hasattr(err, 'hdrs')
+        >>> err.hdrs
+        'Content-Length: 42'
+        >>> expected_errmsg = 'HTTP Error %s: %s' % (err.code, err.msg)
+        >>> assert str(err) == expected_errmsg
         """
 
     def test_HTTPError_interface_call(self):