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
b173d902
Commit
b173d902
authored
Mar 24, 2001
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for improperly closed start and end tag (< instead of >).
Add test for get_starttag_text().
parent
5b1a07ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
6 deletions
+38
-6
lib/python/TAL/test/test_htmlparser.py
lib/python/TAL/test/test_htmlparser.py
+19
-3
lib/python/TAL/tests/test_htmlparser.py
lib/python/TAL/tests/test_htmlparser.py
+19
-3
No files found.
lib/python/TAL/test/test_htmlparser.py
View file @
b173d902
...
...
@@ -60,10 +60,16 @@ class EventCollector(HTMLParser.HTMLParser):
self
.
append
((
"pi"
,
data
))
class
EventCollectorExtra
(
EventCollector
):
def
handle_starttag
(
self
,
tag
,
attrs
):
EventCollector
.
handle_starttag
(
self
,
tag
,
attrs
)
self
.
append
((
"starttag_text"
,
self
.
get_starttag_text
()))
class
HTMLParserTestCase
(
unittest
.
TestCase
):
def
_run_check
(
self
,
source
,
events
):
parser
=
EventC
ollector
()
def
_run_check
(
self
,
source
,
events
,
collector
=
EventCollector
):
parser
=
c
ollector
()
if
isinstance
(
source
,
type
([])):
for
s
in
source
:
parser
.
feed
(
s
)
...
...
@@ -72,6 +78,9 @@ class HTMLParserTestCase(unittest.TestCase):
parser
.
close
()
self
.
assert_
(
parser
.
get_events
()
==
events
,
parser
.
get_events
())
def
_run_check_extra
(
self
,
source
,
events
):
self
.
_run_check
(
source
,
events
,
EventCollectorExtra
)
def
_parse_error
(
self
,
source
):
def
parse
(
source
=
source
):
parser
=
HTMLParser
.
HTMLParser
()
...
...
@@ -171,7 +180,8 @@ text
self
.
_parse_error
(
"</"
)
self
.
_parse_error
(
"</a"
)
self
.
_parse_error
(
"</a"
)
## self._parse_error("</a<a>")
self
.
_parse_error
(
"<a<a>"
)
self
.
_parse_error
(
"</a<a>"
)
self
.
_parse_error
(
"<$"
)
self
.
_parse_error
(
"<$>"
)
self
.
_parse_error
(
"<!"
)
...
...
@@ -199,6 +209,12 @@ text
(
"endtag"
,
"p"
),
])
def
check_get_starttag_text
(
self
):
s
=
"""<foo:bar
\
n
one="1"
\
t
two=2 >"""
self
.
_run_check_extra
(
s
,
[
(
"starttag"
,
"foo:bar"
,
[(
"one"
,
"1"
),
(
"two"
,
"2"
)]),
(
"starttag_text"
,
s
)])
# Support for the Zope regression test framework:
def
test_suite
():
...
...
lib/python/TAL/tests/test_htmlparser.py
View file @
b173d902
...
...
@@ -60,10 +60,16 @@ class EventCollector(HTMLParser.HTMLParser):
self
.
append
((
"pi"
,
data
))
class
EventCollectorExtra
(
EventCollector
):
def
handle_starttag
(
self
,
tag
,
attrs
):
EventCollector
.
handle_starttag
(
self
,
tag
,
attrs
)
self
.
append
((
"starttag_text"
,
self
.
get_starttag_text
()))
class
HTMLParserTestCase
(
unittest
.
TestCase
):
def
_run_check
(
self
,
source
,
events
):
parser
=
EventC
ollector
()
def
_run_check
(
self
,
source
,
events
,
collector
=
EventCollector
):
parser
=
c
ollector
()
if
isinstance
(
source
,
type
([])):
for
s
in
source
:
parser
.
feed
(
s
)
...
...
@@ -72,6 +78,9 @@ class HTMLParserTestCase(unittest.TestCase):
parser
.
close
()
self
.
assert_
(
parser
.
get_events
()
==
events
,
parser
.
get_events
())
def
_run_check_extra
(
self
,
source
,
events
):
self
.
_run_check
(
source
,
events
,
EventCollectorExtra
)
def
_parse_error
(
self
,
source
):
def
parse
(
source
=
source
):
parser
=
HTMLParser
.
HTMLParser
()
...
...
@@ -171,7 +180,8 @@ text
self
.
_parse_error
(
"</"
)
self
.
_parse_error
(
"</a"
)
self
.
_parse_error
(
"</a"
)
## self._parse_error("</a<a>")
self
.
_parse_error
(
"<a<a>"
)
self
.
_parse_error
(
"</a<a>"
)
self
.
_parse_error
(
"<$"
)
self
.
_parse_error
(
"<$>"
)
self
.
_parse_error
(
"<!"
)
...
...
@@ -199,6 +209,12 @@ text
(
"endtag"
,
"p"
),
])
def
check_get_starttag_text
(
self
):
s
=
"""<foo:bar
\
n
one="1"
\
t
two=2 >"""
self
.
_run_check_extra
(
s
,
[
(
"starttag"
,
"foo:bar"
,
[(
"one"
,
"1"
),
(
"two"
,
"2"
)]),
(
"starttag_text"
,
s
)])
# Support for the Zope regression test framework:
def
test_suite
():
...
...
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