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
1868d7c2
Kaydet (Commit)
1868d7c2
authored
Ara 09, 2008
tarafından
Jeremy Hylton
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add simple unittests for Request
üst
16a2a1d2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
test_urllib2.py
Lib/test/test_urllib2.py
+47
-1
No files found.
Lib/test/test_urllib2.py
Dosyayı görüntüle @
1868d7c2
...
...
@@ -1104,6 +1104,51 @@ class MiscTests(unittest.TestCase):
else
:
self
.
assert_
(
False
)
class
RequestTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
get
=
urllib2
.
Request
(
"http://www.python.org/~jeremy/"
)
self
.
post
=
urllib2
.
Request
(
"http://www.python.org/~jeremy/"
,
"data"
,
headers
=
{
"X-Test"
:
"test"
})
def
test_method
(
self
):
self
.
assertEqual
(
"POST"
,
self
.
post
.
get_method
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
def
test_add_data
(
self
):
self
.
assert_
(
not
self
.
get
.
has_data
())
self
.
assertEqual
(
"GET"
,
self
.
get
.
get_method
())
self
.
get
.
add_data
(
"spam"
)
self
.
assert_
(
self
.
get
.
has_data
())
self
.
assertEqual
(
"POST"
,
self
.
get
.
get_method
())
def
test_get_full_url
(
self
):
self
.
assertEqual
(
"http://www.python.org/~jeremy/"
,
self
.
get
.
get_full_url
())
def
test_selector
(
self
):
self
.
assertEqual
(
"/~jeremy/"
,
self
.
get
.
get_selector
())
req
=
urllib2
.
Request
(
"http://www.python.org/"
)
self
.
assertEqual
(
"/"
,
req
.
get_selector
())
def
test_get_type
(
self
):
self
.
assertEqual
(
"http"
,
self
.
get
.
get_type
())
def
test_get_host
(
self
):
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
get_host
())
def
test_get_host_unquote
(
self
):
req
=
urllib2
.
Request
(
"http://www.
%70
ython.org/"
)
self
.
assertEqual
(
"www.python.org"
,
req
.
get_host
())
def
test_proxy
(
self
):
self
.
assert_
(
not
self
.
get
.
has_proxy
())
self
.
get
.
set_proxy
(
"www.perl.org"
,
"http"
)
self
.
assert_
(
self
.
get
.
has_proxy
())
self
.
assertEqual
(
"www.python.org"
,
self
.
get
.
get_origin_req_host
())
self
.
assertEqual
(
"www.perl.org"
,
self
.
get
.
get_host
())
def
test_main
(
verbose
=
None
):
from
test
import
test_urllib2
...
...
@@ -1112,7 +1157,8 @@ def test_main(verbose=None):
tests
=
(
TrivialTests
,
OpenerDirectorTests
,
HandlerTests
,
MiscTests
)
MiscTests
,
RequestTests
)
test_support
.
run_unittest
(
*
tests
)
if
__name__
==
"__main__"
:
...
...
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