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
37d3d9aa
Kaydet (Commit)
37d3d9aa
authored
Agu 08, 2010
tarafından
Florent Xicluna
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add test case for the HTTPResponse being an iterable. Follow-up of issue #4608.
üst
e3f76168
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
test_urllib2_localnet.py
Lib/test/test_urllib2_localnet.py
+22
-2
No files found.
Lib/test/test_urllib2_localnet.py
Dosyayı görüntüle @
37d3d9aa
...
@@ -308,8 +308,9 @@ def GetRequestHandler(responses):
...
@@ -308,8 +308,9 @@ def GetRequestHandler(responses):
def
do_GET
(
self
):
def
do_GET
(
self
):
body
=
self
.
send_head
()
body
=
self
.
send_head
()
if
body
:
while
body
:
self
.
wfile
.
write
(
body
)
done
=
self
.
wfile
.
write
(
body
)
body
=
body
[
done
:]
def
do_POST
(
self
):
def
do_POST
(
self
):
content_length
=
self
.
headers
[
"Content-Length"
]
content_length
=
self
.
headers
[
"Content-Length"
]
...
@@ -501,6 +502,25 @@ class TestUrlopen(BaseTestCase):
...
@@ -501,6 +502,25 @@ class TestUrlopen(BaseTestCase):
urllib
.
request
.
urlopen
,
urllib
.
request
.
urlopen
,
"http://sadflkjsasf.i.nvali.d./"
)
"http://sadflkjsasf.i.nvali.d./"
)
def
test_iteration
(
self
):
expected_response
=
b
"pycon 2008..."
handler
=
self
.
start_server
([(
200
,
[],
expected_response
)])
data
=
urllib
.
request
.
urlopen
(
"http://localhost:
%
s"
%
handler
.
port
)
for
line
in
data
:
self
.
assertEqual
(
line
,
expected_response
)
def
test_line_iteration
(
self
):
lines
=
[
b
"We
\n
"
,
b
"got
\n
"
,
b
"here
\n
"
,
b
"verylong "
*
8192
+
b
"
\n
"
]
expected_response
=
b
""
.
join
(
lines
)
handler
=
self
.
start_server
([(
200
,
[],
expected_response
)])
data
=
urllib
.
request
.
urlopen
(
"http://localhost:
%
s"
%
handler
.
port
)
for
index
,
line
in
enumerate
(
data
):
self
.
assertEqual
(
line
,
lines
[
index
],
"Fetched line number
%
s doesn't match expected:
\n
"
" Expected length was
%
s, got
%
s"
%
(
index
,
len
(
lines
[
index
]),
len
(
line
)))
self
.
assertEqual
(
index
+
1
,
len
(
lines
))
def
test_main
():
def
test_main
():
support
.
run_unittest
(
ProxyAuthTests
,
TestUrlopen
)
support
.
run_unittest
(
ProxyAuthTests
,
TestUrlopen
)
...
...
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