Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_htmlparser.cpython-35.opt-2.pyc



���]��@s�ddlZddlZddlZddlmZGdd�dejj�ZGdd�de�Z	Gdd�de�Z
Gd	d
�d
ej�ZGdd�de�Z
Gd
d�de�Zedkr�ej�dS)�N)�supportc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�EventCollectorcOs5g|_|jj|_tjjj|||�dS)N)�events�append�html�parser�
HTMLParser�__init__)�self�args�kw�r
�4/opt/alt/python35/lib64/python3.5/test_htmlparser.pyr	s	zEventCollector.__init__cCs�g}d}xm|jD]b}|d}||ko=dknred|dd|df|d<n
|j|�|}qW||_|S)Nr�data����r)rr)r
�LZprevtype�event�typer
r
r�
get_eventss
#

	zEventCollector.get_eventscCs|jd||f�dS)N�starttag)r)r
�tag�attrsr
r
r�handle_starttag!szEventCollector.handle_starttagcCs|jd||f�dS)N�startendtag)r)r
rrr
r
r�handle_startendtag$sz!EventCollector.handle_startendtagcCs|jd|f�dS)N�endtag)r)r
rr
r
r�
handle_endtag'szEventCollector.handle_endtagcCs|jd|f�dS)N�comment)r)r
rr
r
r�handle_comment,szEventCollector.handle_commentcCs|jd|f�dS)N�charref)r)r
rr
r
r�handle_charref/szEventCollector.handle_charrefcCs|jd|f�dS)Nr)r)r
rr
r
r�handle_data2szEventCollector.handle_datacCs|jd|f�dS)N�decl)r)r
rr
r
r�handle_decl5szEventCollector.handle_declcCs|jd|f�dS)N�	entityref)r)r
rr
r
r�handle_entityref8szEventCollector.handle_entityrefcCs|jd|f�dS)N�pi)r)r
rr
r
r�	handle_pi;szEventCollector.handle_picCs|jd|f�dS)Nzunknown decl)r)r
r#r
r
r�unknown_decl>szEventCollector.unknown_declN)�__name__�
__module__�__qualname__r	rrrrrr!r"r$r&r(r)r
r
r
rr	src@seZdZdd�ZdS)�EventCollectorExtracCs0tj|||�|jd|j�f�dS)N�
starttag_text)rrrZget_starttag_text)r
rrr
r
rrDsz#EventCollectorExtra.handle_starttagN)r*r+r,rr
r
r
rr-Bsr-c@s(eZdZdd�Zdd�ZdS)�EventCollectorCharrefscCs|jd�dS)Nz6This should never be called with convert_charrefs=True)�fail)r
rr
r
rr!Ksz%EventCollectorCharrefs.handle_charrefcCs|jd�dS)Nz6This should never be called with convert_charrefs=True)r0)r
rr
r
rr&Nsz'EventCollectorCharrefs.handle_entityrefN)r*r+r,r!r&r
r
r
rr/Isr/c@s7eZdZdd�Zddd�Zdd�ZdS)�TestCaseBasecCs
tdd�S)N�convert_charrefsF)r)r
r
r
r�
get_collectorTszTestCaseBase.get_collectorNcCs�|dkr|j�}|}x|D]}|j|�q%W|j�|j�}||kr�|jddt|�dtj|�dtj|��dS)Nz-received events did not match expected eventsz	
Source:
z
Expected:
z
Received:
)r3�feed�closerr0�repr�pprintZpformat)r
�sourceZexpected_events�	collectorr�srr
r
r�
_run_checkWs

zTestCaseBase._run_checkcCs |j||tdd��dS)Nr2F)r;r-)r
r8rr
r
r�_run_check_extraeszTestCaseBase._run_check_extra)r*r+r,r3r;r<r
r
r
rr1Rsr1c@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#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCS)D�HTMLParserTestCasecCs*|jddg�|jddg�dS)Nz<?processing instruction>r'�processing instructionz<?processing instruction ?>�processing instruction ?)r'r>)r'r?)r;)r
r
r
r� test_processing_instruction_onlyls	
	z3HTMLParserTestCase.test_processing_instruction_onlycCs_|jddddddgfdddddddddgfd d!d"d#d$d%d&g�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#�DOCTYPE html PUBLIC 'foo'rrr%�entityr �32r�4comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b�img�src�Bar�ismap�sample
text
�x201C�comment2a-- --comment2br)rrA)r#rB)rrA)r%rC)r rD)rrA)rrE)rrA)rGrH)rIN)rrJ)r rK)rrA)rrL)rrA)rr)rrA)r;)r
r
r
r�test_simple_htmlts&z#HTMLParserTestCase.test_simple_htmlcCsK|jdddgfd	d
g�|jdgddgfddg�dS)
Nz
<p>&#bad;</p>r�pr�&#bad;rz<div>&#bad;</div>�div)rrO)rrN)rrO)rrP)r;)r
r
r
r�test_malformatted_charref�s	
z,HTMLParserTestCase.test_malformatted_charrefcCs|jdddg�dS)Nz&entityref foor%r� foo)r%r%)rrR)r;)r
r
r
r�test_unclosed_entityref�s	z*HTMLParserTestCase.test_unclosed_entityrefcCs2|jdddgfddgfddg�dS)Nz<a><b></a></b>r�a�br)rrT)rrU)r;)r
r
r
r�test_bad_nesting�s
	z#HTMLParserTestCase.test_bad_nestingcCs|jddg�dS)N�#this text & contains & ampersands &r)rrW)r;)r
r
r
r�test_bare_ampersands�s	z'HTMLParserTestCase.test_bare_ampersandscCs|jddg�dS)N�.this < text > contains < bare>pointy< bracketsr)rrY)r;)r
r
r
r�test_bare_pointy_brackets�s	z,HTMLParserTestCase.test_bare_pointy_bracketscCsB|jddddgfg�|jdddd	gfg�dS)
Nz	<a b='<'>rrTrU�<z	<a b='>'>�>)rUr[)rUr\)r;)r
r
r
r�test_starttag_end_boundary�sz-HTMLParserTestCase.test_starttag_end_boundarycCs+ddd*gfg}|jdg|�|jddg|�|jdd	g|�|jd
dg|�|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)-NrrTrUr[z	<a b='<'>z<a zb='<'>z<a bz='<'>z<a b=z'<'>z<a b='<z'>z<a b='<'r\z	<a b='>'>zb='>'>z='>'>z'>'>z<a b='>z<a b='>'r�abc�z
<!--abc-->z	!--abc-->z<!z--abc-->z<!-z-abc-->z<!--zabc-->z<!--azbc-->z<!--abzc-->z<!--abcz-->z<!--abc-z->z	<!--abc--)rUr[)rUr\)rr^)r;)r
�outputr
r
r�test_buffer_artefacts�s4	z(HTMLParserTestCase.test_buffer_artefactsc
CsZddddddddd	d
g
}x/|D]'}|jd|dd
|fg�q+WdS)NZHTMLzOHTML 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#zDOCTYPE )r;)r
ZdtdsZdtdr
r
r�test_valid_doctypes�s	

z&HTMLParserTestCase.test_valid_doctypescCsm|jdddgfg�|jdddgfdg�|jdddgfdddgfd
g�dS)Nz<p/>rrNz<p></p>rrz<p><img src='foo' /></p>rFrG�foo)rrN)rGrc)rrN)r;)r
r
r
r�test_startendtag�s		
	z#HTMLParserTestCase.test_startendtagcCs5d}|j|ddd	d
gfd|fg�dS)Nz <foo:bar   
   one="1"	two=2   >rzfoo:bar�one�1�two�2r.)rerf)rgrh)r<)r
r:r
r
r�test_get_starttag_texts	z)HTMLParserTestCase.test_get_starttag_textcCs�ddddddddd	d
dg}dd
ddddg}xq|D]i}x`|D]X}|j�}djd|d|�}|j|d|gfd|fd|fg�qSWqFWdS)Nz*<!-- not a comment --> &not-an-entity-ref;z<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;
// -->
zfoo = "</sty" + "le>";u<!-- ☃ -->�script�styleZSCRIPTZSTYLEZScriptZStylez <{element}>{content}</{element}>�element�contentrrr)�lower�formatr;)r
�contents�elementsrmrl�
element_lowerr:r
r
r�test_cdata_content
s(	

		z%HTMLParserTestCase.test_cdata_contentcCs�Gdd�dt�}d}x�dddddd	gD]m}|j�j�}d
jd|d|�}|j|d
|gfd|fd|fgd|dd��q5WdS)Nc@seZdZdd�ZdS)zBHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.CollectorcSs|jS)N)r)r
r
r
rr/szMHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.Collector.get_eventsN)r*r+r,rr
r
r
r�	Collector.srtz�<!-- not a comment --> &not-an-entity-ref;
                  <a href="" /> </p><p> <span></span></style>
                  '</script' + '>'z scriptzscript z script z
scriptzscript
z
script
z<script>{content}</{element}>rlrmrrrr9r2F)rrn�stripror;)r
rtrmrlrrr:r
r
r�test_cdata_with_closing_tags)s		z/HTMLParserTestCase.test_cdata_with_closing_tagscCs5d}d
ddd
dddg}|j||�dS)Nz�<!-- I'm a valid comment --><!--me too!--><!------><!----><!----I have many hyphens----><!-- I have a > in the middle --><!-- and I have -- in the middle! -->r� I'm a valid comment �me too!�--r_�--I have many hyphens--� I have a > in the middle � and I have -- in the middle! )rrw)rrx)rry)rr_)rrz)rr{)rr|)r;)r
r�expectedr
r
r�
test_comments?s	z HTMLParserTestCase.test_commentscCs)d}dddg}|j||�dS)	Nzs<!--[if IE & !(lte IE 8)]>aren't<![endif]--><!--[if IE 8]>condcoms<![endif]--><!--[if lte IE 7]>pretty?<![endif]-->r�%[if IE & !(lte IE 8)]>aren't<![endif]�f IE 8]>condcoms<![endif]�[if lte IE 7]>pretty?<![endif])rr)rr�)rr�)r;)r
rr}r
r
r�
test_condcomsPs
	z HTMLParserTestCase.test_condcomscCs�dd�}|j|�j�ddddddg}d	d
d!gfd"d#g}x0|D](}|jdj|�|d|��qYWd$d	d
d%d&d'gfd(d)d*g}x0|D](}|jdj|�|d|��q�Wx�|D]�}dj|gd�}d+d	dgfd
|fd,d-d	dgfd
|fd.d/g	}|jdj||�|d|��q�Wd}xStdt|��D]<}|j|d|�d
|d|�fgd|��q�W|jd d0gd|��dS)1NcSst�S)N)r/r
r
r
r�<lambda>[sz:HTMLParserTestCase.test_convert_charrefs.<locals>.<lambda>z&quot;z&#34;z&#x22;z&quotz&#34z&#x22rrT�href�foo"zarr�a"zrz<a href="foo{0}zar">a{0}z</a>r9�"�x�y�"X�z�X"z*{0}<a x="{0}" y="{0}X" z="X{0}">{0}</a>{0}�X�rjrkz/{1}<script>{0}</script>{1}<style>{0}</style>{1}z&quo &# &#xr�no charrefs here)r�r�)rr�)rrT)rr�)r�r�)r�r�)r�r�)rr�)rrT)rr�)rr�)rrj)rr�)rrk)rr�)rr�)Z
assertTruer2r;ro�join�range�len)r
r9Zcharrefsr}r �textrr�r
r
r�test_convert_charrefsYs>


	,z(HTMLParserTestCase.test_convert_charrefscCsG|jddddgfddddd
dgfddddg	�dS)NzF<html <html>te>>xt&a<<bc</a></html>
<img src="URL><//img></html</html>rr�<htmlr�te>>xtr%rTr[zbc<r�
<img src="URL>r�/img�html<)r�N)rr�)r%rT)rr[)rTN)rr)rr�)rr�)rr�)r;)r
r
r
r�test_tolerant_parsing�s	z(HTMLParserTestCase.test_tolerant_parsingcCsz|jdg�|jddg�|jddg�|jddg�|jdd	d
gfg�|jddg�|jd
dg�|jdd g�|jdd!g�|jdd"g�|jdd#g�|jdd$g�|jdd	dgfg�|jdd	dgfg�|jdddgfg�|jdd	dgfg�|jdddgfg�dS)%Nz</>z</$>r�$�</r�</az<a<a>r�a<az</a<a>r�<!�<a�<a foo='bar'�<a foo='bar�
<a foo='>'�	<a foo='>z<a$>za$z<a$b>za$bz<a$b/>rz<a$b  >z<a$b  />)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)rr�)r;)r
r
r
r�test_starttag_junk_chars�s"z+HTMLParserTestCase.test_starttag_junk_charscCs%|jddddgfg�d}ddddddddd d!gfg}|j||�d}ddd"d#d$gfddd%d&d'gfg}|j||�d}ddgfddgfddgfddgfddgfddgfddgfddgfg}|j||�dS)(Nz<a foo="var"/>rrTrc�varzj<img width=902 height=250px src="/sites/default/files/images/homepage/foo.jpg" /*what am I doing here*/ />rF�width�902�height�250pxrG�,/sites/default/files/images/homepage/foo.jpg�*what�am�i�doing�here*z9<a / /foo/ / /=/ / /bar/ / /><a / /foo/ / /=/ / /bar/ / >�=�barrzD<meta><meta / ><meta // ><meta / / ><meta/><meta /><meta //><meta//>�meta)rcr�)r�r�)r�r�)rGr�)r�N)r�N)r�N)r�N)r�N)rcN)r�N)r�N)rcN)r�N)r�N)r;)r
rr}r
r
r�test_slashes_in_starttag�s$	z+HTMLParserTestCase.test_slashes_in_starttagcCs|jddg�dS)Nz<!DOCTYPE foo $ >r#�DOCTYPE foo $ )r#r�)r;)r
r
r
r�test_declaration_junk_chars�sz.HTMLParserTestCase.test_declaration_junk_charscCs|jddg�dS)Nz"<!spacer type="block" height="25">r�spacer type="block" height="25")rr�)r;)r
r
r
r�test_illegal_declarations�s	z,HTMLParserTestCase.test_illegal_declarationscCs�d}ddgfddd#d$gfdd	d%d&d'gfddgfddd(gfddd)gfd*ddd+gfddd,gfd-d.d/d0ddd1gfddd2gfd3d4d5d6g}|j||�dS)7Nz�<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>rrZbody�bgcolor�d0ca90r��181008�table�cellspacing�0�cellpaddingrfr��100%�trZtd�align�leftZfont�size�-1r�- rTr��/rabota/�span�class�en� software-and-ir�/1/� library)r�r�)r�r�)r�r�)r�rf)r�r�)r�r�)r�r�)rr�)r�r�)r�r�)rr�)rr�)rrT)rr�)r�r�)r�r�)rr�)rr�)rrT)rr�)r;)r
rr}r
r
r�test_with_unquoted_attributes�sz0HTMLParserTestCase.test_with_unquoted_attributescCs)|jdddd	d
dgfg�dS)Nz7<form action="/xxx.php?a=1&amp;b=2&amp", method="post">r�form�action�/xxx.php?a=1&b=2&�,�method�post)r�r�)r�N)r�r�)r;)r
r
r
r�test_comma_between_attributes�s	z0HTMLParserTestCase.test_comma_between_attributescCs#|jddddgfg�dS)Nz<form action=bogus|&#()value>rr�r��bogus|&#()value)r�r�)r;)r
r
r
r�-test_weird_chars_in_unquoted_attribute_values�s	z@HTMLParserTestCase.test_weird_chars_in_unquoted_attribute_valuescCs�d}ddgfd
ddgfdddgfdddgfd
ddgfdddgfddgfg}|j||�dS)Nzn<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br></li class="unit"><br></li
						</ul><br></><br>r�brr�label<rPr�<h4�li)rr�)rrP)rr�)rr�)rr�)r;)r
rr}r
r
r�test_invalid_end_tags�sz(HTMLParserTestCase.test_invalid_end_tagscCs5d}ddgfdd	d
g}|j||�dS)Nz(<b>This</b attr=">"> confuses the parserrrUr�Thisr�"> confuses the parser)rr�)rrU)rr�)r;)r
rr}r
r
r�test_broken_invalid_end_tags	z.HTMLParserTestCase.test_broken_invalid_end_tagcCs�d}dddgfddgfddd	dgfdddddgfdddgfdd d!d"g}|j||�d}ddd#d$d%gfddgfd&dd	d'gfd(d)g}|j||�dS)*Nz[<div style=""    ><b>The <a href="some_url">rain</a> <br /> in <span>Spain</span></b></div>rrPrkr_rUr�The rTr��some_url�rainr� rr�� in r��Spainz><div style="", foo = "bar" ><b>The <a href="some_url">rain</a>r�rcr�)rkr_)rr�)r�r�)rr�)rrT)rr�)rr�)rr�)rr�)rrU)rrP)rkr_)r�N)rcr�)rr�)r�r�)rr�)rrT)r;)r
rr}r
r
r�$test_correct_detection_of_start_tagss0		z7HTMLParserTestCase.test_correct_detection_of_start_tagscCsjddgfddgfdd
ddgfd
ddgfg}x$|D]\}}|j||�qFWdS)N�a&rza&b�abza&b rTr%rUr�za&b;)rr�)rr�)rrT)r%rU)rr�)rrT)r%rU)r;)r
rrr}r
r
r�test_EOF_in_charref3sz&HTMLParserTestCase.test_EOF_in_charrefcCs\ddlm}|j�}|jt��*d}|j|j|�||��WdQRXdS)Nr)�unescapez%&quot;&#34;&#x22;&quot&#34&#x22&#bad;)rr�r3ZassertWarns�DeprecationWarning�assertEqual)r
r�rNr:r
r
r�test_unescape_methodAs
z'HTMLParserTestCase.test_unescape_methodcCs2d}d	d
ddd
dg}|j||�dS)Nz�<! not really a comment ><! not a comment either --><! -- close enough --><!><!<-- this was an empty comment><!!! another bogus comment !!!>r� not really a comment � not a comment either --� -- close enough --r_�<-- this was an empty comment�!! another bogus comment !!!)rr�)rr�)rr�)rr_)rr�)rr�)r;)r
rr}r
r
r�test_broken_commentsHs	z'HTMLParserTestCase.test_broken_commentscCs�d}dddddd	dgfdddd
dgfdd ddgfd!d"d#d$dd
d%gfd&g}|j||�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]>�unknown decl�if !(IE)r�broken condcom�endif�if ! IEr�linkr��favicon.tiff�if !IE 6rFrG�firefox.png�if !ie 6rrUrcr�if (!IE)|(lt IE 9)�mammoth.bmp)r�r�)rr�)r�r�)r�r�)r�r�)r�r�)r�r�)rGr�)r�r�)r�r�)rrc)rrU)r�r�)r�r�)rGr�)r�r�)r;)r
rr}r
r
r�test_broken_condcomsXs&	z'HTMLParserTestCase.test_broken_condcomscCsNtdd�}|jd�|j|j�dddgfdd
dg�dS)Nr2Tzfoo <a>link</a> bar &amp; bazr�foo rrTr�r�
 bar & baz)rr)rr�)rrT)rr)rr4r�r)r
rr
r
r�"test_convert_charrefs_dropped_textys
	z5HTMLParserTestCase.test_convert_charrefs_dropped_textN)$r*r+r,r@rMrQrSrVrXrZr]rarbrdrirsrvr~r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
r
r
rr=jsB 
	)
!!r=c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�AttributesTestCasecCsbdddd
ddgfg}|jd|�|jd	|�|jd
|�|jd|�dS)NrrTrU�v�c�d�ez<a b='v' c="v" d=v e>z<a  b = 'v' c = "v" d = v e>z<a
b
=
'v'
c
=
"v"
d
=
v
e>z<a	b	=	'v'	c	=	"v"	d	=	v	e>)rUr)rr)rr)rN)r;)r
r`r
r
r�test_attr_syntax�s
z#AttributesTestCase.test_attr_syntaxcCs�|jddddddgfg�|jd
ddddgfg�|jddd
dgfg�|jddddgfg�dS)Nz'<a b='xxx
	xxx' c="yyy	
yyy" d='	xyz
'>rrTrU�xxx
	xxxr�yyy	
yyyr�	xyz
z
<a b='' c="">r_z<e a=rgb(1,2,3)>r�
rgb(1,2,3)z<a href=mailto:xyz@example.com>r��mailto:xyz@example.com)rUr
)rr)rr)rUr_)rr_)rTr
)r�r)r;)r
r
r
r�test_attr_values�s				z#AttributesTestCase.test_attr_valuescCsj|jdddddgfg�|jddd	ddgfg�|jddd	ddgfg�dS)Nu!<img src=/foo/bar.png alt=中文>rrFrG�/foo/bar.png�alt�中文u+<a title='テスト' href='テスト.html'>rT�title�	テストr��テスト.htmlu+<a title="テスト" href="テスト.html">)rGr)rr)rr)r�r)rr)r�r)r;)r
r
r
r�test_attr_nonascii�s			z%AttributesTestCase.test_attr_nonasciicCs#|jddddgfg�dS)Nz!<a b='&amp;&gt;&lt;&quot;&apos;'>rrTrU�&><"')rUr)r;)r
r
r
r�test_attr_entity_replacement�sz/AttributesTestCase.test_attr_entity_replacementcCs)|jddddd	d
gfg�dS)Nz<a a.b='v' c:d=v e-f=v>rrT�a.br�c:d�e-f)rr)rr)rr)r;)r
r
r
r�test_attr_funky_names�sz(AttributesTestCase.test_attr_funky_namescCs#|jddddgfg�dS)Nz0<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>rrrc�€&aa&unsupported;)rcr)r;)r
r
r
r�test_entityrefs_in_attributes�sz0AttributesTestCase.test_entityrefs_in_attributescCsA|jdddd
gfdddgfdddgfg�dS)
Nz<a $><b $=%><c \=/>rrTr�rU�%r�\�/)r�N)r�r)r r!)r;)r
r
r
r�test_attr_funky_names2�s
z)AttributesTestCase.test_attr_funky_names2cCs�x�ddddgD]o}|jd|dddgfg�|jd	|dddgfg�|jd
|ddd
gfg�qWdS)N�&z&amp;z&#38;z&#x26;z
<a href="%s">rrTr�z
<a href='%s'>z<a href=%s>)r�r#)r�r#)r�r#)r;)r
rCr
r
r� test_entities_in_attribute_value�s


z3AttributesTestCase.test_entities_in_attribute_valuec
Cstd}dddgfdddddgfdddddgfdddddgfddg}|j||�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>rrTr��test'style='color:red;bad1'r�test - bad1r�test'+style='color:red;ba2'�test - bad2�test' style='color:red;bad3'�test - bad3�test' style='color:red;bad4'�test - bad4)r�r%)rr&)rrT)r�r')rr()rrT)r�r))rr*)rrT)r�r+)rr,)rrT)r;)r
rr}r
r
r�test_malformed_attributes�sz,AttributesTestCase.test_malformed_attributescCsf|jdddgfdddd
gfdg�|jd
ddgfddddgfdg�dS)Nz<x><y z=""o"" /></x>rr�rr�r�r_�o""rz<x><y z="""" /></x>�"")r�r_)r.N)rr�)r�r_)r/N)rr�)r;)r
r
r
r�"test_malformed_adjacent_attributes�s	
	z5AttributesTestCase.test_malformed_adjacent_attributescCsH|jdddd
dgfg�|jdddddgfg�dS)Nz<a width="100%"cellspacing=0>rrTr��100%r�r�z<a id="foo"class="bar">�idrcr�r�)r�r1)r�r�)r2rc)r�r�)r;)r
r
r
r�test_adjacent_attributes�s		z+AttributesTestCase.test_adjacent_attributescCs#|jddddgfg�dS)Nz<a v=>rrTrr_)rr_)r;)r
r
r
r�test_missing_attribute_value�s	z/AttributesTestCase.test_missing_attribute_valuecCs#|jddddgfg�dS)Nz-<a href=javascript:popup('/popup/help.html')>rrTr��$javascript:popup('/popup/help.html'))r�r5)r;)r
r
r
r�test_javascript_attribute_value�s	z2AttributesTestCase.test_javascript_attribute_valuecCs)|jdddd	gfd
dg�dS)Nz-<a href='http://www.example.org/">;'>spam</a>rrTr��http://www.example.org/">;r�spamr)r�r7)rr8)rrT)r;)r
r
r
r�test_end_tag_in_attribute_values		z2AttributesTestCase.test_end_tag_in_attribute_valueN)r*r+r,r	rrrrrr"r$r-r0r3r4r6r9r
r
r
rr�s	
	r�__main__)Zhtml.parserrr7ZunittestZtestrrrrr-r/ZTestCaser1r=rr*�mainr
r
r
r�<module>s9	���