Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2480b089
Commit
2480b089
authored
Mar 19, 2013
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
../bug-fixes/http_error_interface/.hg/last-message.txt
parent
660e89b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
21 deletions
+20
-21
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+20
-21
No files found.
Lib/test/test_urllib2.py
View file @
2480b089
...
@@ -1387,6 +1387,10 @@ class HandlerTests(unittest.TestCase):
...
@@ -1387,6 +1387,10 @@ class HandlerTests(unittest.TestCase):
class
MiscTests
(
unittest
.
TestCase
):
class
MiscTests
(
unittest
.
TestCase
):
def
opener_has_handler
(
self
,
opener
,
handler_class
):
self
.
assertTrue
(
any
(
h
.
__class__
==
handler_class
for
h
in
opener
.
handlers
))
def
test_build_opener
(
self
):
def
test_build_opener
(
self
):
class
MyHTTPHandler
(
urllib
.
request
.
HTTPHandler
):
pass
class
MyHTTPHandler
(
urllib
.
request
.
HTTPHandler
):
pass
class
FooHandler
(
urllib
.
request
.
BaseHandler
):
class
FooHandler
(
urllib
.
request
.
BaseHandler
):
...
@@ -1439,10 +1443,22 @@ class MiscTests(unittest.TestCase):
...
@@ -1439,10 +1443,22 @@ class MiscTests(unittest.TestCase):
self
.
assertEqual
(
b"1234567890"
,
request
.
data
)
self
.
assertEqual
(
b"1234567890"
,
request
.
data
)
self
.
assertEqual
(
"10"
,
request
.
get_header
(
"Content-length"
))
self
.
assertEqual
(
"10"
,
request
.
get_header
(
"Content-length"
))
def
test_HTTPError_interface
(
self
):
"""
Issue 13211 reveals that HTTPError didn't implement the URLError
interface even though HTTPError is a subclass of URLError.
def
opener_has_handler
(
self
,
opener
,
handler_class
):
>>> msg = 'something bad happened'
self
.
assertTrue
(
any
(
h
.
__class__
==
handler_class
>>> url = code = fp = None
for
h
in
opener
.
handlers
))
>>> 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, 'headers')
>>> err.headers
'Content-Length: 42'
"""
class
RequestTests
(
unittest
.
TestCase
):
class
RequestTests
(
unittest
.
TestCase
):
...
@@ -1514,23 +1530,6 @@ class RequestTests(unittest.TestCase):
...
@@ -1514,23 +1530,6 @@ class RequestTests(unittest.TestCase):
req
=
Request
(
url
)
req
=
Request
(
url
)
self
.
assertEqual
(
req
.
get_full_url
(),
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.
>>> 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, 'headers')
>>> err.headers
'Content-Length: 42'
"""
def
test_main
(
verbose
=
None
):
def
test_main
(
verbose
=
None
):
from
test
import
test_urllib2
from
test
import
test_urllib2
support
.
run_doctest
(
test_urllib2
,
verbose
)
support
.
run_doctest
(
test_urllib2
,
verbose
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment