# Copyright (C) 2004-2012 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., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. """ Test html parsing. """ from linkcheck.htmlutil import htmlsoup from io import StringIO import pytest from .htmllib import pretty_print_html # list of tuples # (, ) parsetests = [ # start tags ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""<>""", """"""), ("""< >""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), # multiple attribute names should be ignored... ("""""", """"""), # ... but which one wins - in our implementation the last one ("""""", """"""), # reduce test ("""<""", """<"""), # numbers in tag ("""

bla

""", """

bla

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

""", """

"""), # start and end tag (HTML doctype assumed) ("""
""", """"""), ("""""", """"""), ("""""", """"""), # line continuation (Dr. Fun webpage) ("""""", """"""), ("""""", """"""), ("""""", """"""), # href with $ ("""""", """"""), # quoting ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ( """""", """""", ), ( """""", """""", ), # entity resolving ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), ("""""", """"""), # note that \u8156 is not valid encoding and therefore gets removed ("""""", """"""), # mailto link ( """1""", """1""", ), # meta tag with charset encoding ( """""", """""", ), ( """""", """""", ), ( """""", """""", ), ( """""", """""", ), ( """""", """""", ), # missing > in end tag ("""""", """"""), ("""""", """"""), # missing beginning quote ("""""", """"""), # stray < before start tag ("""<0.""", """"""), # HTML5 tags ("""