Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_htmlparser.cpython-310.pyc

o

0�i���@s�dZddlZddlZddlZddlmZdZedZGdd�dej	j
�ZGdd	�d	e�ZGd
d�de�Z
Gdd
�d
e�ZGdd�dej�ZGdd�de�ZGdd�de�Zedkr_e��dSdS)zTests for HTMLParser.py.�N)�supportuo<!-- not a comment --><not a='start tag'><![CDATA[not a cdata]]><!not a bogus comment></not a bogus comment>☃z&amp;&#9786;c@sreZdZdd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EventCollectorF��	autocdatacOsH||_g|_|jj|_tjjj|g|�Ri|��|r"|�d�dSdS)NF)r�events�append�html�parser�
HTMLParser�__init__�_set_support_cdata)�selfr�args�kw�r�;/opt/alt/python310/lib64/python3.10/test/test_htmlparser.pyrs
�zEventCollector.__init__cCsjg}d}|jD](}|d}||krdkr(nnd|dd|df|d<n|�|�|}q||_|S)Nr�data����)rr)r
�LZprevtypeZevent�typerrr�
get_events s

zEventCollector.get_eventscCs4|�d||f�|jr|dkr|�d�dSdSdS)N�starttag�svgT�rrr�r
�tagZattrsrrr�handle_starttag1s�zEventCollector.handle_starttagcCs|�d||f�dS)N�startendtag�rrrrr�handle_startendtag6sz!EventCollector.handle_startendtagcCs2|�d|f�|jr|dkr|�d�dSdSdS)N�endtagrFr)r
rrrr�
handle_endtag9s�zEventCollector.handle_endtagcC�|�d|f�dS)N�commentr�r
rrrr�handle_comment@�zEventCollector.handle_commentcCr#)N�charrefrr%rrr�handle_charrefCr'zEventCollector.handle_charrefcCr#)Nrrr%rrr�handle_dataFr'zEventCollector.handle_datacCr#)N�declrr%rrr�handle_declIr'zEventCollector.handle_declcCr#)N�	entityrefrr%rrr�handle_entityrefLr'zEventCollector.handle_entityrefcCr#)N�pirr%rrr�	handle_piOr'zEventCollector.handle_picCr#)N�unknown declr)r
r+rrr�unknown_declRr'zEventCollector.unknown_declN)�__name__�
__module__�__qualname__rrrr r"r&r)r*r,r.r0r2rrrrrsrc@�eZdZdd�ZdS)�EventCollectorExtracCs$t�|||�|�d|��f�dS)N�
starttag_text)rrrZget_starttag_textrrrrrXsz#EventCollectorExtra.handle_starttagN)r3r4r5rrrrrr7Vsr7c@seZdZdd�Zdd�ZdS)�EventCollectorCharrefscC�|�d�dS�Nz6This should never be called with convert_charrefs=True��failr%rrrr)_�z%EventCollectorCharrefs.handle_charrefcCr:r;r<r%rrrr.br>z'EventCollectorCharrefs.handle_entityrefN)r3r4r5r)r.rrrrr9]sr9c@r6)�EventCollectorNoNormalizecCs|jS�N)r�r
rrrrisz$EventCollectorNoNormalize.get_eventsN)r3r4r5rrrrrr?hsr?c@s&eZdZdd�Zddd�Zdd�ZdS)	�TestCaseBasecCs
tdd�S�NF��convert_charrefs)rrArrr�
get_collectoros
zTestCaseBase.get_collectorNcCsv|dur|��}|}|D]}|�|�q|��|��}||kr9|�dt|�dt�|�dt�|��dSdS)Nz6received events did not match expected events
Source:
z
Expected:
z
Received:
)rF�feed�closerr=�repr�pprintZpformat)r
�sourceZexpected_events�	collectorr	�srrrr�
_run_checkrs(����
��zTestCaseBase._run_checkcCs|�||tdd��dSrC)rNr7)r
rKrrrr�_run_check_extra�s�zTestCaseBase._run_check_extrar@)r3r4r5rFrNrOrrrrrBms
rBc@sFeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�dgd��dd��Ze�dgd��dd��Ze�d d!d"g�d#d$��Ze�d gd%��d&d'��Zd(d)�Zd*d+�Ze�d,gd-��d.d/��Ze�d gd0��d1d2��Ze�d gd0��d3d4��Ze�d5gd6��d7d8��Ze�d9gd:��d;d<��Ze�d9gd=��d>d?��Zd@dA�ZdBdC�ZdDdE�ZdFdG�Z dHdI�Z!dJdK�Z"dLdM�Z#dNdO�Z$dPdQ�Z%dRdS�Z&dTdU�Z'dVdW�Z(dXdY�Z)dZd[�Z*d\d]�Z+e�dgd^��d_d`��Z,dadb�Z-dcdd�Z.e�dgde��dfdg��Z/dhdi�Z0djdk�Z1e�2dl�dmdn��Z3doS)p�HTMLParserTestCasecCs |�ddg�|�ddg�dS)Nz<?processing instruction>)r/zprocessing instructionz<?processing instruction ?>)r/zprocessing instruction ?�rNrArrr� test_processing_instruction_only�s�
�z3HTMLParserTestCase.test_processing_instruction_onlycCsB|�ddddddgfddddddd	d
dgfdd
dddddg�dS)Nz�
<!DOCTYPE html PUBLIC 'foo'>
<HTML>&entity;&#32;
<!--comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b-->
<Img sRc='Bar' isMAP>sample
text
&#x201C;
<!--comment2a-- --comment2b-->
</Html>
�r�
)r+zDOCTYPE html PUBLIC 'foo'rr)r-�entity)r(Z32)r$z4comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b�img)�srcZBar)ZismapN)rzsample
text
)r(Zx201C)r$zcomment2a-- --comment2b�r!rrQrArrr�test_simple_html�s(��z#HTMLParserTestCase.test_simple_htmlcCs6|�dddgfddg�|�dgddgfddg�dS)	Nz
<p>&#bad;</p>r�p)rz&#bad;�r!rZz<div>&#bad;</div>�div�r!r\rQrArrr�test_malformatted_charref�s�
�z,HTMLParserTestCase.test_malformatted_charrefcCs|�dddg�dS)Nz&entityref foo)r-r-)rz foorQrArrr�test_unclosed_entityref�s
�z*HTMLParserTestCase.test_unclosed_entityrefcCs$|�dddgfddgfddg�dS)Nz<a><b></a></b>r�a�b�r!r`�r!rarQrArrr�test_bad_nesting�s
�z#HTMLParserTestCase.test_bad_nestingcC�|�ddg�dS)N�#this text & contains & ampersands &)rrfrQrArrr�test_bare_ampersands��
�z'HTMLParserTestCase.test_bare_ampersandscCre)N�.this < text > contains < bare>pointy< brackets)rrirQrArrr�test_bare_pointy_brackets�rhz,HTMLParserTestCase.test_bare_pointy_bracketscCs0|�ddddgfg�|�ddddgfg�dS)N�	<a b='<'>rr`�ra�<�	<a b='>'>�ra�>rQrArrr�test_starttag_end_boundary�sz-HTMLParserTestCase.test_starttag_end_boundarycCs�dddgfg}|�dg|�|�ddg|�|�ddg|�|�d	d
g|�|�ddg|�|�d
dg|�dddgfg}|�dg|�|�ddg|�|�ddg|�|�d	dg|�|�ddg|�|�ddg|�dg}|�ddg|�|�ddg|�|�ddg|�|�ddg|�|�dd g|�|�d!d"g|�|�d#d$g|�|�d%d&g|�|�d'd(g|�|�d)dg|�|�ddg|�dS)*Nrr`rlrk�<a zb='<'>z<a bz='<'>z<a b=z'<'>z<a b='<z'>z<a b='<'rprornzb='>'>z='>'>z'>'>z<a b='>z<a b='>')r$�abc�z
<!--abc-->rmz	!--abc-->�<!z--abc-->�<!-z-abc-->�<!--zabc-->z<!--azbc-->z<!--abzc-->z<!--abcz-->z<!--abc-z->z	<!--abc--rQ�r
�outputrrr�test_buffer_artefacts�s4z(HTMLParserTestCase.test_buffer_artefactscCs0gd�}|D]}|�d|dd|fg�qdS)N)
ZHTMLzOHTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"z[HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"zbhtml PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"zfhtml PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"zYmath PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd"z�html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd"zWsvg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"z'html PUBLIC "-//IETF//DTD HTML 2.0//EN"z,html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"z
<!DOCTYPE %s>r+�DOCTYPE rQ)r
ZdtdsZdtdrrr�test_valid_doctypes�s
��z&HTMLParserTestCase.test_valid_doctypescCsN|�dddgfg�|�dddgfdg�|�dddgfddd	gfdg�dS)
Nz<p/>rrZz<p></p>rr[z<p><img src='foo' /></p>rV)rW�foorQrArrr�test_startendtags��

�z#HTMLParserTestCase.test_startendtagcCs&d}|�|ddddgfd|fg�dS)Nz <foo:bar   
   one="1"	two=2   >rzfoo:bar)Zone�1)Ztwo�2r8)rO)r
rMrrr�test_get_starttag_texts

�z)HTMLParserTestCase.test_get_starttag_text�content)
z*<!-- not a comment --> &not-an-entity-ref;�<not a='start tag'>z<a href="" /> <p> <span></span>zfoo = "</scr" + "ipt>";zfoo = "</SCRIPT" + ">";zfoo = <
/script> z*<!-- document.write("</scr" + "ipt>"); -->z�
//<![CDATA[
document.write('<s'+'cript type="text/javascript" src="http://www.example.org/r='+new Date().getTime()+'"><\/s'+'cript>');
//]]>z 
<!-- //
var foo = 3.14;
// -->
u<!-- ☃ -->cC�,d|�d�}|�|ddgfd|fdg�dS)Nz<script>z	</script>r�scriptr�r!r�rQ�r
r�rMrrr�test_script_content%s
�z&HTMLParserTestCase.test_script_content)z0a::before { content: "<!-- not a comment -->"; }z-a::before { content: "&not-an-entity-ref;"; }z-a::before { content: "<not a='start tag'>"; }ua::before { content: "☃"; }cCr�)Nz<style>z</style>r�styler�r!r�rQr�rrr�test_style_content<s

�z%HTMLParserTestCase.test_style_contentr�title�textareacCsjd|�dt�d|�d�}|�|d|gfdtfd|fg�d|�d|�d�}|�|d|gfdd|fg�dS)	Nrmrp�</rrr!z>&amp;</�r-Zamp)�
SAMPLE_RCDATArN�r
rrKrrr�test_rcdata_contentHs�
�z&HTMLParserTestCase.test_rcdata_content)r��xmp�iframe�noembed�noframesr�cCs<d|�dt�d|�d�}|�|d|gfdtfd|fg�dS)Nrmrpr�rrr!��SAMPLE_RAWTEXTrNr�rrr�test_rawtext_contentWs
�z'HTMLParserTestCase.test_rawtext_contentc
Csddt�d�}|�|ddgfddddgfdd	d
ddd
dg
�|j|ddgfdtfdgtdd�d�dS)Nz
<noscript>z</noscript>r�noscript)r$z not a comment �not)r`z	start tag)r1zCDATA[not a cdata)r$znot a bogus comment)r!r�)ru☃r�)r(Z9786)r!r�rT)�	scripting�rL)r�rNr)r
rKrrr�test_noscript_contentas(
�
�
�z(HTMLParserTestCase.test_noscript_contentcCs0td}d|��}|�|ddgfd|fg�dS)Nz</plaintext>z<plaintext>rZ	plaintextrr�)r
r�rKrrr�test_plaintext_contentws

�z)HTMLParserTestCase.test_plaintext_contentr!)r�ZSCRIPTzscript zscript
zscript/zscript foo=barzscript foo=">"cCs@d}d|�d|�d�}|j|ddgfd|fdgtd	d
�d�dS)Nz�<!-- not a comment --> &not-an-entity-ref;
                  <a href="" /> </p><p> <span></span></style>
                  '</script' + '>'�<ScrIPt>r�rprr�rr�FrDr��rNr?)r
r!r�rMrrr�test_script_closing_tags�
�z*HTMLParserTestCase.test_script_closing_tag)	r�r�r�r�r�r�r�r�r�cCs�||��|�d�|�d�|�d�|�d�|�d�fD](}d}d|���d|�d	|�d�}|j|d
|gfd|fd|fgtd
dd�d�qdS)N� rT�/z foo=barz foo=">"z!<!-- not a comment --><i>Spam</i>rmrpr�rrr!FT�rEr�r�)�upperrNr?)r
rr!r�rMrrr�test_closing_tag�s��
��z#HTMLParserTestCase.test_closing_tagcCsld|�d|�d|�d|�d|�d�}d|�d|�d	|�d�}|j|d
|gfd|fd|fgtd
dd�d�dS)Nz< /z></ z></zx></z></u >rmrpr�rrr!FTr�r��rNr)r
rr�rKrrr�test_invalid_closing_tag�s$������

�z+HTMLParserTestCase.test_invalid_closing_tagz
tag,endtag)
)r�utıtle)r�uſtyle)r�uſtyle)r�ustyle)r�uıframe)r�u	noframeſ)r�u	noſcript)r�u	noscrıpt)r�uſcript)r�uscrıptcCs�d|�d�}d|�d|��}|j|d|gfd|fgtddd�d	�d|�d|�d
|�d�}|j|d|gfd|fd|fgtddd�d	�dS)Nz<br></rprmrrFTr�r�r�r!r�)r
rr!r�rKrrr�!test_invalid_nonascii_closing_tag�s 
�
��

�z4HTMLParserTestCase.test_invalid_nonascii_closing_tagztail,end)�rtF�rmF�r�F)z</sF)z</scriptF)z	</script T)z</script foo=barT)z</script foo=">TcCsFd}d|�|��}|j|ddgfd|r|n||fgtdd�d�dS)	Nza = 123r�rr�rFrDr�r�)r
�tail�endr�rMrrr�test_eof_in_script�s�
�z%HTMLParserTestCase.test_eof_in_script)r�r�r�)z</tF)z</titleF)z</title T)z</title foo=barT)z</title foo=">TcCsrd|��}|j|ddgfdd|rdn|fgtdd�d	�|j|ddgfd
ddd|r,dn|fgtd
d�d	�dS)Nz<TitLe>Egg &amp; Spamrr�rz
Egg & SpamrtTrDr�)rzEgg r�z SpamFr�)r
r�r�rMrrr�test_eof_in_title�s
���
�z$HTMLParserTestCase.test_eof_in_titlecC�d}gd�}|�||�dS)Na.<!-- I'm a valid comment --><!--me too!--><!------><!-----><!----><!---><!--><!----I have many hyphens----><!-- I have a > in the middle --><!-- and I have -- in the middle! --><!--incorrectly-closed-comment--!><!----!><!----!--><!---- >--><!---!>--><!--!>--><!-- <!-- nested --> --><!--<!--><!--<!--!>))r$z I'm a valid comment )r$zme too!�r$z--�r$�-�r$rtr�r�)r$z--I have many hyphens--)r$z I have a > in the middle )r$z and I have -- in the middle! )r$zincorrectly-closed-commentr�)r$z--!)r$z-- >�r$z-!>)r$z!>)r$z
 <!-- nested )rz -->�r$rur�rQ�r
r�expectedrrr�
test_comments�sz HTMLParserTestCase.test_commentscCr�)Nzs<!--[if IE & !(lte IE 8)]>aren't<![endif]--><!--[if IE 8]>condcoms<![endif]--><!--[if lte IE 7]>pretty?<![endif]-->))r$z%[if IE & !(lte IE 8)]>aren't<![endif])r$zf IE 8]>condcoms<![endif])r$z[if lte IE 7]>pretty?<![endif]rQr�rrr�
test_condcomssz HTMLParserTestCase.test_condcomsc
CsBdd�}|�|�j�gd�}dddgfddg}|D]}|jd	�|�||�d
�qdddgd�fdddg}|D]}|jd
�|�||�d
�q7|D],}d�|gd�}dddgfd|fddddgfd|fddg	}|jd�||�||�d
�qHd}tdt|��D]}|j|d|�d|d|�fg|�d
�q~|jddg|�d
�dS)NcSst�Sr@)r9rrrr�<lambda>'sz:HTMLParserTestCase.test_convert_charrefs.<locals>.<lambda>)z&quot;z&#34;z&#x22;z&quotz&#34z&#x22rr`)�hrefzfoo"zar)rza"zrbz<a href="foo{0}zar">a{0}z</a>r�)r�"))�xr�)�yz"X)�zzX"z*{0}<a x="{0}" y="{0}X" z="X{0}">{0}</a>{0}�X�r�rr�r�r�z/{1}<script>{0}</script>{1}<style>{0}</style>{1}z&quo &# &#xr�no charrefs here)rr�)Z
assertTruerErN�format�join�range�len)r
rLZcharrefsr�r(�textrr�rrr�test_convert_charrefs%sN
�������

�z(HTMLParserTestCase.test_convert_charrefsc
Cs.|�ddddgfdddddd	gfd
dg�dS)NzF<html <html>te>>xt&a<<bc</a></html>
<img src="URL><//img></html</html>rr)z<htmlN)rzte>>xt)r-r`�rrmzbc<)r`NrXrSrQrArrr�test_tolerant_parsingNs

��z(HTMLParserTestCase.test_tolerant_parsingcCsx|�ddg�|�ddg�|�ddg�|�ddg�|�d	g�|�d
dg�|�dd
g�|�ddg�|�dg�|�ddg�|�ddg�|�dddgfg�|�ddg�|�ddg�|�dg�|�dg�|�dg�|�dg�|�dg�|�d dd!gfg�|�d"dd#gfg�|�d$d%d#gfg�|�d&dd#gfg�|�d'd%d#gfg�|�d(d)g�dS)*Nrmr��<>)rr��< >)rr��< )rr�z</>�<$>)rr�z</$>)r$�$r�)rr�z</az</ a>)r$z az</ az<a<a>r�a<az</a<a>)r!r�rur�z<az<a foo='bar'z<a foo='barz
<a foo='>'z	<a foo='>z<a$>za$z<a$b>�a$bz<a$b/>rz<a$b  >z<a$b  />z</a$b>)r!r�rQrArrr�test_starttag_junk_charsYs2z+HTMLParserTestCase.test_starttag_junk_charsc
Cs�|�ddddgfg�d}ddgd�fg}|�||�d}ddgd	�fd
dgd	�fg}|�||�d}d
dgfd
dgfd
dgfd
dgfddgfddgfddgfddgfg}|�||�dS)
Nz<a foo="var"/>rr`)r}�varzj<img width=902 height=250px src="/sites/default/files/images/homepage/foo.jpg" /*what am I doing here*/ />rV))�widthZ902)ZheightZ250px)rWz,/sites/default/files/images/homepage/foo.jpg)z*whatN)ZamN)�iN)ZdoingN)zhere*Nz9<a / /foo/ / /=/ / /bar/ / /><a / /foo/ / /=/ / /bar/ / >))r}N)�=N)�barNrzD<meta><meta / ><meta // ><meta / / ><meta/><meta /><meta //><meta//>�metarQr�rrr�test_slashes_in_starttagts$���z+HTMLParserTestCase.test_slashes_in_starttagcCs |�ddg�|�ddg�dS)Nz</a/>rbz</a foo="var"/>rQrArrr�test_slashes_in_endtag�sz)HTMLParserTestCase.test_slashes_in_endtagcCre)Nz<!DOCTYPE foo $ >)r+zDOCTYPE foo $ rQrArrr�test_declaration_junk_chars�r'z.HTMLParserTestCase.test_declaration_junk_charscCre)Nz"<!spacer type="block" height="25">)r$zspacer type="block" height="25"rQrArrr�test_illegal_declarations�s�z,HTMLParserTestCase.test_illegal_declarationscCsZd}ddgfdddgfdddgfdddgfdddgfdddgfddgfg}|�||�dS)Nzn<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br></li class="unit"><br></li
						</ul><br></><br>r�br)r!zlabel<r])r$z<h4)r!ZlirQr�rrr�test_invalid_end_tags�s�z(HTMLParserTestCase.test_invalid_end_tagscCs&d}ddgfdddg}|�||�dS)Nz(<b>This</b attr=">"> confuses the parserrra)rZThisrc)rz confuses the parserrQr�rrr�test_broken_invalid_end_tag�s�z.HTMLParserTestCase.test_broken_invalid_end_tagcCs�d}dddgfddgfddddgfd	d
ddd
gfdddgfddddg}|�||�d}ddgd�fddgfddddgfd	d
g}|�||�dS)Nz[<div style=""    ><b>The <a href="some_url">rain</a> <br /> in <span>Spain</span></b></div>rr\�r�rtra)rzThe r`)r�Zsome_url)rZrainrb�rr�rr�)rz in �span)rZSpain�r!r�rcr]z><div style="", foo = "bar" ><b>The <a href="some_url">rain</a>)r���,N�r}r�rQr�rrr�$test_correct_detection_of_start_tags�s4

�
�z7HTMLParserTestCase.test_correct_detection_of_start_tagscCsFddgfddgfdgd�fddd	gfg}|D]
\}}|�||�qdS)
N�a&)rr�za&b)rZabza&b )�rr`�r-rar�za&b;r�r�rQ�r
rrr�rrr�test_EOF_in_charref�s

��z&HTMLParserTestCase.test_EOF_in_charrefcCs�ddgfddgfddgfddgfddgfd	dgfd
dgfdd
gfddgfddgfddgfddgfddgfddgfg}|D]
\}}|�||�q<dS)Nrwr�z<!---z<!----z<!-----r�z<!------r�z<!----!z<!---!)r$z-!z<!---!>r�z<!--foo)r$r}z<!--foo-z	<!--foo--z
<!--foo--!z<!--<!--r�z	<!--<!--!rQr�rrr�test_eof_in_comments�s$��z'HTMLParserTestCase.test_eof_in_commentscCsrddgfddgfddgfddgfd	d
gfddgfd
dgfddgfddgfddgfg
}|D]
\}}|�||�q,dS)Nrur�rvr�z<![)r$�[z	<!DOCTYPE)r+ZDOCTYPEz
<!DOCTYPE )r+r{z<!DOCTYPE html)r+zDOCTYPE htmlz<!DOCTYPE html )r+z
DOCTYPE html z<!DOCTYPE html PUBLIC)r+zDOCTYPE html PUBLICz<!DOCTYPE html PUBLIC "foo)r+zDOCTYPE html PUBLIC "fooz6<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foo)r+z4DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "foorQr�rrr�test_eof_in_declarationss ��
�z+HTMLParserTestCase.test_eof_in_declarations)rtr�zx]zx]]cCsn|�d|dd|fg�|jd|dd|fgtdd�d�|�d	|d
dgfd
dd
gfdd|fg�dS)Nz	<![CDATA[r1�CDATA[r$z[CDATA[Trr��<svg><text y="100"><![CDATA[rrr��r�Z100r�)r
r�rrr�test_eof_in_cdatas
�
�


��z$HTMLParserTestCase.test_eof_in_cdatacCr�)Nz�<!ELEMENT br EMPTY><! not really a comment ><! not a comment either --><! -- close enough --><!><!<-- this was an empty comment><!!! another bogus comment !!!>))r$zELEMENT br EMPTY)r$z not really a comment )r$z not a comment either --)r$z -- close enough --r�)r$z<-- this was an empty comment)r$z!! another bogus comment !!!rQr�rrr�test_bogus_comments s	z&HTMLParserTestCase.test_bogus_commentscCsXd}dddddddgfdd	dd
dgfddd
dgfdddddd
dgfdg}|�||�dS)Nz�<![if !(IE)]>broken condcom<![endif]><![if ! IE]><link href="favicon.tiff"/><![endif]><![if !IE 6]><img src="firefox.png" /><![endif]><![if !ie 6]><b>foo</b><![endif]><![if (!IE)|(lt IE 9)]><img src="mammoth.bmp" /><![endif]>)r1zif !(IE))rzbroken condcom)r1Zendif)r1zif ! IEr�link)r�zfavicon.tiff)r1zif !IE 6rV)rWzfirefox.png)r1zif !ie 6rra)rr}rc)r1zif (!IE)|(lt IE 9))rWzmammoth.bmprQr�rrr�test_broken_condcoms2s(


�z'HTMLParserTestCase.test_broken_condcoms)zjust some plain textz<!-- not a comment -->z&not-an-entity-ref;r�rtz[[I have many brackets]]zI have a > in the middlezI have a ]] in the middlez] ]>z]] >zN
    if (a < b && a > b) {
        printf("[<marquee>How?</marquee>]");
    }
cCsVd|�d�}ddgfdddgfdd|fd	d
g}|�||�|j||tdd�d
�dS)Nr�z]]></text></svg>rrr�r�r1r��r!r��r!rTrr�r�)r
r�rr�rrr�test_cdata_section_contentTs

�z-HTMLParserTestCase.test_cdata_section_contentc	CsBd}ddddgfdddgfdd	d
ddg	}|j||tdd�d
�dS)Nzb<![CDATA[foo<br>bar]]><svg><text y="100"><![CDATA[foo<br>bar]]></text></svg><![CDATA[foo<br>bar]]>)r$z
[CDATA[foo<br)rzbar]]>rrr�r�)r1zCDATA[foo<br>barr�r�Trr�r�r�rrr�test_cdata_sectionrs
�z%HTMLParserTestCase.test_cdata_sectioncCs8tdd�}|�d�|�|��dddgfddd	g�dS)
NTrDzfoo <a>link</a> bar &amp; baz)rzfoo rr`)rr�rb)rz
 bar & baz)rrGZassertEqualr)r
r	rrr�"test_convert_charrefs_dropped_text�s

��z5HTMLParserTestCase.test_convert_charrefs_dropped_textZcpucCs�dd�}d}|d|�|d|�|d|�|d|�|d|�|d	|�|d
|�|d|�|d|�|d
|�dS)NcSs tj��}|�|�|��dSr@)rr	r
rGrH)rKr	rrr�check�s

zBHTMLParserTestCase.test_eof_no_quadratic_complexity.<locals>.checki��rrz<a a=z8</a </a </a </a </a </a </a </a </a </a </a </a </a </a zB</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=</a a=z<!--<!--<!--<!--zx<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!<!z&<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?<?z-</$</$</$</$</$</$</$</$</$</$</$</$</$</$</$zQ<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[<![CDATA[a;<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctype<!doctyper)r
r��nrrr� test_eof_no_quadratic_complexity�sz3HTMLParserTestCase.test_eof_no_quadratic_complexityN)4r3r4r5rRrYr^r_rdrgrjrqrzr|r~r�rZsubTestsr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�Zrequires_resourcerrrrrrP�s| 



�








-	)!
"
rPc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�AttributesTestCasecCs�ddgd�fg}|�d|�|�ddddgfg�|�ddddgfg�|�d	dddgfg�|�d
dddgfg�|�dddd
gfg�|�ddddgfg�|�ddddgfg�|�ddddgfg�|�ddddgfg�dS)Nrr`))ra�v)�cr)�dr)�eNz<a b='v' c="v" d=v e>z<a foo==bar>)r}z=barz<a foo =bar>r�z<a foo	=bar>z<a foo=bar>)zfoor�u
<a foo =bar>)ufoo r�z<a foo= bar>z<a foo=	bar>z<a foo=bar>)r}zbaru
<a foo= bar>)r}u barrQrxrrr�test_attr_syntax�s�z#AttributesTestCase.test_attr_syntaxcCs�|�dddgd�fg�|�dddddgfg�|�dddd	d
gfg�|�ddddd
gfg�|�ddddgfg�|�ddddgfg�dS)Nz'<a b='xxx
	xxx' c="yyy	
yyy" d='	xyz
'>rr`))razxxx
	xxx)rzyyy	
yyy)rz	xyz
z
<a b='' c="">)rart)rrtz
<a b=	x c=
y>)rar�)rr�u<a b= c= >)ra�)r� z<e a=rgb(1,2,3)>r)r`z
rgb(1,2,3)z<a href=mailto:xyz@example.com>)r�zmailto:xyz@example.comrQrArrr�test_attr_values�s&������z#AttributesTestCase.test_attr_valuescCsL|�dddddgfg�|�ddddd	gfg�|�d
dddd	gfg�dS)Nu!<img src=/foo/bar.png alt=中文>rrV)rWz/foo/bar.png)Zaltu中文u+<a title='テスト' href='テスト.html'>r`)r�u	テスト)r�uテスト.htmlu+<a title="テスト" href="テスト.html">rQrArrr�test_attr_nonascii�s$������z%AttributesTestCase.test_attr_nonasciicC�|�ddddgfg�dS)Nz!<a b='&amp;&gt;&lt;&quot;&apos;'>rr`)raz&><"'rQrArrr�test_attr_entity_replacement���z/AttributesTestCase.test_attr_entity_replacementcCs|�dddgd�fg�dS)Nz<a a.b='v' c:d=v e-f=v>rr`))za.br)zc:dr)ze-frrQrArrr�test_attr_funky_names�s�z(AttributesTestCase.test_attr_funky_namescCr)Nz0<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>rr)r}u€&aa&unsupported;rQrArrr�test_entityrefs_in_attributes�rz0AttributesTestCase.test_entityrefs_in_attributescCs.|�ddddgfdddgfdddgfg�dS)	Nz<a $><b $=%><c \=/>rr`)r�Nra)r��%r)�\r�rQrArrr�test_attr_funky_names2�s


��z)AttributesTestCase.test_attr_funky_names2cCs\dD])}|�d|dddgfg�|�d|dddgfg�|�d|dddgfg�qdS)N)�&z&amp;z&#38;z&#x26;z
<a href="%s">rr`)r�rz
<a href='%s'>z<a href=%s>rQ)r
rUrrr� test_entities_in_attribute_value�s
�
�
��z3AttributesTestCase.test_entities_in_attribute_valuecCsPd}dddgfdddddgfddddd	gfd
ddddgfddg}|�||�dS)
Nz�<a href=test'style='color:red;bad1'>test - bad1</a><a href=test'+style='color:red;ba2'>test - bad2</a><a href=test'&nbsp;style='color:red;bad3'>test - bad3</a><a href = test'&nbsp;style='color:red;bad4'  >test - bad4</a>rr`)r�ztest'style='color:red;bad1')rztest - bad1rb)r�ztest'+style='color:red;ba2')rztest - bad2)r�utest' style='color:red;bad3')rztest - bad3)r�utest' style='color:red;bad4')rztest - bad4rQr�rrr�test_malformed_attributes�s �



�z,AttributesTestCase.test_malformed_attributescCsH|�dddgfddddgfdg�|�d	ddgfdddd
gfdg�dS)Nz<x><y z=""o"" /></x>rr�rr�)r�rt)zo""N)r!r�z<x><y z="""" /></x>)z""NrQrArrr�"test_malformed_adjacent_attributess����z5AttributesTestCase.test_malformed_adjacent_attributescCs4|�dddddgfg�|�dddddgfg�dS)	Nz<a width="100%"cellspacing=0>rr`�r�z100%�Zcellspacing�0z<a id="foo"class="bar">)�idr}��classr�rQrArrr�test_adjacent_attributess����z+AttributesTestCase.test_adjacent_attributescCr)Nz<a v=>rr`)rrtrQrArrr�test_missing_attribute_value&s�z/AttributesTestCase.test_missing_attribute_valuecCr)Nz-<a href=javascript:popup('/popup/help.html')>rr`)r�z$javascript:popup('/popup/help.html')rQrArrr�test_javascript_attribute_value*s
��z2AttributesTestCase.test_javascript_attribute_valuecCs|�ddddgfddg�dS)Nz-<a href='http://www.example.org/">;'>spam</a>rr`)r�zhttp://www.example.org/">;)rZspamrbrQrArrr�test_end_tag_in_attribute_value/s���z2AttributesTestCase.test_end_tag_in_attribute_valuecCs�d}ddgfddddgfddgd�fdd	gfdd
dgfddd
gfddddgfdddgfdddddddgfdddgfddddg}|�||�dS)Nz�<html><body bgcolor=d0ca90 text='181008'><table cellspacing=0 cellpadding=1 width=100% ><tr><td align=left><font size=-1>- <a href=/rabota/><span class=en> software-and-i</span></a>- <a href='/1/'><span class=en> library</span></a></table>rr�body)ZbgcolorZd0ca90)r�Z181008�table)r)ZcellpaddingrrZtrZtd)Zalign�leftZfont)�sizez-1)rz- r`)r�z/rabota/r�)rZen)rz software-and-ir�rb)r�z/1/)rz library)r!r#rQr�rrr�test_with_unquoted_attributes6s"�

�z0AttributesTestCase.test_with_unquoted_attributescCs�d}dddgfddddgfddddgfddgd	�fdddd
gfddddgfddd
dgfddddgfddddgfg	}|�||�dS)Nz�<div class=bar,baz=asd><div class="bar",baz="asd"><div class=bar, baz=asd,><div class="bar", baz="asd",><div class="bar",><div class=,bar baz=,asd><div class=,"bar" baz=,"asd"><div ,class=bar ,baz=asd><div class,="bar" baz,="asd">rr\)rzbar,baz=asdr)z,baz�asd)rzbar,)�bazzasd,)rr�)r(r'r�r�)rz,bar)r(z,asd)rz,"bar")r(z,"asd")z,classr�)zclass,r�)zbaz,r'rQr�rrr�test_comma_between_attributesNs
�z0AttributesTestCase.test_comma_between_attributescCr)Nz<form action=bogus|&#()value>rZform)�actionzbogus|&#()valuerQrArrr�-test_weird_chars_in_unquoted_attribute_valuesjs
�
�z@AttributesTestCase.test_weird_chars_in_unquoted_attribute_valuesN)r3r4r5rr
rr
rrrrrrrrr r!r&r)r+rrrrr�s$
	r�__main__)�__doc__Zhtml.parserrrJZunittest�testrr�r�r	r
rr7r9r?ZTestCaserBrPrr3�mainrrrr�<module>s2�	@&K�