Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
77ebfccd
Kaydet (Commit)
77ebfccd
authored
Agu 20, 2012
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue 15743 - improve urllib tests by removing deprecated method usages. Patch by Jeff Knupp.
üst
df9c9450
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
31 deletions
+36
-31
test_urllib2.py
Lib/test/test_urllib2.py
+33
-31
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_urllib2.py
Dosyayı görüntüle @
77ebfccd
...
@@ -621,10 +621,10 @@ class OpenerDirectorTests(unittest.TestCase):
...
@@ -621,10 +621,10 @@ class OpenerDirectorTests(unittest.TestCase):
with
self
.
assertWarns
(
DeprecationWarning
):
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
add_data
(
"data"
)
req
.
add_data
(
"data"
)
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
has_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_data
()
req
.
get_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
has_data
()
with
self
.
assertWarns
(
DeprecationWarning
):
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_host
()
req
.
get_host
()
with
self
.
assertWarns
(
DeprecationWarning
):
with
self
.
assertWarns
(
DeprecationWarning
):
...
@@ -633,6 +633,8 @@ class OpenerDirectorTests(unittest.TestCase):
...
@@ -633,6 +633,8 @@ class OpenerDirectorTests(unittest.TestCase):
req
.
is_unverifiable
()
req
.
is_unverifiable
()
with
self
.
assertWarns
(
DeprecationWarning
):
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_origin_req_host
()
req
.
get_origin_req_host
()
with
self
.
assertWarns
(
DeprecationWarning
):
req
.
get_type
()
def
sanepathname2url
(
path
):
def
sanepathname2url
(
path
):
...
@@ -989,8 +991,8 @@ class HandlerTests(unittest.TestCase):
...
@@ -989,8 +991,8 @@ class HandlerTests(unittest.TestCase):
newreq
=
h
.
http_request
(
req
)
newreq
=
h
.
http_request
(
req
)
self
.
assertIs
(
cj
.
ach_req
,
req
)
self
.
assertIs
(
cj
.
ach_req
,
req
)
self
.
assertIs
(
cj
.
ach_req
,
newreq
)
self
.
assertIs
(
cj
.
ach_req
,
newreq
)
self
.
assertEqual
(
req
.
get_origin_req_host
()
,
"example.com"
)
self
.
assertEqual
(
req
.
origin_req_host
,
"example.com"
)
self
.
assertFalse
(
req
.
is_unverifiable
()
)
self
.
assertFalse
(
req
.
unverifiable
)
newr
=
h
.
http_response
(
req
,
r
)
newr
=
h
.
http_response
(
req
,
r
)
self
.
assertIs
(
cj
.
ec_req
,
req
)
self
.
assertIs
(
cj
.
ec_req
,
req
)
self
.
assertIs
(
cj
.
ec_r
,
r
)
self
.
assertIs
(
cj
.
ec_r
,
r
)
...
@@ -1022,7 +1024,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -1022,7 +1024,7 @@ class HandlerTests(unittest.TestCase):
try
:
try
:
self
.
assertEqual
(
o
.
req
.
get_method
(),
"GET"
)
self
.
assertEqual
(
o
.
req
.
get_method
(),
"GET"
)
except
AttributeError
:
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
# now it's a GET, there should not be headers regarding content
# (possibly dragged from before being a POST)
# (possibly dragged from before being a POST)
...
@@ -1138,9 +1140,9 @@ class HandlerTests(unittest.TestCase):
...
@@ -1138,9 +1140,9 @@ class HandlerTests(unittest.TestCase):
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
req
=
Request
(
"http://acme.example.com/"
)
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
)
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"
)],
self
.
assertEqual
([(
handlers
[
0
],
"http_open"
)],
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
...
@@ -1151,13 +1153,13 @@ class HandlerTests(unittest.TestCase):
...
@@ -1151,13 +1153,13 @@ class HandlerTests(unittest.TestCase):
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
o
.
add_handler
(
ph
)
o
.
add_handler
(
ph
)
req
=
Request
(
"http://www.perl.org/"
)
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
)
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"
)
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
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
del
os
.
environ
[
'no_proxy'
]
del
os
.
environ
[
'no_proxy'
]
def
test_proxy_no_proxy_all
(
self
):
def
test_proxy_no_proxy_all
(
self
):
...
@@ -1166,9 +1168,9 @@ class HandlerTests(unittest.TestCase):
...
@@ -1166,9 +1168,9 @@ class HandlerTests(unittest.TestCase):
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
ph
=
urllib
.
request
.
ProxyHandler
(
dict
(
http
=
"proxy.example.com"
))
o
.
add_handler
(
ph
)
o
.
add_handler
(
ph
)
req
=
Request
(
"http://www.python.org"
)
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
)
r
=
o
.
open
(
req
)
self
.
assertEqual
(
req
.
get_host
()
,
"www.python.org"
)
self
.
assertEqual
(
req
.
host
,
"www.python.org"
)
del
os
.
environ
[
'no_proxy'
]
del
os
.
environ
[
'no_proxy'
]
...
@@ -1182,9 +1184,9 @@ class HandlerTests(unittest.TestCase):
...
@@ -1182,9 +1184,9 @@ class HandlerTests(unittest.TestCase):
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
handlers
=
add_ordered_mock_handlers
(
o
,
meth_spec
)
req
=
Request
(
"https://www.example.com/"
)
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
)
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"
)],
self
.
assertEqual
([(
handlers
[
0
],
"https_open"
)],
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
[
tup
[
0
:
2
]
for
tup
in
o
.
calls
])
...
@@ -1197,7 +1199,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -1197,7 +1199,7 @@ class HandlerTests(unittest.TestCase):
req
=
Request
(
"https://www.example.com/"
)
req
=
Request
(
"https://www.example.com/"
)
req
.
add_header
(
"Proxy-Authorization"
,
"FooBar"
)
req
.
add_header
(
"Proxy-Authorization"
,
"FooBar"
)
req
.
add_header
(
"User-Agent"
,
"Grail"
)
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
)
self
.
assertIsNone
(
req
.
_tunnel_host
)
r
=
o
.
open
(
req
)
r
=
o
.
open
(
req
)
# Verify Proxy-Authorization gets tunneled to request.
# Verify Proxy-Authorization gets tunneled to request.
...
@@ -1208,7 +1210,7 @@ class HandlerTests(unittest.TestCase):
...
@@ -1208,7 +1210,7 @@ class HandlerTests(unittest.TestCase):
self
.
assertIn
((
"User-Agent"
,
"Grail"
),
self
.
assertIn
((
"User-Agent"
,
"Grail"
),
https_handler
.
httpconn
.
req_headers
)
https_handler
.
httpconn
.
req_headers
)
self
.
assertIsNotNone
(
req
.
_tunnel_host
)
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"
)
self
.
assertEqual
(
req
.
get_header
(
"Proxy-authorization"
),
"FooBar"
)
# TODO: This should be only for OSX
# TODO: This should be only for OSX
...
@@ -1445,11 +1447,11 @@ class RequestTests(unittest.TestCase):
...
@@ -1445,11 +1447,11 @@ class RequestTests(unittest.TestCase):
self
.
assertEqual
(
"POST"
,
self
.
post
.
get_method
())
self
.
assertEqual
(
"POST"
,
self
.
post
.
get_method
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
def
test_
add_
data
(
self
):
def
test_data
(
self
):
self
.
assertFalse
(
self
.
get
.
has_data
()
)
self
.
assertFalse
(
self
.
get
.
data
)
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
self
.
get
.
add_data
(
"spam"
)
self
.
get
.
data
=
"spam"
self
.
assertTrue
(
self
.
get
.
has_data
()
)
self
.
assertTrue
(
self
.
get
.
data
)
self
.
assertEqual
(
"POST"
,
self
.
get
.
get_method
())
self
.
assertEqual
(
"POST"
,
self
.
get
.
get_method
())
def
test_get_full_url
(
self
):
def
test_get_full_url
(
self
):
...
@@ -1457,36 +1459,36 @@ class RequestTests(unittest.TestCase):
...
@@ -1457,36 +1459,36 @@ class RequestTests(unittest.TestCase):
self
.
get
.
get_full_url
())
self
.
get
.
get_full_url
())
def
test_selector
(
self
):
def
test_selector
(
self
):
self
.
assertEqual
(
"/~jeremy/"
,
self
.
get
.
get_selector
()
)
self
.
assertEqual
(
"/~jeremy/"
,
self
.
get
.
selector
)
req
=
Request
(
"http://www.python.org/"
)
req
=
Request
(
"http://www.python.org/"
)
self
.
assertEqual
(
"/"
,
req
.
get_selector
()
)
self
.
assertEqual
(
"/"
,
req
.
selector
)
def
test_get_type
(
self
):
def
test_get_type
(
self
):
self
.
assertEqual
(
"http"
,
self
.
get
.
get_type
()
)
self
.
assertEqual
(
"http"
,
self
.
get
.
type
)
def
test_get_host
(
self
):
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
):
def
test_get_host_unquote
(
self
):
req
=
Request
(
"http://www.
%70
ython.org/"
)
req
=
Request
(
"http://www.
%70
ython.org/"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
()
)
self
.
assertEqual
(
"www.python.org"
,
req
.
host
)
def
test_proxy
(
self
):
def
test_proxy
(
self
):
self
.
assertFalse
(
self
.
get
.
has_proxy
())
self
.
assertFalse
(
self
.
get
.
has_proxy
())
self
.
get
.
set_proxy
(
"www.perl.org"
,
"http"
)
self
.
get
.
set_proxy
(
"www.perl.org"
,
"http"
)
self
.
assertTrue
(
self
.
get
.
has_proxy
())
self
.
assertTrue
(
self
.
get
.
has_proxy
())
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
get_origin_req_host
()
)
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
origin_req_host
)
self
.
assertEqual
(
"www.perl.org"
,
self
.
get
.
get_host
()
)
self
.
assertEqual
(
"www.perl.org"
,
self
.
get
.
host
)
def
test_wrapped_url
(
self
):
def
test_wrapped_url
(
self
):
req
=
Request
(
"<URL:http://www.python.org>"
)
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
):
def
test_url_fragment
(
self
):
req
=
Request
(
"http://www.python.org/?qs=query#fragment=true"
)
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"
)
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.
# Issue 11703: geturl() omits fragment in the original URL.
url
=
'http://docs.python.org/library/urllib2.html#OK'
url
=
'http://docs.python.org/library/urllib2.html#OK'
...
...
Misc/NEWS
Dosyayı görüntüle @
77ebfccd
...
@@ -86,6 +86,9 @@ Documentation
...
@@ -86,6 +86,9 @@ Documentation
Tests
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
- Issue #15615: Add some tests for the json module'
s
handling
of
invalid
input
data
.
Patch
by
Kushal
Das
.
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