# -*- coding: iso-8859-1 -*- # Copyright (C) 2004-2005 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ Test html parsing. """ import linkcheck.HtmlParser import linkcheck.HtmlParser.htmlsax import linkcheck.HtmlParser.htmllib import cStringIO as StringIO import unittest # list of tuples (, ) parsetests = [ # start tags ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""< a>""", """"""), ("""< a >""", """"""), ("""<>""", """<>"""), ("""< >""", """< >"""), # reduce test ("""<""", """<"""), ("""d>""", """d>"""), # numbers in tag ("""

bla

""", """

bla

"""), # more start tags ("""
""", """"""), ("""""", """"""), ("""
""", """
"""), ("""
""", """
"""), ("""
""", """

"""), # comments ("""< 1>""", """<1>"""), ("""< 2>""", """<2>"""), ("""< 3>""", """<3>"""), ("""< 4>""", """<4>"""), ("""< 5>""", """<5>"""), ("""<6>"""), ("""< 7>""", """<7>"""), ("""<8>"""), ("""""", """"""), ("""< 9>""", """<9>"""), ("""< 10>""", """<10>"""), # end tags ("""
""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""< / a>""", """"""), ("""< /a>""", """"""), # missing > in end tag ("""""", """"""), # start and end tag (HTML doctype assumed) ("""""", """"""), ("""""", """"""), ("""""", """"""), # declaration tags ("""""", """"""), # misc ("""""", """"""), # javascript ("""""", """"""), ("""""", """"""), # line continuation (Dr. Fun webpage) ("", """"""), # href with $ ("""""", """"""), # quoting ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), # entity resolving ("""""", """"""), # non-ascii characters ("""<Üzgür> fahr ¹²³¼½¬{""", """<Üzgür> fahr ¹²³¼½¬{"""), # mailto link ("""1""", """1"""), # doctype XHTML ("""""", """"""), ] flushtests = [ ("<", "<"), ("