diff options
author | Benjamin Peterson <benjamin@python.org> | 2013-01-01 03:40:42 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2013-01-01 03:40:42 (GMT) |
commit | 1f7df8f2070391f28391e3594580c07e11b6b32b (patch) | |
tree | ec03dfe4f71df3840232731145b8f6736fc6a314 /Lib/test/test_urllib2.py | |
parent | b25d611f8d9140e83acbfffb6b0579939c88c033 (diff) | |
parent | 10e93a6d40502e100c68090730e0b3190df97854 (diff) | |
download | cpython-1f7df8f2070391f28391e3594580c07e11b6b32b.zip cpython-1f7df8f2070391f28391e3594580c07e11b6b32b.tar.gz cpython-1f7df8f2070391f28391e3594580c07e11b6b32b.tar.bz2 |
merge heads
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r-- | Lib/test/test_urllib2.py | 36 |
1 files changed, 26 insertions, 10 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 12263b3..eac9950 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1336,16 +1336,32 @@ 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 = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) - >>> assert hasattr(err, 'reason') - >>> err.reason - 'something bad happened' - """ + def test_HTTPError_interface(self): + """ + Issue 13211 reveals that HTTPError didn't implement the URLError + interface even though HTTPError is a subclass of URLError. + + >>> err = urllib2.HTTPError(msg='something bad happened', url=None, code=None, hdrs=None, fp=None) + >>> assert hasattr(err, 'reason') + >>> err.reason + 'something bad happened' + """ + + def test_HTTPError_interface_call(self): + """ + Issue 15701= - HTTPError interface has info method available from URLError. + """ + err = urllib2.HTTPError(msg='something bad happened', url=None, + code=None, hdrs='Content-Length:42', fp=None) + self.assertTrue(hasattr(err, 'reason')) + assert hasattr(err, 'reason') + assert hasattr(err, 'info') + assert callable(err.info) + try: + err.info() + except AttributeError: + self.fail("err.info() failed") + self.assertEqual(err.info(), "Content-Length:42") def test_main(verbose=None): from test import test_urllib2 |