Skip to content

Commit 7450a97

Browse files
Apply suggestions from code review
1 parent 4fb2241 commit 7450a97

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Lib/test/test_htmlparser.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -539,13 +539,19 @@ def test_EOF_in_charref(self):
539539
for html, expected in data:
540540
self._run_check(html, expected)
541541

542-
def test_unescape_method(self):
543-
from html import unescape
544-
p = self.get_collector()
545-
with self.assertWarns(DeprecationWarning):
546-
s = '"""&quot&#34&#x22&#bad;'
547-
self.assertEqual(p.unescape(s), unescape(s))
548-
542+
def test_EOF_in_comments_or_decls(self):
543+
data = [
544+
('<!', [('data', '<!')]),
545+
('<!-', [('data', '<!-')]),
546+
('<!--', [('data', '<!--')]),
547+
('<![', [('data', '<![')]),
548+
('<![CDATA[', [('data', '<![CDATA[')]),
549+
('<![CDATA[x', [('data', '<![CDATA[x')]),
550+
('<!DOCTYPE', [('data', '<!DOCTYPE')]),
551+
('<!DOCTYPE HTML', [('data', '<!DOCTYPE HTML')]),
552+
]
553+
for html, expected in data:
554+
self._run_check(html, expected)
549555
def test_bogus_comments(self):
550556
html = ('<! not really a comment >'
551557
'<! not a comment either -->'
@@ -556,7 +562,10 @@ def test_bogus_comments(self):
556562
'<![with square brackets]!>'
557563
'<![\nmultiline\nbogusness\n]!>'
558564
'<![more brackets]-[and a hyphen]!>'
559-
'<![cdata[should be uppercase]]>')
565+
'<![cdata[should be uppercase]]>'
566+
'<![CDATA [whitespaces are not ignored]]>'
567+
'<![CDATA]]>' # required '[' after CDATA
568+
)
560569
expected = [
561570
('comment', ' not really a comment '),
562571
('comment', ' not a comment either --'),
@@ -568,6 +577,8 @@ def test_bogus_comments(self):
568577
('comment', '[\nmultiline\nbogusness\n]!'),
569578
('comment', '[more brackets]-[and a hyphen]!'),
570579
('comment', '[cdata[should be uppercase]]'),
580+
('comment', '[CDATA [whitespaces are not ignored]]'),
581+
('comment', '[CDATA]]'),
571582
]
572583
self._run_check(html, expected)
573584

0 commit comments

Comments
 (0)