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
77b7de6d
Kaydet (Commit)
77b7de6d
authored
Eki 29, 2010
tarafından
Brett Cannon
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Move test_httplib over to file context managers.
üst
7f462fc8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
test_httplib.py
Lib/test/test_httplib.py
+25
-27
No files found.
Lib/test/test_httplib.py
Dosyayı görüntüle @
77b7de6d
...
...
@@ -189,13 +189,13 @@ class BasicTest(TestCase):
expected
=
(
b
'GET /foo HTTP/1.1
\r\n
Host: example.com
\r\n
'
b
'Accept-Encoding: identity
\r\n
Content-Length:'
)
body
=
open
(
__file__
,
'rb'
)
conn
=
client
.
HTTPConnection
(
'example.com'
)
sock
=
FakeSocket
(
body
)
conn
.
sock
=
sock
conn
.
request
(
'GET'
,
'/foo'
,
body
)
self
.
assertTrue
(
sock
.
data
.
startswith
(
expected
),
'
%
r !=
%
r'
%
(
sock
.
data
[:
len
(
expected
)],
expected
))
with
open
(
__file__
,
'rb'
)
as
body
:
conn
=
client
.
HTTPConnection
(
'example.com'
)
sock
=
FakeSocket
(
body
)
conn
.
sock
=
sock
conn
.
request
(
'GET'
,
'/foo'
,
body
)
self
.
assertTrue
(
sock
.
data
.
startswith
(
expected
),
'
%
r !=
%
r'
%
(
sock
.
data
[:
len
(
expected
)],
expected
))
def
test_send
(
self
):
expected
=
b
'this is a test this is only a test'
...
...
@@ -519,28 +519,26 @@ class RequestBodyTest(TestCase):
self
.
assertEqual
(
b
'body
\xc1
'
,
f
.
read
())
def
test_file_body
(
self
):
f
=
open
(
support
.
TESTFN
,
"w"
)
f
.
write
(
"body"
)
f
.
close
()
f
=
open
(
support
.
TESTFN
)
self
.
conn
.
request
(
"PUT"
,
"/url"
,
f
)
message
,
f
=
self
.
get_headers_and_fp
()
self
.
assertEqual
(
"text/plain"
,
message
.
get_content_type
())
self
.
assertEqual
(
None
,
message
.
get_charset
())
self
.
assertEqual
(
"4"
,
message
.
get
(
"content-length"
))
self
.
assertEqual
(
b
'body'
,
f
.
read
())
with
open
(
support
.
TESTFN
,
"w"
)
as
f
:
f
.
write
(
"body"
)
with
open
(
support
.
TESTFN
)
as
f
:
self
.
conn
.
request
(
"PUT"
,
"/url"
,
f
)
message
,
f
=
self
.
get_headers_and_fp
()
self
.
assertEqual
(
"text/plain"
,
message
.
get_content_type
())
self
.
assertEqual
(
None
,
message
.
get_charset
())
self
.
assertEqual
(
"4"
,
message
.
get
(
"content-length"
))
self
.
assertEqual
(
b
'body'
,
f
.
read
())
def
test_binary_file_body
(
self
):
f
=
open
(
support
.
TESTFN
,
"wb"
)
f
.
write
(
b
"body
\xc1
"
)
f
.
close
()
f
=
open
(
support
.
TESTFN
,
"rb"
)
self
.
conn
.
request
(
"PUT"
,
"/url"
,
f
)
message
,
f
=
self
.
get_headers_and_fp
()
self
.
assertEqual
(
"text/plain"
,
message
.
get_content_type
())
self
.
assertEqual
(
None
,
message
.
get_charset
())
self
.
assertEqual
(
"5"
,
message
.
get
(
"content-length"
))
self
.
assertEqual
(
b
'body
\xc1
'
,
f
.
read
())
with
open
(
support
.
TESTFN
,
"wb"
)
as
f
:
f
.
write
(
b
"body
\xc1
"
)
with
open
(
support
.
TESTFN
,
"rb"
)
as
f
:
self
.
conn
.
request
(
"PUT"
,
"/url"
,
f
)
message
,
f
=
self
.
get_headers_and_fp
()
self
.
assertEqual
(
"text/plain"
,
message
.
get_content_type
())
self
.
assertEqual
(
None
,
message
.
get_charset
())
self
.
assertEqual
(
"5"
,
message
.
get
(
"content-length"
))
self
.
assertEqual
(
b
'body
\xc1
'
,
f
.
read
())
class
HTTPResponseTest
(
TestCase
):
...
...
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