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
aa69d4d0
Kaydet (Commit)
aa69d4d0
authored
Tem 14, 2010
tarafından
Senthil Kumaran
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fix Issue5842 - Moving the tests out of urllib.parse module
üst
fc9e08de
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
64 deletions
+32
-64
test_urlparse.py
Lib/test/test_urlparse.py
+32
-0
parse.py
Lib/urllib/parse.py
+0
-64
No files found.
Lib/test/test_urlparse.py
Dosyayı görüntüle @
aa69d4d0
...
@@ -7,6 +7,7 @@ import urllib.parse
...
@@ -7,6 +7,7 @@ import urllib.parse
RFC1808_BASE
=
"http://a/b/c/d;p?q#f"
RFC1808_BASE
=
"http://a/b/c/d;p?q#f"
RFC2396_BASE
=
"http://a/b/c/d;p?q"
RFC2396_BASE
=
"http://a/b/c/d;p?q"
RFC3986_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 a two-tuple that contains
# A list of test cases. Each test case is a a two-tuple that contains
# a string with the query and a dictionary with the expected result.
# a string with the query and a dictionary with the expected result.
...
@@ -295,6 +296,37 @@ class UrlParseTestCase(unittest.TestCase):
...
@@ -295,6 +296,37 @@ class UrlParseTestCase(unittest.TestCase):
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
#self.checkJoin(RFC3986_BASE, 'http:g','http:g') # strict parser
self
.
checkJoin
(
RFC3986_BASE
,
'http:g'
,
'http://a/b/c/g'
)
#relaxed parser
self
.
checkJoin
(
RFC3986_BASE
,
'http:g'
,
'http://a/b/c/g'
)
#relaxed parser
def
test_urljoins
(
self
):
self
.
checkJoin
(
SIMPLE_BASE
,
'g:h'
,
'g:h'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:g'
,
'http://a/b/c/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:'
,
'http://a/b/c/d'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g'
,
'http://a/b/c/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'./g'
,
'http://a/b/c/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g/'
,
'http://a/b/c/g/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'/g'
,
'http://a/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'//g'
,
'http://g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'?y'
,
'http://a/b/c/d?y'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g?y'
,
'http://a/b/c/g?y'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g?y/./x'
,
'http://a/b/c/g?y/./x'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'.'
,
'http://a/b/c/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'./'
,
'http://a/b/c/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'..'
,
'http://a/b/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'../'
,
'http://a/b/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'../g'
,
'http://a/b/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'../..'
,
'http://a/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'../../g'
,
'http://a/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'../../../g'
,
'http://a/../g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'./../g'
,
'http://a/b/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'./g/.'
,
'http://a/b/c/g/'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'/./g'
,
'http://a/./g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g/./h'
,
'http://a/b/c/g/h'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'g/../h'
,
'http://a/b/c/h'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:g'
,
'http://a/b/c/g'
)
self
.
checkJoin
(
SIMPLE_BASE
,
'http:'
,
'http://a/b/c/d'
)
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'
)
def
test_RFC2732
(
self
):
def
test_RFC2732
(
self
):
for
url
,
hostname
,
port
in
[
for
url
,
hostname
,
port
in
[
(
'http://Test.python.org:5432/foo/'
,
'test.python.org'
,
5432
),
(
'http://Test.python.org:5432/foo/'
,
'test.python.org'
,
5432
),
...
...
Lib/urllib/parse.py
Dosyayı görüntüle @
aa69d4d0
...
@@ -799,67 +799,3 @@ def splitvalue(attr):
...
@@ -799,67 +799,3 @@ def splitvalue(attr):
match
=
_valueprog
.
match
(
attr
)
match
=
_valueprog
.
match
(
attr
)
if
match
:
return
match
.
group
(
1
,
2
)
if
match
:
return
match
.
group
(
1
,
2
)
return
attr
,
None
return
attr
,
None
test_input
=
"""
http://a/b/c/d
g:h = <URL:g:h>
http:g = <URL:http://a/b/c/g>
http: = <URL:http://a/b/c/d>
g = <URL:http://a/b/c/g>
./g = <URL:http://a/b/c/g>
g/ = <URL:http://a/b/c/g/>
/g = <URL:http://a/g>
//g = <URL:http://g>
?y = <URL:http://a/b/c/d?y>
g?y = <URL:http://a/b/c/g?y>
g?y/./x = <URL:http://a/b/c/g?y/./x>
. = <URL:http://a/b/c/>
./ = <URL:http://a/b/c/>
.. = <URL:http://a/b/>
../ = <URL:http://a/b/>
../g = <URL:http://a/b/g>
../.. = <URL:http://a/>
../../g = <URL:http://a/g>
../../../g = <URL:http://a/../g>
./../g = <URL:http://a/b/g>
./g/. = <URL:http://a/b/c/g/>
/./g = <URL:http://a/./g>
g/./h = <URL:http://a/b/c/g/h>
g/../h = <URL:http://a/b/c/h>
http:g = <URL:http://a/b/c/g>
http: = <URL:http://a/b/c/d>
http:?y = <URL:http://a/b/c/d?y>
http:g?y = <URL:http://a/b/c/g?y>
http:g?y/./x = <URL:http://a/b/c/g?y/./x>
"""
def
test
():
base
=
''
if
sys
.
argv
[
1
:]:
fn
=
sys
.
argv
[
1
]
if
fn
==
'-'
:
fp
=
sys
.
stdin
else
:
fp
=
open
(
fn
)
else
:
from
io
import
StringIO
fp
=
StringIO
(
test_input
)
for
line
in
fp
:
words
=
line
.
split
()
if
not
words
:
continue
url
=
words
[
0
]
parts
=
urlparse
(
url
)
print
(
'
%-10
s :
%
s'
%
(
url
,
parts
))
abs
=
urljoin
(
base
,
url
)
if
not
base
:
base
=
abs
wrapped
=
'<URL:
%
s>'
%
abs
print
(
'
%-10
s =
%
s'
%
(
url
,
wrapped
))
if
len
(
words
)
==
3
and
words
[
1
]
==
'='
:
if
wrapped
!=
words
[
2
]:
print
(
'EXPECTED'
,
words
[
2
],
'!!!!!!!!!!'
)
if
__name__
==
'__main__'
:
test
()
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