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
25d8aeac
Kaydet (Commit)
25d8aeac
authored
Şub 08, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #20555: Use specific asserts in urllib, httplib, ftplib, cgi, wsgiref tests.
üst
3a20a5de
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
26 deletions
+27
-26
test_cgi.py
Lib/test/test_cgi.py
+1
-1
test_ftplib.py
Lib/test/test_ftplib.py
+3
-3
test_httplib.py
Lib/test/test_httplib.py
+3
-3
test_httpservers.py
Lib/test/test_httpservers.py
+1
-1
test_urllib.py
Lib/test/test_urllib.py
+2
-2
test_urllib2.py
Lib/test/test_urllib2.py
+4
-3
test_urllib2net.py
Lib/test/test_urllib2net.py
+11
-11
test_wsgiref.py
Lib/test/test_wsgiref.py
+2
-2
No files found.
Lib/test/test_cgi.py
Dosyayı görüntüle @
25d8aeac
...
@@ -227,7 +227,7 @@ class CgiTests(unittest.TestCase):
...
@@ -227,7 +227,7 @@ class CgiTests(unittest.TestCase):
# if we're not chunking properly, readline is only called twice
# if we're not chunking properly, readline is only called twice
# (by read_binary); if we are chunking properly, it will be called 5 times
# (by read_binary); if we are chunking properly, it will be called 5 times
# as long as the chunksize is 1 << 16.
# as long as the chunksize is 1 << 16.
self
.
assert
True
(
f
.
numcalls
>
2
)
self
.
assert
Greater
(
f
.
numcalls
,
2
)
f
.
close
()
f
.
close
()
def
test_fieldstorage_multipart
(
self
):
def
test_fieldstorage_multipart
(
self
):
...
...
Lib/test/test_ftplib.py
Dosyayı görüntüle @
25d8aeac
...
@@ -965,7 +965,7 @@ class TestTimeouts(TestCase):
...
@@ -965,7 +965,7 @@ class TestTimeouts(TestCase):
def
testTimeoutDefault
(
self
):
def
testTimeoutDefault
(
self
):
# default -- use global socket timeout
# default -- use global socket timeout
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
socket
.
setdefaulttimeout
(
30
)
socket
.
setdefaulttimeout
(
30
)
try
:
try
:
ftp
=
ftplib
.
FTP
(
HOST
)
ftp
=
ftplib
.
FTP
(
HOST
)
...
@@ -977,13 +977,13 @@ class TestTimeouts(TestCase):
...
@@ -977,13 +977,13 @@ class TestTimeouts(TestCase):
def
testTimeoutNone
(
self
):
def
testTimeoutNone
(
self
):
# no timeout -- do not use global socket timeout
# no timeout -- do not use global socket timeout
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
socket
.
setdefaulttimeout
(
30
)
socket
.
setdefaulttimeout
(
30
)
try
:
try
:
ftp
=
ftplib
.
FTP
(
HOST
,
timeout
=
None
)
ftp
=
ftplib
.
FTP
(
HOST
,
timeout
=
None
)
finally
:
finally
:
socket
.
setdefaulttimeout
(
None
)
socket
.
setdefaulttimeout
(
None
)
self
.
assert
True
(
ftp
.
sock
.
gettimeout
()
is
None
)
self
.
assert
IsNone
(
ftp
.
sock
.
gettimeout
()
)
self
.
evt
.
wait
()
self
.
evt
.
wait
()
ftp
.
close
()
ftp
.
close
()
...
...
Lib/test/test_httplib.py
Dosyayı görüntüle @
25d8aeac
...
@@ -132,7 +132,7 @@ class HeaderTests(TestCase):
...
@@ -132,7 +132,7 @@ class HeaderTests(TestCase):
conn
.
sock
=
FakeSocket
(
None
)
conn
.
sock
=
FakeSocket
(
None
)
conn
.
putrequest
(
'GET'
,
'/'
)
conn
.
putrequest
(
'GET'
,
'/'
)
conn
.
putheader
(
'Content-length'
,
42
)
conn
.
putheader
(
'Content-length'
,
42
)
self
.
assert
True
(
b
'Content-length: 42'
in
conn
.
_buffer
)
self
.
assert
In
(
b
'Content-length: 42'
,
conn
.
_buffer
)
def
test_ipv6host_header
(
self
):
def
test_ipv6host_header
(
self
):
# Default host header on IPv6 transaction should wrapped by [] if
# Default host header on IPv6 transaction should wrapped by [] if
...
@@ -699,7 +699,7 @@ class TimeoutTest(TestCase):
...
@@ -699,7 +699,7 @@ class TimeoutTest(TestCase):
# and into the socket.
# and into the socket.
# default -- use global socket timeout
# default -- use global socket timeout
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
socket
.
setdefaulttimeout
(
30
)
socket
.
setdefaulttimeout
(
30
)
try
:
try
:
httpConn
=
client
.
HTTPConnection
(
HOST
,
TimeoutTest
.
PORT
)
httpConn
=
client
.
HTTPConnection
(
HOST
,
TimeoutTest
.
PORT
)
...
@@ -710,7 +710,7 @@ class TimeoutTest(TestCase):
...
@@ -710,7 +710,7 @@ class TimeoutTest(TestCase):
httpConn
.
close
()
httpConn
.
close
()
# no timeout -- do not use global socket default
# no timeout -- do not use global socket default
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
socket
.
setdefaulttimeout
(
30
)
socket
.
setdefaulttimeout
(
30
)
try
:
try
:
httpConn
=
client
.
HTTPConnection
(
HOST
,
TimeoutTest
.
PORT
,
httpConn
=
client
.
HTTPConnection
(
HOST
,
TimeoutTest
.
PORT
,
...
...
Lib/test/test_httpservers.py
Dosyayı görüntüle @
25d8aeac
...
@@ -531,7 +531,7 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
...
@@ -531,7 +531,7 @@ class BaseHTTPRequestHandlerTestCase(unittest.TestCase):
def
verify_http_server_response
(
self
,
response
):
def
verify_http_server_response
(
self
,
response
):
match
=
self
.
HTTPResponseMatch
.
search
(
response
)
match
=
self
.
HTTPResponseMatch
.
search
(
response
)
self
.
assert
True
(
match
is
not
None
)
self
.
assert
IsNotNone
(
match
)
def
test_http_1_1
(
self
):
def
test_http_1_1
(
self
):
result
=
self
.
send_typical_request
(
b
'GET / HTTP/1.1
\r\n\r\n
'
)
result
=
self
.
send_typical_request
(
b
'GET / HTTP/1.1
\r\n\r\n
'
)
...
...
Lib/test/test_urllib.py
Dosyayı görüntüle @
25d8aeac
...
@@ -1264,7 +1264,7 @@ class URLopener_Tests(unittest.TestCase):
...
@@ -1264,7 +1264,7 @@ class URLopener_Tests(unittest.TestCase):
# def testTimeoutNone(self):
# def testTimeoutNone(self):
# # global default timeout is ignored
# # global default timeout is ignored
# import socket
# import socket
# self.assert
True(socket.getdefaulttimeout() is None
)
# self.assert
IsNone(socket.getdefaulttimeout()
)
# socket.setdefaulttimeout(30)
# socket.setdefaulttimeout(30)
# try:
# try:
# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [])
# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [])
...
@@ -1276,7 +1276,7 @@ class URLopener_Tests(unittest.TestCase):
...
@@ -1276,7 +1276,7 @@ class URLopener_Tests(unittest.TestCase):
# def testTimeoutDefault(self):
# def testTimeoutDefault(self):
# # global default timeout is used
# # global default timeout is used
# import socket
# import socket
# self.assert
True(socket.getdefaulttimeout() is None
)
# self.assert
IsNone(socket.getdefaulttimeout()
)
# socket.setdefaulttimeout(30)
# socket.setdefaulttimeout(30)
# try:
# try:
# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [])
# ftp = urllib.ftpwrapper("myuser", "mypass", "localhost", 9093, [])
...
...
Lib/test/test_urllib2.py
Dosyayı görüntüle @
25d8aeac
...
@@ -594,8 +594,8 @@ class OpenerDirectorTests(unittest.TestCase):
...
@@ -594,8 +594,8 @@ class OpenerDirectorTests(unittest.TestCase):
self
.
assertIsInstance
(
args
[
0
],
Request
)
self
.
assertIsInstance
(
args
[
0
],
Request
)
# response from opener.open is None, because there's no
# response from opener.open is None, because there's no
# handler that defines http_open to handle it
# handler that defines http_open to handle it
self
.
assertTrue
(
args
[
1
]
is
None
or
if
args
[
1
]
is
not
None
:
isinstance
(
args
[
1
],
MockResponse
)
)
self
.
assertIsInstance
(
args
[
1
],
MockResponse
)
def
test_method_deprecations
(
self
):
def
test_method_deprecations
(
self
):
req
=
Request
(
"http://www.example.com"
)
req
=
Request
(
"http://www.example.com"
)
...
@@ -1000,7 +1000,8 @@ class HandlerTests(unittest.TestCase):
...
@@ -1000,7 +1000,8 @@ class HandlerTests(unittest.TestCase):
MockHeaders
({
"location"
:
to_url
}))
MockHeaders
({
"location"
:
to_url
}))
except
urllib
.
error
.
HTTPError
:
except
urllib
.
error
.
HTTPError
:
# 307 in response to POST requires user OK
# 307 in response to POST requires user OK
self
.
assertTrue
(
code
==
307
and
data
is
not
None
)
self
.
assertEqual
(
code
,
307
)
self
.
assertIsNotNone
(
data
)
self
.
assertEqual
(
o
.
req
.
get_full_url
(),
to_url
)
self
.
assertEqual
(
o
.
req
.
get_full_url
(),
to_url
)
try
:
try
:
self
.
assertEqual
(
o
.
req
.
get_method
(),
"GET"
)
self
.
assertEqual
(
o
.
req
.
get_method
(),
"GET"
)
...
...
Lib/test/test_urllib2net.py
Dosyayı görüntüle @
25d8aeac
...
@@ -85,7 +85,7 @@ class CloseSocketTest(unittest.TestCase):
...
@@ -85,7 +85,7 @@ class CloseSocketTest(unittest.TestCase):
with
support
.
transient_internet
(
url
):
with
support
.
transient_internet
(
url
):
response
=
_urlopen_with_retry
(
url
)
response
=
_urlopen_with_retry
(
url
)
sock
=
response
.
fp
sock
=
response
.
fp
self
.
assert
True
(
not
sock
.
closed
)
self
.
assert
False
(
sock
.
closed
)
response
.
close
()
response
.
close
()
self
.
assertTrue
(
sock
.
closed
)
self
.
assertTrue
(
sock
.
closed
)
...
@@ -252,15 +252,15 @@ class OtherNetworkTests(unittest.TestCase):
...
@@ -252,15 +252,15 @@ class OtherNetworkTests(unittest.TestCase):
class
TimeoutTest
(
unittest
.
TestCase
):
class
TimeoutTest
(
unittest
.
TestCase
):
def
test_http_basic
(
self
):
def
test_http_basic
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
url
=
"http://www.python.org"
url
=
"http://www.python.org"
with
support
.
transient_internet
(
url
,
timeout
=
None
):
with
support
.
transient_internet
(
url
,
timeout
=
None
):
u
=
_urlopen_with_retry
(
url
)
u
=
_urlopen_with_retry
(
url
)
self
.
addCleanup
(
u
.
close
)
self
.
addCleanup
(
u
.
close
)
self
.
assert
True
(
u
.
fp
.
raw
.
_sock
.
gettimeout
()
is
None
)
self
.
assert
IsNone
(
u
.
fp
.
raw
.
_sock
.
gettimeout
()
)
def
test_http_default_timeout
(
self
):
def
test_http_default_timeout
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
url
=
"http://www.python.org"
url
=
"http://www.python.org"
with
support
.
transient_internet
(
url
):
with
support
.
transient_internet
(
url
):
socket
.
setdefaulttimeout
(
60
)
socket
.
setdefaulttimeout
(
60
)
...
@@ -272,7 +272,7 @@ class TimeoutTest(unittest.TestCase):
...
@@ -272,7 +272,7 @@ class TimeoutTest(unittest.TestCase):
self
.
assertEqual
(
u
.
fp
.
raw
.
_sock
.
gettimeout
(),
60
)
self
.
assertEqual
(
u
.
fp
.
raw
.
_sock
.
gettimeout
(),
60
)
def
test_http_no_timeout
(
self
):
def
test_http_no_timeout
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
url
=
"http://www.python.org"
url
=
"http://www.python.org"
with
support
.
transient_internet
(
url
):
with
support
.
transient_internet
(
url
):
socket
.
setdefaulttimeout
(
60
)
socket
.
setdefaulttimeout
(
60
)
...
@@ -281,7 +281,7 @@ class TimeoutTest(unittest.TestCase):
...
@@ -281,7 +281,7 @@ class TimeoutTest(unittest.TestCase):
self
.
addCleanup
(
u
.
close
)
self
.
addCleanup
(
u
.
close
)
finally
:
finally
:
socket
.
setdefaulttimeout
(
None
)
socket
.
setdefaulttimeout
(
None
)
self
.
assert
True
(
u
.
fp
.
raw
.
_sock
.
gettimeout
()
is
None
)
self
.
assert
IsNone
(
u
.
fp
.
raw
.
_sock
.
gettimeout
()
)
def
test_http_timeout
(
self
):
def
test_http_timeout
(
self
):
url
=
"http://www.python.org"
url
=
"http://www.python.org"
...
@@ -293,14 +293,14 @@ class TimeoutTest(unittest.TestCase):
...
@@ -293,14 +293,14 @@ class TimeoutTest(unittest.TestCase):
FTP_HOST
=
"ftp://ftp.mirror.nl/pub/gnu/"
FTP_HOST
=
"ftp://ftp.mirror.nl/pub/gnu/"
def
test_ftp_basic
(
self
):
def
test_ftp_basic
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
with
support
.
transient_internet
(
self
.
FTP_HOST
,
timeout
=
None
):
with
support
.
transient_internet
(
self
.
FTP_HOST
,
timeout
=
None
):
u
=
_urlopen_with_retry
(
self
.
FTP_HOST
)
u
=
_urlopen_with_retry
(
self
.
FTP_HOST
)
self
.
addCleanup
(
u
.
close
)
self
.
addCleanup
(
u
.
close
)
self
.
assert
True
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
()
is
None
)
self
.
assert
IsNone
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
()
)
def
test_ftp_default_timeout
(
self
):
def
test_ftp_default_timeout
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
with
support
.
transient_internet
(
self
.
FTP_HOST
):
with
support
.
transient_internet
(
self
.
FTP_HOST
):
socket
.
setdefaulttimeout
(
60
)
socket
.
setdefaulttimeout
(
60
)
try
:
try
:
...
@@ -311,7 +311,7 @@ class TimeoutTest(unittest.TestCase):
...
@@ -311,7 +311,7 @@ class TimeoutTest(unittest.TestCase):
self
.
assertEqual
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
(),
60
)
self
.
assertEqual
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
(),
60
)
def
test_ftp_no_timeout
(
self
):
def
test_ftp_no_timeout
(
self
):
self
.
assert
True
(
socket
.
getdefaulttimeout
()
is
None
)
self
.
assert
IsNone
(
socket
.
getdefaulttimeout
()
)
with
support
.
transient_internet
(
self
.
FTP_HOST
):
with
support
.
transient_internet
(
self
.
FTP_HOST
):
socket
.
setdefaulttimeout
(
60
)
socket
.
setdefaulttimeout
(
60
)
try
:
try
:
...
@@ -319,7 +319,7 @@ class TimeoutTest(unittest.TestCase):
...
@@ -319,7 +319,7 @@ class TimeoutTest(unittest.TestCase):
self
.
addCleanup
(
u
.
close
)
self
.
addCleanup
(
u
.
close
)
finally
:
finally
:
socket
.
setdefaulttimeout
(
None
)
socket
.
setdefaulttimeout
(
None
)
self
.
assert
True
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
()
is
None
)
self
.
assert
IsNone
(
u
.
fp
.
fp
.
raw
.
_sock
.
gettimeout
()
)
def
test_ftp_timeout
(
self
):
def
test_ftp_timeout
(
self
):
with
support
.
transient_internet
(
self
.
FTP_HOST
):
with
support
.
transient_internet
(
self
.
FTP_HOST
):
...
...
Lib/test/test_wsgiref.py
Dosyayı görüntüle @
25d8aeac
...
@@ -196,7 +196,7 @@ class UtilityTests(TestCase):
...
@@ -196,7 +196,7 @@ class UtilityTests(TestCase):
# Check existing value
# Check existing value
env
=
{
key
:
alt
}
env
=
{
key
:
alt
}
util
.
setup_testing_defaults
(
env
)
util
.
setup_testing_defaults
(
env
)
self
.
assert
True
(
env
[
key
]
is
alt
)
self
.
assert
Is
(
env
[
key
],
alt
)
def
checkCrossDefault
(
self
,
key
,
value
,
**
kw
):
def
checkCrossDefault
(
self
,
key
,
value
,
**
kw
):
util
.
setup_testing_defaults
(
kw
)
util
.
setup_testing_defaults
(
kw
)
...
@@ -343,7 +343,7 @@ class HeaderTests(TestCase):
...
@@ -343,7 +343,7 @@ class HeaderTests(TestCase):
self
.
assertEqual
(
Headers
(
test
[:])
.
keys
(),
[
'x'
])
self
.
assertEqual
(
Headers
(
test
[:])
.
keys
(),
[
'x'
])
self
.
assertEqual
(
Headers
(
test
[:])
.
values
(),
[
'y'
])
self
.
assertEqual
(
Headers
(
test
[:])
.
values
(),
[
'y'
])
self
.
assertEqual
(
Headers
(
test
[:])
.
items
(),
test
)
self
.
assertEqual
(
Headers
(
test
[:])
.
items
(),
test
)
self
.
assert
False
(
Headers
(
test
)
.
items
()
is
test
)
# must be copy!
self
.
assert
IsNot
(
Headers
(
test
)
.
items
(),
test
)
# must be copy!
h
=
Headers
([])
h
=
Headers
([])
del
h
[
'foo'
]
# should not raise an error
del
h
[
'foo'
]
# should not raise an error
...
...
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