Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit761f3ab

Browse files
committed
Add a test for HTMLParser(debug=True)
1 parenta137d14 commit761f3ab

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

‎html5lib/tests/test_parser2.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from __future__importabsolute_import,division,unicode_literals
22

3+
fromsiximportPY2,text_type
4+
35
importio
46

57
from .importsupport# noqa
68

79
fromhtml5lib.constantsimportnamespaces
8-
fromhtml5libimportparse
10+
fromhtml5libimportparse,HTMLParser
911

1012

1113
# tests that aren't autogenerated from text files
@@ -56,3 +58,33 @@ def test_duplicate_attribute():
5658
doc=parse('<p class=a class=b>')
5759
el=doc[1][0]
5860
assertel.get("class")=="a"
61+
62+
63+
deftest_debug_log():
64+
parser=HTMLParser(debug=True)
65+
parser.parse("<!doctype html><title>a</title><p>b<script>c</script>d</p>e")
66+
67+
expected= [('dataState','InitialPhase','InitialPhase','processDoctype', {'type':'Doctype'}),
68+
('dataState','BeforeHtmlPhase','BeforeHtmlPhase','processStartTag', {'name':'title','type':'StartTag'}),
69+
('dataState','BeforeHeadPhase','BeforeHeadPhase','processStartTag', {'name':'title','type':'StartTag'}),
70+
('dataState','InHeadPhase','InHeadPhase','processStartTag', {'name':'title','type':'StartTag'}),
71+
('rcdataState','TextPhase','TextPhase','processCharacters', {'type':'Characters'}),
72+
('dataState','TextPhase','TextPhase','processEndTag', {'name':'title','type':'EndTag'}),
73+
('dataState','InHeadPhase','InHeadPhase','processStartTag', {'name':'p','type':'StartTag'}),
74+
('dataState','AfterHeadPhase','AfterHeadPhase','processStartTag', {'name':'p','type':'StartTag'}),
75+
('dataState','InBodyPhase','InBodyPhase','processStartTag', {'name':'p','type':'StartTag'}),
76+
('dataState','InBodyPhase','InBodyPhase','processCharacters', {'type':'Characters'}),
77+
('dataState','InBodyPhase','InBodyPhase','processStartTag', {'name':'script','type':'StartTag'}),
78+
('dataState','InBodyPhase','InHeadPhase','processStartTag', {'name':'script','type':'StartTag'}),
79+
('scriptDataState','TextPhase','TextPhase','processCharacters', {'type':'Characters'}),
80+
('dataState','TextPhase','TextPhase','processEndTag', {'name':'script','type':'EndTag'}),
81+
('dataState','InBodyPhase','InBodyPhase','processCharacters', {'type':'Characters'}),
82+
('dataState','InBodyPhase','InBodyPhase','processEndTag', {'name':'p','type':'EndTag'}),
83+
('dataState','InBodyPhase','InBodyPhase','processCharacters', {'type':'Characters'})]
84+
85+
ifPY2:
86+
fori,loginenumerate(expected):
87+
log= [x.encode("ascii")ifisinstance(x,text_type)elsexforxinlog]
88+
expected[i]=tuple(log)
89+
90+
assertparser.log==expected

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp