[Python-checkins] CVS: python/dist/src/Lib/test test_htmlparser.py,1.3,1.4

Fred L. Drake fdrake@users.sourceforge.net
2001年8月20日 14:24:21 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv22193/Lib/test
Modified Files:
	test_htmlparser.py 
Log Message:
Deal more appropriately with bare ampersands and pointy brackets; this
module has to deal with "class" HTML-as-deployed as well as XHTML, so we
cannot be as strict as XHTML allows.
This closes SF bug #453059, but uses a different fix than suggested in
the bug comments.
Index: test_htmlparser.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_htmlparser.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** test_htmlparser.py	2001年08月03日 19:53:01	1.3
--- test_htmlparser.py	2001年08月20日 21:24:19	1.4
***************
*** 2,5 ****
--- 2,6 ----
 
 import HTMLParser
+ import pprint
 import sys
 import test_support
***************
*** 84,90 ****
 parser.feed(c)
 parser.close()
! self.assert_(parser.get_events() ==
! self.initial_events + events + self.final_events,
! parser.get_events())
 
 def _run_check_extra(self, source, events):
--- 85,92 ----
 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))
 
 def _run_check_extra(self, source, events):
***************
*** 138,141 ****
--- 140,155 ----
 ])
 
+ def test_doctype_decl(self):
+ inside = """\
+ DOCTYPE html [
+ <!ELEMENT html - O EMPTY>
+ <!ATTLIST html
+ version CDATA #IMPLIED '4.0'>
+ <!-- comment -->
+ ]"""
+ self._run_check("<!%s>" % inside, [
+ ("decl", inside),
+ ])
+ 
 def test_bad_nesting(self):
 # Strangely, this *is* supposed to test that overlapping
***************
*** 149,152 ****
--- 163,176 ----
 ])
 
+ def test_bare_ampersands(self):
+ self._run_check("this text & contains & ampersands &", [
+ ("data", "this text & contains & ampersands &"),
+ ])
+ 
+ def test_bare_pointy_brackets(self):
+ self._run_check("this < text > contains < bare>pointy< brackets", [
+ ("data", "this < text > contains < bare>pointy< brackets"),
+ ])
+ 
 def test_attr_syntax(self):
 output = [
***************
*** 200,205 ****
 
 def test_starttag_junk_chars(self):
- self._parse_error("<")
- self._parse_error("<>")
 self._parse_error("</>")
 self._parse_error("</$>")
--- 224,227 ----
***************
*** 208,213 ****
 self._parse_error("<a<a>")
 self._parse_error("</a<a>")
- self._parse_error("<$")
- self._parse_error("<$>")
 self._parse_error("<!")
 self._parse_error("<a $>")
--- 230,233 ----

AltStyle によって変換されたページ (->オリジナル) /