Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
0e90db9e
Commit
0e90db9e
authored
Mar 24, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for handle_comment().
Remove confusing comment about entity replacement.
parent
2c3d7e65
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
2 deletions
+22
-2
lib/python/TAL/test/test_htmlparser.py
lib/python/TAL/test/test_htmlparser.py
+11
-1
lib/python/TAL/tests/test_htmlparser.py
lib/python/TAL/tests/test_htmlparser.py
+11
-1
No files found.
lib/python/TAL/test/test_htmlparser.py
View file @
0e90db9e
...
@@ -44,6 +44,9 @@ class EventCollector(HTMLParser.HTMLParser):
...
@@ -44,6 +44,9 @@ class EventCollector(HTMLParser.HTMLParser):
# all other markup
# all other markup
def
handle_comment
(
self
,
data
):
self
.
append
((
"comment"
,
data
))
def
handle_charref
(
self
,
data
):
def
handle_charref
(
self
,
data
):
self
.
append
((
"charref"
,
data
))
self
.
append
((
"charref"
,
data
))
...
@@ -97,8 +100,12 @@ class HTMLParserTestCase(unittest.TestCase):
...
@@ -97,8 +100,12 @@ class HTMLParserTestCase(unittest.TestCase):
self
.
_run_check
(
"""
self
.
_run_check
(
"""
<!DOCTYPE html PUBLIC 'foo'>
<!DOCTYPE html PUBLIC 'foo'>
<html>&entity; 
<html>&entity; 
<!--comment1a
-></foo><bar><<?pi?></foo<bar
comment1b-->
<img src='bar' ismap>sample
<img src='bar' ismap>sample
text
text
<!--comment2a-- --comment2b-->
</html>
</html>
"""
,
[
"""
,
[
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
...
@@ -108,8 +115,12 @@ text
...
@@ -108,8 +115,12 @@ text
(
"entityref"
,
"entity"
),
(
"entityref"
,
"entity"
),
(
"charref"
,
"32"
),
(
"charref"
,
"32"
),
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
(
"comment"
,
"comment1a
\
n
-></foo><bar><<?pi?></foo<bar
\
n
comment1b"
),
(
"data"
,
"
\
n
"
),
(
"starttag"
,
"img"
,
[(
"src"
,
"bar"
),
(
"ismap"
,
"ismap"
)]),
(
"starttag"
,
"img"
,
[(
"src"
,
"bar"
),
(
"ismap"
,
"ismap"
)]),
(
"data"
,
"sample
\
n
text
\
n
"
),
(
"data"
,
"sample
\
n
text
\
n
"
),
(
"comment"
,
"comment2a-- --comment2b"
),
(
"data"
,
"
\
n
"
),
(
"endtag"
,
"html"
),
(
"endtag"
,
"html"
),
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
])
])
...
@@ -142,7 +153,6 @@ text
...
@@ -142,7 +153,6 @@ text
])
])
def
check_attr_entity_replacement
(
self
):
def
check_attr_entity_replacement
(
self
):
# we expect entities *not* to be replaced by HTLMParser!
self
.
_run_check
(
"""<a b='&><"''>"""
,
[
self
.
_run_check
(
"""<a b='&><"''>"""
,
[
(
"starttag"
,
"a"
,
[(
"b"
,
"&><
\
"
'"
)]),
(
"starttag"
,
"a"
,
[(
"b"
,
"&><
\
"
'"
)]),
])
])
...
...
lib/python/TAL/tests/test_htmlparser.py
View file @
0e90db9e
...
@@ -44,6 +44,9 @@ class EventCollector(HTMLParser.HTMLParser):
...
@@ -44,6 +44,9 @@ class EventCollector(HTMLParser.HTMLParser):
# all other markup
# all other markup
def
handle_comment
(
self
,
data
):
self
.
append
((
"comment"
,
data
))
def
handle_charref
(
self
,
data
):
def
handle_charref
(
self
,
data
):
self
.
append
((
"charref"
,
data
))
self
.
append
((
"charref"
,
data
))
...
@@ -97,8 +100,12 @@ class HTMLParserTestCase(unittest.TestCase):
...
@@ -97,8 +100,12 @@ class HTMLParserTestCase(unittest.TestCase):
self
.
_run_check
(
"""
self
.
_run_check
(
"""
<!DOCTYPE html PUBLIC 'foo'>
<!DOCTYPE html PUBLIC 'foo'>
<html>&entity; 
<html>&entity; 
<!--comment1a
-></foo><bar><<?pi?></foo<bar
comment1b-->
<img src='bar' ismap>sample
<img src='bar' ismap>sample
text
text
<!--comment2a-- --comment2b-->
</html>
</html>
"""
,
[
"""
,
[
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
...
@@ -108,8 +115,12 @@ text
...
@@ -108,8 +115,12 @@ text
(
"entityref"
,
"entity"
),
(
"entityref"
,
"entity"
),
(
"charref"
,
"32"
),
(
"charref"
,
"32"
),
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
(
"comment"
,
"comment1a
\
n
-></foo><bar><<?pi?></foo<bar
\
n
comment1b"
),
(
"data"
,
"
\
n
"
),
(
"starttag"
,
"img"
,
[(
"src"
,
"bar"
),
(
"ismap"
,
"ismap"
)]),
(
"starttag"
,
"img"
,
[(
"src"
,
"bar"
),
(
"ismap"
,
"ismap"
)]),
(
"data"
,
"sample
\
n
text
\
n
"
),
(
"data"
,
"sample
\
n
text
\
n
"
),
(
"comment"
,
"comment2a-- --comment2b"
),
(
"data"
,
"
\
n
"
),
(
"endtag"
,
"html"
),
(
"endtag"
,
"html"
),
(
"data"
,
"
\
n
"
),
(
"data"
,
"
\
n
"
),
])
])
...
@@ -142,7 +153,6 @@ text
...
@@ -142,7 +153,6 @@ text
])
])
def
check_attr_entity_replacement
(
self
):
def
check_attr_entity_replacement
(
self
):
# we expect entities *not* to be replaced by HTLMParser!
self
.
_run_check
(
"""<a b='&><"''>"""
,
[
self
.
_run_check
(
"""<a b='&><"''>"""
,
[
(
"starttag"
,
"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