mirror of
https://github.com/python/cpython.git
synced 2025-10-07 15:42:02 +00:00
Fix stupid bug: when migrating these tests from the Zope repository, the
names of the test methods were not changed from the Zope-standard "check" names to the Python-standard "test_" names, so the tests were not actually being run. Added test of hexadecimal character references as a regression check for SF bug #445196.
This commit is contained in:
parent
1d4601d306
commit
84bb9d8dc4
1 changed files with 20 additions and 14 deletions
|
@ -100,12 +100,12 @@ class TestCaseBase(unittest.TestCase):
|
||||||
|
|
||||||
class HTMLParserTestCase(TestCaseBase):
|
class HTMLParserTestCase(TestCaseBase):
|
||||||
|
|
||||||
def check_processing_instruction_only(self):
|
def test_processing_instruction_only(self):
|
||||||
self._run_check("<?processing instruction>", [
|
self._run_check("<?processing instruction>", [
|
||||||
("pi", "processing instruction"),
|
("pi", "processing instruction"),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_simple_html(self):
|
def test_simple_html(self):
|
||||||
self._run_check("""
|
self._run_check("""
|
||||||
<!DOCTYPE html PUBLIC 'foo'>
|
<!DOCTYPE html PUBLIC 'foo'>
|
||||||
<HTML>&entity; 
|
<HTML>&entity; 
|
||||||
|
@ -114,6 +114,7 @@ class HTMLParserTestCase(TestCaseBase):
|
||||||
comment1b-->
|
comment1b-->
|
||||||
<Img sRc='Bar' isMAP>sample
|
<Img sRc='Bar' isMAP>sample
|
||||||
text
|
text
|
||||||
|
“
|
||||||
<!--comment2a-- --comment2b-->
|
<!--comment2a-- --comment2b-->
|
||||||
</Html>
|
</Html>
|
||||||
""", [
|
""", [
|
||||||
|
@ -128,13 +129,18 @@ text
|
||||||
("data", "\n"),
|
("data", "\n"),
|
||||||
("starttag", "img", [("src", "Bar"), ("ismap", None)]),
|
("starttag", "img", [("src", "Bar"), ("ismap", None)]),
|
||||||
("data", "sample\ntext\n"),
|
("data", "sample\ntext\n"),
|
||||||
|
("charref", "x201C"),
|
||||||
|
("data", "\n"),
|
||||||
("comment", "comment2a-- --comment2b"),
|
("comment", "comment2a-- --comment2b"),
|
||||||
("data", "\n"),
|
("data", "\n"),
|
||||||
("endtag", "html"),
|
("endtag", "html"),
|
||||||
("data", "\n"),
|
("data", "\n"),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_bad_nesting(self):
|
def test_bad_nesting(self):
|
||||||
|
# Strangely, this *is* supposed to test that overlapping
|
||||||
|
# elements are allowed. HTMLParser is more geared toward
|
||||||
|
# lexing the input that parsing the structure.
|
||||||
self._run_check("<a><b></a></b>", [
|
self._run_check("<a><b></a></b>", [
|
||||||
("starttag", "a", []),
|
("starttag", "a", []),
|
||||||
("starttag", "b", []),
|
("starttag", "b", []),
|
||||||
|
@ -142,7 +148,7 @@ text
|
||||||
("endtag", "b"),
|
("endtag", "b"),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_attr_syntax(self):
|
def test_attr_syntax(self):
|
||||||
output = [
|
output = [
|
||||||
("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)])
|
("starttag", "a", [("b", "v"), ("c", "v"), ("d", "v"), ("e", None)])
|
||||||
]
|
]
|
||||||
|
@ -151,7 +157,7 @@ text
|
||||||
self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output)
|
self._run_check("""<a\nb\n=\n'v'\nc\n=\n"v"\nd\n=\nv\ne>""", output)
|
||||||
self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output)
|
self._run_check("""<a\tb\t=\t'v'\tc\t=\t"v"\td\t=\tv\te>""", output)
|
||||||
|
|
||||||
def check_attr_values(self):
|
def test_attr_values(self):
|
||||||
self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
|
self._run_check("""<a b='xxx\n\txxx' c="yyy\t\nyyy" d='\txyz\n'>""",
|
||||||
[("starttag", "a", [("b", "xxx\n\txxx"),
|
[("starttag", "a", [("b", "xxx\n\txxx"),
|
||||||
("c", "yyy\t\nyyy"),
|
("c", "yyy\t\nyyy"),
|
||||||
|
@ -161,21 +167,21 @@ text
|
||||||
("starttag", "a", [("b", ""), ("c", "")]),
|
("starttag", "a", [("b", ""), ("c", "")]),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_attr_entity_replacement(self):
|
def test_attr_entity_replacement(self):
|
||||||
self._run_check("""<a b='&><"''>""", [
|
self._run_check("""<a b='&><"''>""", [
|
||||||
("starttag", "a", [("b", "&><\"'")]),
|
("starttag", "a", [("b", "&><\"'")]),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_attr_funky_names(self):
|
def test_attr_funky_names(self):
|
||||||
self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
|
self._run_check("""<a a.b='v' c:d=v e-f=v>""", [
|
||||||
("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
|
("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_starttag_end_boundary(self):
|
def test_starttag_end_boundary(self):
|
||||||
self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])])
|
self._run_check("""<a b='<'>""", [("starttag", "a", [("b", "<")])])
|
||||||
self._run_check("""<a b='>'>""", [("starttag", "a", [("b", ">")])])
|
self._run_check("""<a b='>'>""", [("starttag", "a", [("b", ">")])])
|
||||||
|
|
||||||
def check_buffer_artefacts(self):
|
def test_buffer_artefacts(self):
|
||||||
output = [("starttag", "a", [("b", "<")])]
|
output = [("starttag", "a", [("b", "<")])]
|
||||||
self._run_check(["<a b='<'>"], output)
|
self._run_check(["<a b='<'>"], output)
|
||||||
self._run_check(["<a ", "b='<'>"], output)
|
self._run_check(["<a ", "b='<'>"], output)
|
||||||
|
@ -192,7 +198,7 @@ text
|
||||||
self._run_check(["<a b='>", "'>"], output)
|
self._run_check(["<a b='>", "'>"], output)
|
||||||
self._run_check(["<a b='>'", ">"], output)
|
self._run_check(["<a b='>'", ">"], output)
|
||||||
|
|
||||||
def check_starttag_junk_chars(self):
|
def test_starttag_junk_chars(self):
|
||||||
self._parse_error("<")
|
self._parse_error("<")
|
||||||
self._parse_error("<>")
|
self._parse_error("<>")
|
||||||
self._parse_error("</>")
|
self._parse_error("</>")
|
||||||
|
@ -212,10 +218,10 @@ text
|
||||||
self._parse_error("<a foo='>")
|
self._parse_error("<a foo='>")
|
||||||
self._parse_error("<a foo=>")
|
self._parse_error("<a foo=>")
|
||||||
|
|
||||||
def check_declaration_junk_chars(self):
|
def test_declaration_junk_chars(self):
|
||||||
self._parse_error("<!DOCTYPE foo $ >")
|
self._parse_error("<!DOCTYPE foo $ >")
|
||||||
|
|
||||||
def check_startendtag(self):
|
def test_startendtag(self):
|
||||||
self._run_check("<p/>", [
|
self._run_check("<p/>", [
|
||||||
("startendtag", "p", []),
|
("startendtag", "p", []),
|
||||||
])
|
])
|
||||||
|
@ -229,13 +235,13 @@ text
|
||||||
("endtag", "p"),
|
("endtag", "p"),
|
||||||
])
|
])
|
||||||
|
|
||||||
def check_get_starttag_text(self):
|
def test_get_starttag_text(self):
|
||||||
s = """<foo:bar \n one="1"\ttwo=2 >"""
|
s = """<foo:bar \n one="1"\ttwo=2 >"""
|
||||||
self._run_check_extra(s, [
|
self._run_check_extra(s, [
|
||||||
("starttag", "foo:bar", [("one", "1"), ("two", "2")]),
|
("starttag", "foo:bar", [("one", "1"), ("two", "2")]),
|
||||||
("starttag_text", s)])
|
("starttag_text", s)])
|
||||||
|
|
||||||
def check_cdata_content(self):
|
def test_cdata_content(self):
|
||||||
s = """<script> <!-- not a comment --> ¬-an-entity-ref; </script>"""
|
s = """<script> <!-- not a comment --> ¬-an-entity-ref; </script>"""
|
||||||
self._run_check(s, [
|
self._run_check(s, [
|
||||||
("starttag", "script", []),
|
("starttag", "script", []),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue