@@ -323,6 +323,23 @@ def get_events(self):
323323 ("endtag" , element_lower )],
324324 collector = Collector ())
325325
326+ def test_comments (self ):
327+ html = ("<!-- I'm a valid comment -->"
328+ '<!--me too!-->'
329+ '<!------>'
330+ '<!---->'
331+ '<!----I have many hyphens---->'
332+ '<!-- I have a > in the middle -->'
333+ '<!-- and I have -- in the middle! -->' )
334+ expected = [('comment' , " I'm a valid comment " ),
335+ ('comment' , 'me too!' ),
336+ ('comment' , '--' ),
337+ ('comment' , '' ),
338+ ('comment' , '--I have many hyphens--' ),
339+ ('comment' , ' I have a > in the middle ' ),
340+ ('comment' , ' and I have -- in the middle! ' )]
341+ self ._run_check (html , expected )
342+
326343 def test_condcoms (self ):
327344 html = ('<!--[if IE & !(lte IE 8)]>aren\' t<![endif]-->'
328345 '<!--[if IE 8]>condcoms<![endif]-->'
@@ -426,6 +443,19 @@ def test_unescape_function(self):
426443 # see #12888
427444 self .assertEqual (p .unescape ('{ ' * 1050 ), '{ ' * 1050 )
428445
446+ def test_broken_comments (self ):
447+ html = ('<! not really a comment >'
448+ '<! not a comment either -->'
449+ '<! -- close enough -->'
450+ '<!!! another bogus comment !!!>' )
451+ expected = [
452+ ('comment' , ' not really a comment ' ),
453+ ('comment' , ' not a comment either --' ),
454+ ('comment' , ' -- close enough --' ),
455+ ('comment' , '!! another bogus comment !!!' ),
456+ ]
457+ self ._run_check (html , expected )
458+
429459 def test_broken_condcoms (self ):
430460 # these condcoms are missing the '--' after '<!' and before the '>'
431461 html = ('<![if !(IE)]>broken condcom<![endif]>'
0 commit comments