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
de02a719
Kaydet (Commit)
de02a719
authored
Tem 23, 2011
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix closes issue12581 - Increase the urllib.parse test coverage. Patch by Petter Haggholm.
üst
06ad13ee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
76 additions
and
2 deletions
+76
-2
test_urlparse.py
Lib/test/test_urlparse.py
+76
-2
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
de02a719
...
...
@@ -93,8 +93,11 @@ class UrlParseTestCase(unittest.TestCase):
def
test_qsl
(
self
):
for
orig
,
expect
in
parse_qsl_test_cases
:
result
=
urllib
.
parse
.
parse_qsl
(
orig
,
keep_blank_values
=
True
)
self
.
assertEqual
(
result
,
expect
,
"Error parsing
%
s"
%
repr
(
orig
))
self
.
assertEqual
(
result
,
expect
,
"Error parsing
%
r"
%
orig
)
expect_without_blanks
=
[
v
for
v
in
expect
if
len
(
v
[
1
])]
result
=
urllib
.
parse
.
parse_qsl
(
orig
,
keep_blank_values
=
False
)
self
.
assertEqual
(
result
,
expect_without_blanks
,
"Error parsing
%
r"
%
orig
)
def
test_roundtrips
(
self
):
str_cases
=
[
...
...
@@ -365,6 +368,9 @@ class UrlParseTestCase(unittest.TestCase):
self
.
checkJoin
(
SIMPLE_BASE
,
'http:?y'
,
'http://a/b/c/d?y'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:g?y'
,
'http://a/b/c/g?y'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:g?y/./x'
,
'http://a/b/c/g?y/./x'
)
self
.
checkJoin
(
'http:///'
,
'..'
,
'http:///'
)
self
.
checkJoin
(
''
,
'http://a/b/c/g?y/./x'
,
'http://a/b/c/g?y/./x'
)
self
.
checkJoin
(
''
,
'http://a/./g'
,
'http://a/./g'
)
def
test_RFC2732
(
self
):
str_cases
=
[
...
...
@@ -719,6 +725,74 @@ class UrlParseTestCase(unittest.TestCase):
errors
=
"ignore"
)
self
.
assertEqual
(
result
,
[(
'key'
,
'
\u0141
-'
)])
def
test_splitnport
(
self
):
# Normal cases are exercised by other tests; ensure that we also
# catch cases with no port specified. (testcase ensuring coverage)
result
=
urllib
.
parse
.
splitnport
(
'parrot:88'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
88
))
result
=
urllib
.
parse
.
splitnport
(
'parrot'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
-
1
))
result
=
urllib
.
parse
.
splitnport
(
'parrot'
,
55
)
self
.
assertEqual
(
result
,
(
'parrot'
,
55
))
result
=
urllib
.
parse
.
splitnport
(
'parrot:'
)
self
.
assertEqual
(
result
,
(
'parrot'
,
None
))
def
test_splitquery
(
self
):
# Normal cases are exercised by other tests; ensure that we also
# catch cases with no port specified (testcase ensuring coverage)
result
=
urllib
.
parse
.
splitquery
(
'http://python.org/fake?foo=bar'
)
self
.
assertEqual
(
result
,
(
'http://python.org/fake'
,
'foo=bar'
))
result
=
urllib
.
parse
.
splitquery
(
'http://python.org/fake?foo=bar?'
)
self
.
assertEqual
(
result
,
(
'http://python.org/fake?foo=bar'
,
''
))
result
=
urllib
.
parse
.
splitquery
(
'http://python.org/fake'
)
self
.
assertEqual
(
result
,
(
'http://python.org/fake'
,
None
))
def
test_splitvalue
(
self
):
# Normal cases are exercised by other tests; test pathological cases
# with no key/value pairs. (testcase ensuring coverage)
result
=
urllib
.
parse
.
splitvalue
(
'foo=bar'
)
self
.
assertEqual
(
result
,
(
'foo'
,
'bar'
))
result
=
urllib
.
parse
.
splitvalue
(
'foo='
)
self
.
assertEqual
(
result
,
(
'foo'
,
''
))
result
=
urllib
.
parse
.
splitvalue
(
'foobar'
)
self
.
assertEqual
(
result
,
(
'foobar'
,
None
))
def
test_to_bytes
(
self
):
result
=
urllib
.
parse
.
to_bytes
(
'http://www.python.org'
)
self
.
assertEqual
(
result
,
'http://www.python.org'
)
self
.
assertRaises
(
UnicodeError
,
urllib
.
parse
.
to_bytes
,
'http://www.python.org/medi
\u00e6
val'
)
def
test_urlencode_sequences
(
self
):
# Other tests incidentally urlencode things; test non-covered cases:
# Sequence and object values.
result
=
urllib
.
parse
.
urlencode
({
'a'
:
[
1
,
2
],
'b'
:
(
3
,
4
,
5
)},
True
)
self
.
assertEqual
(
result
,
'a=1&a=2&b=3&b=4&b=5'
)
class
Trivial
:
def
__str__
(
self
):
return
'trivial'
result
=
urllib
.
parse
.
urlencode
({
'a'
:
Trivial
()},
True
)
self
.
assertEqual
(
result
,
'a=trivial'
)
def
test_quote_from_bytes
(
self
):
self
.
assertRaises
(
TypeError
,
urllib
.
parse
.
quote_from_bytes
,
'foo'
)
result
=
urllib
.
parse
.
quote_from_bytes
(
b
'archaeological arcana'
)
self
.
assertEqual
(
result
,
'archaeological
%20
arcana'
)
result
=
urllib
.
parse
.
quote_from_bytes
(
b
''
)
self
.
assertEqual
(
result
,
''
)
def
test_unquote_to_bytes
(
self
):
result
=
urllib
.
parse
.
unquote_to_bytes
(
'abc
%20
def'
)
self
.
assertEqual
(
result
,
b
'abc def'
)
result
=
urllib
.
parse
.
unquote_to_bytes
(
''
)
self
.
assertEqual
(
result
,
b
''
)
def
test_quote_errors
(
self
):
self
.
assertRaises
(
TypeError
,
urllib
.
parse
.
quote
,
b
'foo'
,
encoding
=
'utf-8'
)
self
.
assertRaises
(
TypeError
,
urllib
.
parse
.
quote
,
b
'foo'
,
errors
=
'strict'
)
def
test_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