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
b245ed1c
Kaydet (Commit)
b245ed1c
authored
Kas 14, 2011
tarafından
Ezio Melotti
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Group tests about attributes in a separate class.
üst
0e79b7e9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
59 deletions
+62
-59
test_htmlparser.py
Lib/test/test_htmlparser.py
+62
-59
No files found.
Lib/test/test_htmlparser.py
Dosyayı görüntüle @
b245ed1c
...
...
@@ -196,60 +196,6 @@ DOCTYPE html [
(
"data"
,
"this < text > contains < bare>pointy< brackets"
),
])
def
test_attr_syntax
(
self
):
output
=
[
(
"starttag"
,
"a"
,
[(
"b"
,
"v"
),
(
"c"
,
"v"
),
(
"d"
,
"v"
),
(
"e"
,
None
)])
]
self
.
_run_check
(
"""<a b='v' c="v" d=v e>"""
,
output
)
self
.
_run_check
(
"""<a b = 'v' c = "v" d = v e>"""
,
output
)
self
.
_run_check
(
"""<a
\n
b
\n
=
\n
'v'
\n
c
\n
=
\n
"v"
\n
d
\n
=
\n
v
\n
e>"""
,
output
)
self
.
_run_check
(
"""<a
\t
b
\t
=
\t
'v'
\t
c
\t
=
\t
"v"
\t
d
\t
=
\t
v
\t
e>"""
,
output
)
def
test_attr_values
(
self
):
self
.
_run_check
(
"""<a b='xxx
\n\t
xxx' c="yyy
\t\n
yyy" d='
\t
xyz
\n
'>"""
,
[(
"starttag"
,
"a"
,
[(
"b"
,
"xxx
\n\t
xxx"
),
(
"c"
,
"yyy
\t\n
yyy"
),
(
"d"
,
"
\t
xyz
\n
"
)])
])
self
.
_run_check
(
"""<a b='' c="">"""
,
[
(
"starttag"
,
"a"
,
[(
"b"
,
""
),
(
"c"
,
""
)]),
])
# Regression test for SF patch #669683.
self
.
_run_check
(
"<e a=rgb(1,2,3)>"
,
[
(
"starttag"
,
"e"
,
[(
"a"
,
"rgb(1,2,3)"
)]),
])
# Regression test for SF bug #921657.
self
.
_run_check
(
"<a href=mailto:xyz@example.com>"
,
[
(
"starttag"
,
"a"
,
[(
"href"
,
"mailto:xyz@example.com"
)]),
])
def
test_attr_nonascii
(
self
):
# see issue 7311
self
.
_run_check
(
"<img src=/foo/bar.png alt=
\u4e2d\u6587
>"
,
[
(
"starttag"
,
"img"
,
[(
"src"
,
"/foo/bar.png"
),
(
"alt"
,
"
\u4e2d\u6587
"
)]),
])
self
.
_run_check
(
"<a title='
\u30c6\u30b9\u30c8
' "
"href='
\u30c6\u30b9\u30c8
.html'>"
,
[
(
"starttag"
,
"a"
,
[(
"title"
,
"
\u30c6\u30b9\u30c8
"
),
(
"href"
,
"
\u30c6\u30b9\u30c8
.html"
)]),
])
self
.
_run_check
(
'<a title="
\u30c6\u30b9\u30c8
" '
'href="
\u30c6\u30b9\u30c8
.html">'
,
[
(
"starttag"
,
"a"
,
[(
"title"
,
"
\u30c6\u30b9\u30c8
"
),
(
"href"
,
"
\u30c6\u30b9\u30c8
.html"
)]),
])
def
test_attr_entity_replacement
(
self
):
self
.
_run_check
(
"""<a b='&><"''>"""
,
[
(
"starttag"
,
"a"
,
[(
"b"
,
"&><
\"
'"
)]),
])
def
test_attr_funky_names
(
self
):
self
.
_run_check
(
"""<a a.b='v' c:d=v e-f=v>"""
,
[
(
"starttag"
,
"a"
,
[(
"a.b"
,
"v"
),
(
"c:d"
,
"v"
),
(
"e-f"
,
"v"
)]),
])
def
test_illegal_declarations
(
self
):
self
.
_parse_error
(
'<!spacer type="block" height="25">'
)
...
...
@@ -358,10 +304,6 @@ DOCTYPE html [
(
"endtag"
,
element_lower
)])
def
test_entityrefs_in_attributes
(
self
):
self
.
_run_check
(
"<html foo='€&aa&unsupported;'>"
,
[(
"starttag"
,
"html"
,
[(
"foo"
,
"
\u20AC
&aa&unsupported;"
)])])
class
HTMLParserTolerantTestCase
(
HTMLParserStrictTestCase
):
...
...
@@ -458,8 +400,69 @@ class HTMLParserTolerantTestCase(HTMLParserStrictTestCase):
self
.
assertEqual
(
p
.
unescape
(
'{ '
*
1050
),
'{ '
*
1050
)
class
AttributesStrictTestCase
(
TestCaseBase
):
def
get_collector
(
self
):
return
EventCollector
(
strict
=
True
)
def
test_attr_syntax
(
self
):
output
=
[
(
"starttag"
,
"a"
,
[(
"b"
,
"v"
),
(
"c"
,
"v"
),
(
"d"
,
"v"
),
(
"e"
,
None
)])
]
self
.
_run_check
(
"""<a b='v' c="v" d=v e>"""
,
output
)
self
.
_run_check
(
"""<a b = 'v' c = "v" d = v e>"""
,
output
)
self
.
_run_check
(
"""<a
\n
b
\n
=
\n
'v'
\n
c
\n
=
\n
"v"
\n
d
\n
=
\n
v
\n
e>"""
,
output
)
self
.
_run_check
(
"""<a
\t
b
\t
=
\t
'v'
\t
c
\t
=
\t
"v"
\t
d
\t
=
\t
v
\t
e>"""
,
output
)
def
test_attr_values
(
self
):
self
.
_run_check
(
"""<a b='xxx
\n\t
xxx' c="yyy
\t\n
yyy" d='
\t
xyz
\n
'>"""
,
[(
"starttag"
,
"a"
,
[(
"b"
,
"xxx
\n\t
xxx"
),
(
"c"
,
"yyy
\t\n
yyy"
),
(
"d"
,
"
\t
xyz
\n
"
)])])
self
.
_run_check
(
"""<a b='' c="">"""
,
[(
"starttag"
,
"a"
,
[(
"b"
,
""
),
(
"c"
,
""
)])])
# Regression test for SF patch #669683.
self
.
_run_check
(
"<e a=rgb(1,2,3)>"
,
[(
"starttag"
,
"e"
,
[(
"a"
,
"rgb(1,2,3)"
)])])
# Regression test for SF bug #921657.
self
.
_run_check
(
"<a href=mailto:xyz@example.com>"
,
[(
"starttag"
,
"a"
,
[(
"href"
,
"mailto:xyz@example.com"
)])])
def
test_attr_nonascii
(
self
):
# see issue 7311
self
.
_run_check
(
"<img src=/foo/bar.png alt=
\u4e2d\u6587
>"
,
[(
"starttag"
,
"img"
,
[(
"src"
,
"/foo/bar.png"
),
(
"alt"
,
"
\u4e2d\u6587
"
)])])
self
.
_run_check
(
"<a title='
\u30c6\u30b9\u30c8
' href='
\u30c6\u30b9\u30c8
.html'>"
,
[(
"starttag"
,
"a"
,
[(
"title"
,
"
\u30c6\u30b9\u30c8
"
),
(
"href"
,
"
\u30c6\u30b9\u30c8
.html"
)])])
self
.
_run_check
(
'<a title="
\u30c6\u30b9\u30c8
" href="
\u30c6\u30b9\u30c8
.html">'
,
[(
"starttag"
,
"a"
,
[(
"title"
,
"
\u30c6\u30b9\u30c8
"
),
(
"href"
,
"
\u30c6\u30b9\u30c8
.html"
)])])
def
test_attr_entity_replacement
(
self
):
self
.
_run_check
(
"<a b='&><"''>"
,
[(
"starttag"
,
"a"
,
[(
"b"
,
"&><
\"
'"
)])])
def
test_attr_funky_names
(
self
):
self
.
_run_check
(
"<a a.b='v' c:d=v e-f=v>"
,
[(
"starttag"
,
"a"
,
[(
"a.b"
,
"v"
),
(
"c:d"
,
"v"
),
(
"e-f"
,
"v"
)])])
def
test_entityrefs_in_attributes
(
self
):
self
.
_run_check
(
"<html foo='€&aa&unsupported;'>"
,
[(
"starttag"
,
"html"
,
[(
"foo"
,
"
\u20AC
&aa&unsupported;"
)])])
def
test_main
():
support
.
run_unittest
(
HTMLParserStrictTestCase
,
HTMLParserTolerantTestCase
)
support
.
run_unittest
(
HTMLParserStrictTestCase
,
HTMLParserTolerantTestCase
,
AttributesStrictTestCase
)
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