def test_getMetaInfo(self): "encutils.getMetaInfo" tests = { """<meta tp-equiv='Content-Type' content='text/html; charset=ascii'>""": (None, None), """<meta http-equiv='ontent-Type' content='text/html; charset=ascii'>""": (None, None), """<meta http-equiv='Content-Type' content='text/html'>""": ('text/html', None), """<meta content='text/html' http-equiv='Content-Type'>""": ('text/html', None), """<meta content='text/html;charset=ascii' http-equiv='Content-Type'>""": ('text/html', 'ascii'), """<meta http-equiv='Content-Type' content='text/html ;charset=ascii'>""": ('text/html', 'ascii'), """<meta content='text/html;charset=iso-8859-1' http-equiv='Content-Type'>""": ('text/html', 'iso-8859-1'), """<meta http-equiv="Content-Type" content="text/html;charset = ascii">""": ('text/html', 'ascii'), """<meta http-equiv="Content-Type" content="text/html;charset=ascii;x=2">""": ('text/html', 'ascii'), """<meta http-equiv="Content-Type" content="text/html;x=2;charset=ascii">""": ('text/html', 'ascii'), """<meta http-equiv="Content-Type" content="text/html;x=2;charset=ascii;y=2">""": ('text/html', 'ascii'), """<meta http-equiv='Content-Type' content="text/html;charset=ascii">""": ('text/html', 'ascii'), """<meta http-equiv='Content-Type' content='text/html;charset=ascii' />""": ('text/html', 'ascii'), """<meta http-equiv = " Content-Type" content = " text/html;charset=ascii " >""": ('text/html', 'ascii'), """<meta http-equiv = " \n Content-Type " content = " \t text/html ; charset=ascii " >""": ('text/html', 'ascii'), """<meta content="text/html;charset=ascii" http-equiv="Content-Type">""": ('text/html', 'ascii'), """<meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ('text/html', 'ascii'), """raises exception: </ >""": (None, None), """<meta content="text/html;charset=ascii" http-equiv="cONTENT-type"> </ >""": ('text/html', 'ascii'), """</ > <meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ('text/html', 'ascii'), # py 2.7.3 fixed HTMLParser so: (None, None) """<meta content="text/html" http-equiv="cONTENT-type"> </ > <meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ('text/html', None) } for test, exp in list(tests.items()): self.assertEqual(exp, encutils.getMetaInfo(test, log=log))
def test_getMetaInfo(self): "encutils.getMetaInfo" tests = { """<meta tp-equiv='Content-Type' content='text/html; charset=ascii'>""": (None, None), """<meta http-equiv='ontent-Type' content='text/html; charset=ascii'>""": (None, None), """<meta http-equiv='Content-Type' content='text/html'>""": ("text/html", None), """<meta content='text/html' http-equiv='Content-Type'>""": ("text/html", None), """<meta content='text/html;charset=ascii' http-equiv='Content-Type'>""": ("text/html", "ascii"), """<meta http-equiv='Content-Type' content='text/html ;charset=ascii'>""": ("text/html", "ascii"), """<meta content='text/html;charset=iso-8859-1' http-equiv='Content-Type'>""": ("text/html", "iso-8859-1"), """<meta http-equiv="Content-Type" content="text/html;charset = ascii">""": ("text/html", "ascii"), """<meta http-equiv="Content-Type" content="text/html;charset=ascii;x=2">""": ("text/html", "ascii"), """<meta http-equiv="Content-Type" content="text/html;x=2;charset=ascii">""": ("text/html", "ascii"), """<meta http-equiv="Content-Type" content="text/html;x=2;charset=ascii;y=2">""": ("text/html", "ascii"), """<meta http-equiv='Content-Type' content="text/html;charset=ascii">""": ("text/html", "ascii"), """<meta http-equiv='Content-Type' content='text/html;charset=ascii' />""": ("text/html", "ascii"), """<meta http-equiv = " Content-Type" content = " text/html;charset=ascii " >""": ("text/html", "ascii"), """<meta http-equiv = " \n Content-Type " content = " \t text/html ; charset=ascii " >""": ( "text/html", "ascii", ), """<meta content="text/html;charset=ascii" http-equiv="Content-Type">""": ("text/html", "ascii"), """<meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ("text/html", "ascii"), """raises exception: </ >""": (None, None), """<meta content="text/html;charset=ascii" http-equiv="cONTENT-type"> </ >""": ( "text/html", "ascii", ), """</ > <meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ( None, None, ), """<meta content="text/html" http-equiv="cONTENT-type"> </ > <meta content="text/html;charset=ascii" http-equiv="cONTENT-type">""": ( "text/html", None, ), } for test, exp in tests.items(): self.assertEqual(exp, encutils.getMetaInfo(test, log=log))