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
77ebfccd
Commit
77ebfccd
authored
Aug 20, 2012
by
Senthil Kumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Issue 15743 - improve urllib tests by removing deprecated method usages. Patch by Jeff Knupp.
parent
df9c9450
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
31 deletions
+36
-31
Lib/test/test_urllib2.py
Lib/test/test_urllib2.py
+33
-31
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
View file @
77ebfccd
...
...
@@ -621,10 +621,10 @@ class OpenerDirectorTests(unittest.TestCase):
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
add_data
(
"data"
)
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
has_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
has_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_host
()
with
self
.
assertWarns
(
DeprecationWarning
):
...
...
@@ -633,6 +633,8 @@ class OpenerDirectorTests(unittest.TestCase):
req
.
is_unverifiable
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_origin_req_host
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_type
()
def
sanepathname2url
(
path
):
...
...
@@ -989,8 +991,8 @@ class HandlerTests(unittest.TestCase):
newreq
=
h
.
http_request
(
req
)
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
()
)
self
.
assertEqual
(
req
.
origin_req_host
,
"example.com"
)
self
.
assertFalse
(
req
.
unverifiable
)
newr
=
h
.
http_response
(
req
,
r
)
self
.
assertIs
(
cj
.
ec_req
,
req
)
self
.
assertIs
(
cj
.
ec_r
,
r
)
...
...
@@ -1022,7 +1024,7 @@ class HandlerTests(unittest.TestCase):
try
:
self
.
assertEqual
(
o
.
req
.
get_method
(),
"GET"
)
except
AttributeError
:
self
.
assertFalse
(
o
.
req
.
has_data
()
)
self
.
assertFalse
(
o
.
req
.
data
)
# now it's a GET, there should not be headers regarding content
# (possibly dragged from before being a POST)
...
...
@@ -1138,9 +1140,9 @@ class HandlerTests(unittest.TestCase):
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
req
=
Request
(
"http://acme.example.com/"
)
self
.
assertEqual
(
req
.
get_host
()
,
"acme.example.com"
)
self
.
assertEqual
(
req
.
host
,
"acme.example.com"
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"proxy.example.com:3128"
)
self
.
assertEqual
(
req
.
host
,
"proxy.example.com:3128"
)
self
.
assertEqual
([(
handlers
[
0
],
"http_open"
)],
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
...
...
@@ -1151,13 +1153,13 @@ class HandlerTests(unittest.TestCase):
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
o
.
add_handler
(
ph
)
req
=
Request
(
"http://www.perl.org/"
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.perl.org"
)
self
.
assertEqual
(
req
.
host
,
"www.perl.org"
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"proxy.example.com"
)
self
.
assertEqual
(
req
.
host
,
"proxy.example.com"
)
req
=
Request
(
"http://www.python.org"
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
del
os
.
environ
[
'no_proxy'
]
def
test_proxy_no_proxy_all
(
self
):
...
...
@@ -1166,9 +1168,9 @@ class HandlerTests(unittest.TestCase):
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
o
.
add_handler
(
ph
)
req
=
Request
(
"http://www.python.org"
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
del
os
.
environ
[
'no_proxy'
]
...
...
@@ -1182,9 +1184,9 @@ class HandlerTests(unittest.TestCase):
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
req
=
Request
(
"https://www.example.com/"
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.example.com"
)
self
.
assertEqual
(
req
.
host
,
"www.example.com"
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"proxy.example.com:3128"
)
self
.
assertEqual
(
req
.
host
,
"proxy.example.com:3128"
)
self
.
assertEqual
([(
handlers
[
0
],
"https_open"
)],
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
...
...
@@ -1197,7 +1199,7 @@ class HandlerTests(unittest.TestCase):
req
=
Request
(
"https://www.example.com/"
)
req
.
add_header
(
"Proxy-Authorization"
,
"FooBar"
)
req
.
add_header
(
"User-Agent"
,
"Grail"
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.example.com"
)
self
.
assertEqual
(
req
.
host
,
"www.example.com"
)
self
.
assertIsNone
(
req
.
_tunnel_host
)
r
=
o
.
open
(
req
)
# Verify Proxy-Authorization gets tunneled to request.
...
...
@@ -1208,7 +1210,7 @@ class HandlerTests(unittest.TestCase):
self
.
assertIn
((
"User-Agent"
,
"Grail"
),
https_handler
.
httpconn
.
req_headers
)
self
.
assertIsNotNone
(
req
.
_tunnel_host
)
self
.
assertEqual
(
req
.
get_host
()
,
"proxy.example.com:3128"
)
self
.
assertEqual
(
req
.
host
,
"proxy.example.com:3128"
)
self
.
assertEqual
(
req
.
get_header
(
"Proxy-authorization"
),
"FooBar"
)
# TODO: This should be only for OSX
...
...
@@ -1445,11 +1447,11 @@ class RequestTests(unittest.TestCase):
self
.
assertEqual
(
"POST"
,
self
.
post
.
get_method
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
def
test_
add_
data
(
self
):
self
.
assertFalse
(
self
.
get
.
has_data
()
)
def
test_data
(
self
):
self
.
assertFalse
(
self
.
get
.
data
)
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
self
.
get
.
add_data
(
"spam"
)
self
.
assertTrue
(
self
.
get
.
has_data
()
)
self
.
get
.
data
=
"spam"
self
.
assertTrue
(
self
.
get
.
data
)
self
.
assertEqual
(
"POST"
,
self
.
get
.
get_method
())
def
test_get_full_url
(
self
):
...
...
@@ -1457,36 +1459,36 @@ class RequestTests(unittest.TestCase):
self
.
get
.
get_full_url
())
def
test_selector
(
self
):
self
.
assertEqual
(
"/~jeremy/"
,
self
.
get
.
get_selector
()
)
self
.
assertEqual
(
"/~jeremy/"
,
self
.
get
.
selector
)
req
=
Request
(
"http://www.python.org/"
)
self
.
assertEqual
(
"/"
,
req
.
get_selector
()
)
self
.
assertEqual
(
"/"
,
req
.
selector
)
def
test_get_type
(
self
):
self
.
assertEqual
(
"http"
,
self
.
get
.
get_type
()
)
self
.
assertEqual
(
"http"
,
self
.
get
.
type
)
def
test_get_host
(
self
):
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
get_host
()
)
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
host
)
def
test_get_host_unquote
(
self
):
req
=
Request
(
"http://www.%70ython.org/"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
()
)
self
.
assertEqual
(
"www.python.org"
,
req
.
host
)
def
test_proxy
(
self
):
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
()
)
self
.
assertEqual
(
"www.perl.org"
,
self
.
get
.
get_host
()
)
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
origin_req_host
)
self
.
assertEqual
(
"www.perl.org"
,
self
.
get
.
host
)
def
test_wrapped_url
(
self
):
req
=
Request
(
"<URL:http://www.python.org>"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
()
)
self
.
assertEqual
(
"www.python.org"
,
req
.
host
)
def
test_url_fragment
(
self
):
req
=
Request
(
"http://www.python.org/?qs=query#fragment=true"
)
self
.
assertEqual
(
"/?qs=query"
,
req
.
get_selector
()
)
self
.
assertEqual
(
"/?qs=query"
,
req
.
selector
)
req
=
Request
(
"http://www.python.org/#fun=true"
)
self
.
assertEqual
(
"/"
,
req
.
get_selector
()
)
self
.
assertEqual
(
"/"
,
req
.
selector
)
# Issue 11703: geturl() omits fragment in the original URL.
url
=
'http://docs.python.org/library/urllib2.html#OK'
...
...
Misc/NEWS
View file @
77ebfccd
...
...
@@ -86,6 +86,9 @@ Documentation
Tests
-----
- Issue #15743: Remove the deprecated method usage in urllib tests. Patch by
Jeff Knupp.
- Issue #15615: Add some tests for the json module'
s
handling
of
invalid
input
data
.
Patch
by
Kushal
Das
.
...
...
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