diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2011-11-07 15:50:32 (GMT) |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2011-11-07 15:50:32 (GMT) |
commit | aa204dbe9c83302781f7b9d7df6db225b3661f9e (patch) | |
tree | 4414eab7cde62cafdb8b833c0c4ab5e45a7697ee /Lib/test | |
parent | a90e364ea5c301e76e67e23e2162f4fa8066a6f3 (diff) | |
download | cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.zip cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.tar.gz cpython-aa204dbe9c83302781f7b9d7df6db225b3661f9e.tar.bz2 |
Issue #13211: Add .reason attribute to HTTPError to implement parent class (URLError) interface.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_urllib2.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 83bb0a9..c94ebf8 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1409,6 +1409,17 @@ class RequestTests(unittest.TestCase): req = Request(url) self.assertEqual(req.get_full_url(), url) +def test_HTTPError_interface(): + """ + 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) + >>> assert hasattr(err, 'reason') + >>> err.reason + 'something bad happened' + """ + def test_main(verbose=None): from test import test_urllib2 support.run_doctest(test_urllib2, verbose) |