ó {G_Tc@sÊddlZddlZddlZddlmZejddeƒZdejfd„ƒYZ de fd„ƒYZ d e fd „ƒYZ d ej fd „ƒYZ d „ZedkrÆeƒndS(iÿÿÿÿN(t test_supporttsgmllibt deprecatedtEventCollectorcBskeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z d „Z d „Z RS( cCs,g|_|jj|_tjj|ƒdS(N(teventstappendRt SGMLParsert__init__(tself((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR s cCs‰g}d}xm|jD]b}|d}||ko=dknred|dd|df|dstHTMLEntityCollectorcBsDeZejdƒZd„Zd„Zd„Zd„Zd„Z RS(s:(?:&([a-zA-Z][-.a-zA-Z0-9]*)|&#(x[0-9a-zA-Z]+|[0-9]+))(;?)cCs:|jdd|fƒ|ddkr6tj||ƒSdS(NRtconvertitx(RRtconvert_charref(Rtname((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR+IscCs*|jdd|fƒtj||ƒdS(Nt codepointR)(RRtconvert_codepoint(RR-((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR.NscCs&|jdd|fƒtj||ƒS(NRR)(RRtconvert_entityref(RR,((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR/RscCs*|jd|fƒtjj||ƒdS(NR(RRRR(RR ((s-/usr/local/lib/python2.7/test/test_sgmllib.pyRZscCs*|jd|fƒtjj||ƒdS(NR(RRRR(RR ((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR^s( R"R#tretcompiletentity_or_charrefR+R.R/RR(((s-/usr/local/lib/python2.7/test/test_sgmllib.pyR(Ds     tSGMLParserTestCasecBseZeZd„Zd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d „Zd „Zd „Zd „Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!RS(cCsO|jƒ}y,x|D]}|j|ƒqW|jƒWn ‚nX|jƒS(N(t collectortfeedtcloseR(Rtsourcetparserts((s-/usr/local/lib/python2.7/test/test_sgmllib.pyRgs  cCs^y|j|ƒ}Wn ‚nX||krZ|jdtj|ƒdtj|ƒƒndS(Ns8received events did not match expected events Expected: s Received: (Rtfailtpprinttpformat(RR7texpected_eventsR((s-/usr/local/lib/python2.7/test/test_sgmllib.pyt check_eventsrs cCsetƒ}y|j|ƒ|jƒWntjk r:n'X|jd|tj|jƒƒfƒdS(Ns+expected SGMLParseError for %r Received: %s( RR5R6RtSGMLParseErrorR:R;R<R(RR7R8((s-/usr/local/lib/python2.7/test/test_sgmllib.pytcheck_parse_error~s   cCs*d}|jd|gd|fgƒdS(NsòDOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN' SYSTEM 'http://www.w3.org/TR/html401/strict.dtd' [ %paramEntity; ]sR(R>(Rtinside((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_doctype_decl_internal‰scCs'd}|jd|d|fgƒdS(Ns/DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01//EN'sR(R>(RRA((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_doctype_decl_externalœs cCs&|jdddddgfgƒdS( s7Make sure attribute names with underscores are acceptedsRtat has_undert_underN(RERE(RFRF(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_underscore_in_attrname¢s  cCs#|jdddgfdgƒdS(s1Make sure tag names with underscores are acceptedsRRERN(sendtags has_under(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_underscore_in_tagnameªs  cCs#|jddddgfgƒdS(s@Be sure quotes in unquoted attributes are made part of the valuesRRDthrefs foo'bar"bazN(RIs foo'bar"baz(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_quotes_in_unquoted_attrs²s cCs2|jdddgfd ddgfd gƒdS( s(Handling of XHTML-style empty start tagss
textRtbrR ttexttiRN(sdatastext(sendtagRM(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_xhtml_empty_tag¹s    cCs|jddgƒdS(NsRsprocessing instruction(spisprocessing instruction(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyt test_processing_instruction_onlyÂs cCs2|jdddgfddgfddgƒdS(Ns
RRDtbR(sendtagRD(sendtagRP(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_bad_nestingÇs    cCs|jddgƒdS(Ns#this text & contains & ampersands &R (sdatas#this text & contains & ampersands &(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_bare_ampersandsÏs cCs|jddgƒdS(Ns.this < text > contains < bare>pointy< bracketsR (sdatas.this < text > contains < bare>pointy< brackets(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_bare_pointy_bracketsÔs cCsbddd d ddgfg}|jd|ƒ|jd |ƒ|jd |ƒ|jd |ƒdS(NRRDRPtvtctdtessss(RPRT(RURT(RVRT(RWRW(R>(Rtoutput((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_attr_syntaxÙs cCs¸|jddddddgfgƒ|jd ddddgfgƒd }d }d}d|||f}|jd|ddd|fgfgƒ|jddddgfgƒdS(Ns'RRDRPsxxx xxxRUsyyy yyyRVs xyz s ts$-_.+s!*'(),s;/?:@&=s+http://example.com:8080/path/to/file?%s%s%ssRWss rgb(1,2,3)(RPsxxx xxx(RUsyyy yyy(RVs xyz (RPRZ(RURZ(RDs rgb(1,2,3)(R>(Rtsafetextratreservedturl((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_attr_valuesâs     cCs>|jdddddddddddd d!g fgƒdS("s9Substitution of entities and charrefs in attribute valuessÙRRDRPtRVs<->RWs< tfs&xxx;tgs !thsǴRMs x?a=b&c=d;tjs*tkN(RPR`(RUs<>(RVs<->(RWs< (Ras&xxx;(Rbs !(RcsǴ(RMs x?a=b&c=d;(Rds*(Res*(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_attr_values_entitiesùs cCsGt|_|jddddddgfdddddddg ƒdS(Ns3foo&foobar;*RR)tldquoRtx201dRRDttitles“test”R tfooRtfoobart42R-i*(s entityrefsconvertRg(scharrefsconvertRh(stitles“test”(sdataRj(sendtagRD(s entityrefRk(s entityrefsconvertRk(scharrefRl(scharrefsconvertRl(s codepointsconverti*(R(R4R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_convert_overrides s  cCs)|jddddd d gfgƒdS( NsRRDsa.bRTsc:dse-f(sa.bRT(sc:dRT(se-fRT(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_attr_funky_names s cCs2|jddddgfdddgfgƒdS(NsRRRDRIshttp://[1080::8:800:200C:417A]/(shrefshttp://[1080::8:800:200C:417A]/(shrefshttp://[1080::8:800:200C:417A]/(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_attr_value_ip6_url%s cCsK|jdddgfddgfgƒ|jddddgfgƒdS(NsRRDsR(sendtagRD(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_weird_starttags-s    cCs|jdƒdS(Ns(R@(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_declaration_junk_chars7scCs,d}|j|dddd gfgƒdS( NsRRktonet1ttwot2(RrRs(RtRu(R>(RR9((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_get_starttag_text:s c Csud}t|_|j|ddgfd dddgfddddgƒd }|j|ddgfddgƒdS(Nsb ¬-an-entity-ref; RR%R s, ¬-an-entity-ref; Rtnotcdatat Rs comment s$ s (sdatas, ¬-an-entity-ref; (sendtagscdata(sdataRx(scomments comment (sdataRx(sendtagRw(sdatas (sendtagscdata(R$R4R>(RR9((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_cdata_content@s        cCs#d}|j|ddd gƒdS( Ns(abcdefR tabcs unknown declsspacer type="block" height="25"tdef(sdatasabc(s unknown declsspacer type="block" height="25"(sdataR{(R>(RR9((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_illegal_declarationsUs  cCsd}|j|dgƒdS(Ns-]>Rs*DOCTYPE doc [](sdecls*DOCTYPE doc [](R>(RR9((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_enumerated_attr_type]s cCscd}ttjdƒƒ}tjƒ}x5|j|ƒ}|j|ƒt|ƒ|kr*Pq*q*dS(Nissgml_input.html(topenRtfindfileRRtreadR5tlen(RtCHUNKRatfpR ((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_read_chunkscs  cCs/d}|j|ddd d d gfgƒdS( Ns@Rtsignst exclamationt!t copyrights©t quotelefts‘(R†R‡(s copyrights©(R‰s‘(R>(RR9((s-/usr/local/lib/python2.7/test/test_sgmllib.pyttest_only_decode_asciips  cCsB|jddddgfgƒ|jdddd gfgƒdS( Ns RRDRPR`s t>(RPR`(RPR‹(R>(R((s-/usr/local/lib/python2.7/test/test_sgmllib.pyt_test_starttag_end_boundary~scCs+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(-NRRDRPR`s ssssssb='>'>s='>'>s'>'>s'RRzRZs s !--abc-->sssssss