{G_Tc@sdZddlZddlZddlZddlmZdejfdYZdefdYZdejfd YZ d e fd YZ d e fd YZ dZ e dkre ndS(sTests for HTMLParser.py.iN(t test_supporttEventCollectorcBsteZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z RS( cCs,g|_|jj|_tjj|dS(N(teventstappendt HTMLParsert__init__(tself((s0/usr/local/lib/python2.7/test/test_htmlparser.pyR s cCsg}d}xm|jD]b}|d}||ko=dknred|dd|df|ds(t__name__t __module__RR RRRRRRRRR R!(((s0/usr/local/lib/python2.7/test/test_htmlparser.pyR s           tEventCollectorExtracBseZdZRS(cCs0tj||||jd|jfdS(Nt starttag_text(RRRtget_starttag_text(RRR((s0/usr/local/lib/python2.7/test/test_htmlparser.pyRDs(R"R#R(((s0/usr/local/lib/python2.7/test/test_htmlparser.pyR$Bst TestCaseBasecBs&eZedZdZdZRS(cCs{|}x|D]}|j|qW|j|j}||krw|jdtj|dtj|ndS(Ns8received events did not match expected events Expected: s Received: (tfeedtcloseR tfailtpprinttpformat(Rtsourcetexpected_eventst collectortparsertsR((s0/usr/local/lib/python2.7/test/test_htmlparser.pyt _run_checkKs     cCs|j||tdS(N(R2R$(RR-R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyt_run_check_extraVscCs#|d}|jtj|dS(NcSs'tj}|j||jdS(N(RR(R)(R-R0((s0/usr/local/lib/python2.7/test/test_htmlparser.pytparseZs  (t assertRaisesRtHTMLParseError(RR-R4((s0/usr/local/lib/python2.7/test/test_htmlparser.pyt _parse_errorYs (R"R#RR2R3R7(((s0/usr/local/lib/python2.7/test/test_htmlparser.pyR'Is tHTMLParserTestCasecBseZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZdZdZdZRS(cCs*|jddg|jddgdS(NsRsprocessing instructionssprocessing instruction ?(spisprocessing instruction(spisprocessing instruction ?(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyt test_processing_instruction_onlycs   cCs_|jddddddgfdddddddddgfd d!d"d#d$d%d&gdS('Ns &entity; sample text “ Rs RsDOCTYPE html PUBLIC 'foo'RthtmlRtentityRt32Rs4comment1a -><<R?(R@N(sdatas sample text (scharrefRA(sdatas (scommentscomment2a-- --comment2b(sdatas (sendtagshtml(sdatas (R2R(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_simple_htmlks&  cCs|jdddgdS(Ns&entityref fooRRs foo(s entityrefs entityref(sdatas foo(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_unclosed_entityrefs cCs2|jdddgfddgfddgdS(NsRtatbR(sendtagRD(sendtagRE(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_bad_nestings    cCs|jddgdS(Ns#this text & contains & ampersands &R(sdatas#this text & contains & ampersands &(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_bare_ampersandss cCs|jddgdS(Ns.this < text > contains < bare>pointy< bracketsR(sdatas.this < text > contains < bare>pointy< brackets(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_bare_pointy_bracketss cCs|jddgdS(Ns"Rsspacer type="block" height="25"(scommentsspacer type="block" height="25"(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_illegal_declarationss cCsB|jddddgfg|jdddd gfgdS( Ns RRDREtt>(RERJ(RERK(R2(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_starttag_end_boundaryscCs+ddd*gfg}|jdg||jddg||jdd g||jd d g||jd d g||jddg|ddd+gfg}|jdg||jddg||jddg||jd dg||jdd g||jddg|d,g}|jddg||jddg||jddg||jddg||jdd g||jd!d"g||jd#d$g||jd%d&g||jd'd(g||jd)dg||jddg|dS(-NRRDRERJs ssssssb='>'>s='>'>s'>'>s'Rtabcts s !--abc-->sssssss ¬-an-entity-ref;ss

sfoo = "";sfoo = "";sfoo = < /script> s*s //<\/s'+'cript>'); //]]>s sfoo = "";u tscripttstyletSCRIPTtSTYLEtScripttStyleu <{element}>{content}telementtcontentRRR(tlowertformatR2(RtcontentstelementsRzRyt element_lowerR1((s0/usr/local/lib/python2.7/test/test_htmlparser.pyttest_cdata_contentSs(      cCsdtfdY}d}xfdddddd gD]L}d jd |d |}|j|d dgfd|fdgd|q5WdS(Nt CollectorcBseZdZRS(cSs|jS(N(R(R((s0/usr/local/lib/python2.7/test/test_htmlparser.pyR xs(R"R#R (((s0/usr/local/lib/python2.7/test/test_htmlparser.pyRwss ¬-an-entity-ref;

& '' !s scriptsscript s script s scriptsscript s script u