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
257b980b
Kaydet (Commit)
257b980b
authored
Nis 05, 2017
tarafından
Senthil Kumaran
Kaydeden (comit)
GitHub
Nis 05, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
correct parse_qs and parse_qsl test case descriptions. (#968)
* correct parse_qs and parse_qsl test case descriptions.
üst
f78b1193
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
test_urlparse.py
Lib/test/test_urlparse.py
+6
-6
parse.py
Lib/urllib/parse.py
+6
-2
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
257b980b
...
...
@@ -6,8 +6,8 @@ RFC2396_BASE = "http://a/b/c/d;p?q"
RFC3986_BASE
=
'http://a/b/c/d;p?q'
SIMPLE_BASE
=
'http://a/b/c/d'
#
A list of test cases. Each test
case is a two-tuple that contains
# a string with the query and a
dictionary
with the expected result.
#
Each parse_qsl test
case is a two-tuple that contains
# a string with the query and a
list
with the expected result.
parse_qsl_test_cases
=
[
(
""
,
[]),
...
...
@@ -42,6 +42,9 @@ parse_qsl_test_cases = [
(
b
"a=1;a=2"
,
[(
b
'a'
,
b
'1'
),
(
b
'a'
,
b
'2'
)]),
]
# Each parse_qs testcase is a two-tuple that contains
# a string with the query and a dictionary with the expected result.
parse_qs_test_cases
=
[
(
""
,
{}),
(
"&"
,
{}),
...
...
@@ -290,7 +293,6 @@ class UrlParseTestCase(unittest.TestCase):
def
test_RFC2396
(
self
):
# cases from RFC 2396
self
.
checkJoin
(
RFC2396_BASE
,
'g:h'
,
'g:h'
)
self
.
checkJoin
(
RFC2396_BASE
,
'g'
,
'http://a/b/c/g'
)
self
.
checkJoin
(
RFC2396_BASE
,
'./g'
,
'http://a/b/c/g'
)
...
...
@@ -333,9 +335,7 @@ class UrlParseTestCase(unittest.TestCase):
# self.checkJoin(RFC2396_BASE, '/./g', 'http://a/./g')
# self.checkJoin(RFC2396_BASE, '/../g', 'http://a/../g')
def
test_RFC3986
(
self
):
# Test cases from RFC3986
self
.
checkJoin
(
RFC3986_BASE
,
'?y'
,
'http://a/b/c/d;p?y'
)
self
.
checkJoin
(
RFC3986_BASE
,
';x'
,
'http://a/b/c/;x'
)
self
.
checkJoin
(
RFC3986_BASE
,
'g:h'
,
'g:h'
)
...
...
@@ -363,7 +363,7 @@ class UrlParseTestCase(unittest.TestCase):
self
.
checkJoin
(
RFC3986_BASE
,
'../../g'
,
'http://a/g'
)
self
.
checkJoin
(
RFC3986_BASE
,
'../../../g'
,
'http://a/g'
)
#Abnormal Examples
#
Abnormal Examples
# The 'abnormal scenarios' are incompatible with RFC2986 parsing
# Tests are here for reference.
...
...
Lib/urllib/parse.py
Dosyayı görüntüle @
257b980b
...
...
@@ -612,6 +612,7 @@ def unquote(string, encoding='utf-8', errors='replace'):
append
(
bits
[
i
+
1
])
return
''
.
join
(
res
)
def
parse_qs
(
qs
,
keep_blank_values
=
False
,
strict_parsing
=
False
,
encoding
=
'utf-8'
,
errors
=
'replace'
):
"""Parse a query given as a string argument.
...
...
@@ -633,6 +634,8 @@ def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
encoding and errors: specify how to decode percent-encoded sequences
into Unicode characters, as accepted by the bytes.decode() method.
Returns a dictionary.
"""
parsed_result
=
{}
pairs
=
parse_qsl
(
qs
,
keep_blank_values
,
strict_parsing
,
...
...
@@ -644,6 +647,7 @@ def parse_qs(qs, keep_blank_values=False, strict_parsing=False,
parsed_result
[
name
]
=
[
value
]
return
parsed_result
def
parse_qsl
(
qs
,
keep_blank_values
=
False
,
strict_parsing
=
False
,
encoding
=
'utf-8'
,
errors
=
'replace'
):
"""Parse a query given as a string argument.
...
...
@@ -653,8 +657,8 @@ def parse_qsl(qs, keep_blank_values=False, strict_parsing=False,
qs: percent-encoded query string to be parsed
keep_blank_values: flag indicating whether blank values in
percent-encoded queries should be treated as blank strings. A
true value indicates that blanks should be retained as blank
percent-encoded queries should be treated as blank strings.
A
true value indicates that blanks should be retained as blank
strings. The default false value indicates that blank values
are to be ignored and treated as if they were not included.
...
...
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