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
c20a6989
Kaydet (Commit)
c20a6989
authored
Eyl 04, 2001
tarafından
Fred Drake
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Enhanced the test for DOCTYPE declarations, added a test for dealing with
broken declaration-like things.
üst
68eac2b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
14 deletions
+23
-14
test_htmlparser.py
Lib/test/test_htmlparser.py
+23
-14
No files found.
Lib/test/test_htmlparser.py
Dosyayı görüntüle @
c20a6989
...
...
@@ -60,6 +60,9 @@ class EventCollector(HTMLParser.HTMLParser):
def
handle_pi
(
self
,
data
):
self
.
append
((
"pi"
,
data
))
def
unknown_decl
(
self
,
decl
):
self
.
append
((
"unknown decl"
,
decl
))
class
EventCollectorExtra
(
EventCollector
):
...
...
@@ -70,24 +73,16 @@ class EventCollectorExtra(EventCollector):
class
TestCaseBase
(
unittest
.
TestCase
):
# Constant pieces of source and events
prologue
=
""
epilogue
=
""
initial_events
=
[]
final_events
=
[]
def
_run_check
(
self
,
source
,
events
,
collector
=
EventCollector
):
def
_run_check
(
self
,
source
,
expected_events
,
collector
=
EventCollector
):
parser
=
collector
()
parser
.
feed
(
self
.
prologue
)
for
s
in
source
:
parser
.
feed
(
s
)
for
c
in
self
.
epilogue
:
parser
.
feed
(
c
)
parser
.
close
()
events
=
parser
.
get_events
()
self
.
assertEqual
(
events
,
self
.
initial_events
+
events
+
self
.
final_events
,
"got events:
\n
"
+
pprint
.
pformat
(
events
))
if
events
!=
expected_events
:
self
.
fail
(
"received events did not match expected events
\n
"
"Expected:
\n
"
+
pprint
.
pformat
(
expected_events
)
+
"
\n
Received:
\n
"
+
pprint
.
pformat
(
events
))
def
_run_check_extra
(
self
,
source
,
events
):
self
.
_run_check
(
source
,
events
,
EventCollectorExtra
)
...
...
@@ -144,7 +139,13 @@ text
DOCTYPE html [
<!ELEMENT html - O EMPTY>
<!ATTLIST html
version CDATA #IMPLIED '4.0'>
version CDATA #IMPLIED
profile CDATA 'DublinCore'>
<!NOTATION datatype SYSTEM 'http://xml.python.org/notations/python-module'>
<!ENTITY myEntity 'internal parsed entity'>
<!ENTITY anEntity SYSTEM 'http://xml.python.org/entities/something.xml'>
<!ENTITY
%
paramEntity 'name|name|name'>
%
paramEntity;
<!-- comment -->
]"""
self
.
_run_check
(
"<!
%
s>"
%
inside
,
[
...
...
@@ -201,6 +202,14 @@ DOCTYPE html [
(
"starttag"
,
"a"
,
[(
"a.b"
,
"v"
),
(
"c:d"
,
"v"
),
(
"e-f"
,
"v"
)]),
])
def
test_illegal_declarations
(
self
):
s
=
'abc<!spacer type="block" height="25">def'
self
.
_run_check
(
s
,
[
(
"data"
,
"abc"
),
(
"unknown decl"
,
'spacer type="block" height="25"'
),
(
"data"
,
"def"
),
])
def
test_starttag_end_boundary
(
self
):
self
.
_run_check
(
"""<a b='<'>"""
,
[(
"starttag"
,
"a"
,
[(
"b"
,
"<"
)])])
self
.
_run_check
(
"""<a b='>'>"""
,
[(
"starttag"
,
"a"
,
[(
"b"
,
">"
)])])
...
...
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