Sindbad~EG File Manager

Current Path : /proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //proc/2568807/root/usr/local/lib/python3.12/test/__pycache__/test_htmlparser.cpython-312.opt-2.pyc

�

'Μgx���B�	ddlZddlZddlZddlmZGd�dejj�ZGd�de�Z	Gd�de�Z
Gd	�d
ej�ZGd�de�Z
Gd
�de�ZGd�dej�Zedk(rej"�yy)�N)�patchc�T�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�EventCollectorc��g|_|jj|_tjjj
|g|��i|��y�N)�events�append�html�parser�
HTMLParser�__init__)�self�args�kws   �1/usr/local/lib/python3.12/test/test_htmlparser.pyr
zEventCollector.__init__s<������k�k�(�(��������'�'��:�t�:�r�:�c��g}d}|jD]<}|d}||cxk(rdk(rnnd|dd|dzf|d<n|j|�|}�>||_|S)Nr�data����)rr	)r�L�prevtype�event�types     r�
get_eventszEventCollector.get_eventsso��
�����[�[�E���8�D��x�)�6�)���2��q��E�!�H�!4�5��"��������H�
!�����rc�,�|jd||f�y)N�starttag�r	�r�tag�attrss   r�handle_starttagzEventCollector.handle_starttag"s�����Z��e�,�-rc�,�|jd||f�y)N�startendtagrrs   r�handle_startendtagz!EventCollector.handle_startendtag%s�����]�C��/�0rc�*�|jd|f�y)N�endtagr)rr s  r�
handle_endtagzEventCollector.handle_endtag(s�����X�s�O�$rc�*�|jd|f�y)N�commentr�rrs  r�handle_commentzEventCollector.handle_comment-������Y��%�&rc�*�|jd|f�y)N�charrefrr+s  r�handle_charrefzEventCollector.handle_charref0r-rc�*�|jd|f�y)Nrrr+s  r�handle_datazEventCollector.handle_data3������V�T�N�#rc�*�|jd|f�y)N�declrr+s  r�handle_declzEventCollector.handle_decl6r3rc�*�|jd|f�y)N�	entityrefrr+s  r�handle_entityrefzEventCollector.handle_entityref9s�����[�$�'�(rc�*�|jd|f�y)N�pirr+s  r�	handle_pizEventCollector.handle_pi<s�����T�4�L�!rc�*�|jd|f�y)N�unknown declr)rr5s  r�unknown_declzEventCollector.unknown_decl?s�����^�T�*�+rN)�__name__�
__module__�__qualname__r
rr"r%r(r,r0r2r6r9r<r?�rrrr
s>��;�

�".�1�%�
'�'�$�$�)�"�,rrc��eZdZd�Zy)�EventCollectorExtrac�t�tj|||�|jd|j�f�y)N�
starttag_text)rr"r	�get_starttag_textrs   rr"z#EventCollectorExtra.handle_starttagEs.���&�&�t�S�%�8����_�d�&<�&<�&>�?�@rN)r@rArBr"rCrrrErECs��ArrEc��eZdZd�Zd�Zy)�EventCollectorCharrefsc�&�|jd�y�Nz6This should never be called with convert_charrefs=True��failr+s  rr0z%EventCollectorCharrefs.handle_charrefL����	�	�J�Krc�&�|jd�yrLrMr+s  rr9z'EventCollectorCharrefs.handle_entityrefOrOrN)r@rArBr0r9rCrrrJrJJs��L�LrrJc� �eZdZd�Zdd�Zd�Zy)�TestCaseBasec��td��S�NF��convert_charrefs)r�rs r�
get_collectorzTestCaseBase.get_collectorUs
���u�5�5rNc�F�|�|j�}|}|D]}|j|��|j�|j�}||k7rP|j	dt|�zdzt
j|�zdzt
j|�z�yy)Nz6received events did not match expected events
Source:
z
Expected:
z
Received:
)rX�feed�closerrN�repr�pprint�pformat)r�source�expected_events�	collectorr�srs       r�
_run_checkzTestCaseBase._run_checkXs������*�*�,�I����A��K�K��N�������"�"�$���_�$��I�I�$�&*�6�l�3�%�&�(.����(G�H�&�&�)/���v�(>�?�
@�%rc�>�|j||td���yrT)rcrE)rr_rs   r�_run_check_extrazTestCaseBase._run_check_extrafs�������+�U�C�	Err)r@rArBrXrcrerCrrrRrRSs��6�@�ErrRc��eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�HTMLParserTestCasec�P�|jddg�|jddg�y)Nz<?processing instruction>)r;zprocessing instructionz<?processing instruction ?>)r;zprocessing instruction ?�rcrWs r� test_processing_instruction_onlyz3HTMLParserTestCase.test_processing_instruction_onlyms2�����3�,�6�	�	
���5�.�8�	rc�Z�|jddddddgfddddddd	d
dgfdd
dddddg�y)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�
)r5zDOCTYPE html PUBLIC 'foo'rr
)r8�entity)r/�32)r*z4comment1a
-></foo><bar>&lt;<?pi?></foo<bar
comment1b�img)�src�Bar)�ismapN)rzsample
text
)r/�x201C)r*zcomment2a-- --comment2b�r'r
rirWs r�test_simple_htmlz#HTMLParserTestCase.test_simple_htmlus`�������)���������I������9�:����*����#�	rc�f�|jdddgfddg�|jdgddgfddg�y)	Nz
<p>&#bad;</p>r�p)rz&#bad;�r'rwz<div>&#bad;</div>�div�r'ryrirWs r�test_malformatted_charrefz,HTMLParserTestCase.test_malformatted_charref�sN������
��b�!���*
�	�	
���,�-�
���#���0
�	rc�,�|jdddg�y)Nz&entityref foo)r8r8)rz foorirWs r�test_unclosed_entityrefz*HTMLParserTestCase.test_unclosed_entityref�s�����(�&��+�	rc�<�|jdddgfddgfddg�y)Nz<a><b></a></b>r�a�b�r'r�r'r�rirWs r�test_bad_nestingz#HTMLParserTestCase.test_bad_nesting�s2��	
���(�
��b�!�
��b�!���	+�	rc�*�|jddg�y)N�#this text & contains & ampersands &)rr�rirWs r�test_bare_ampersandsz'HTMLParserTestCase.test_bare_ampersands�s�����=�;�@�	rc�*�|jddg�y)N�.this < text > contains < bare>pointy< brackets)rr�rirWs r�test_bare_pointy_bracketsz,HTMLParserTestCase.test_bare_pointy_brackets�s�����H�F�K�	rc�`�|jddddgfg�|jddddgfg�y)N�	<a b='<'>rr�r��<�	<a b='>'>�r��>rirWs r�test_starttag_end_boundaryz-HTMLParserTestCase.test_starttag_end_boundary�s6������:�s�Z�L�*I�)J�K�����:�s�Z�L�*I�)J�Krc��dddgfg}|jdg|�|jddg|�|jddg|�|jd	d
g|�|jddg|�|jd
dg|�dddgfg}|jdg|�|jddg|�|jddg|�|jd	dg|�|jddg|�|jddg|�dg}|jddg|�|jddg|�|jddg|�|jddg|�|jdd g|�|jd!d"g|�|jd#d$g|�|jd%d&g|�|jd'd(g|�|jd)dg|�|jddg|�y)*Nrrr�r�z<a zb='<'>z<a bz='<'>z<a b=z'<'>z<a b='<z'>z<a b='<'r�r�r�zb='>'>z='>'>z'>'>z<a b='>z<a b='>')r*�abc�z
<!--abc-->r�z	!--abc-->�<!z--abc-->z<!-z-abc-->z<!--zabc-->z<!--azbc-->z<!--abzc-->z<!--abcz-->z<!--abc-z->z	<!--abc--ri�r�outputs  r�test_buffer_artefactsz(HTMLParserTestCase.test_buffer_artefacts�s����s�Z�L�1�2������
�v�.������)�6�2������)�6�2�����&�)�6�2�����D�)�6�2�����S�)�6�2��s�Z�L�1�2������
�v�.������)�6�2������)�6�2�����&�)�6�2�����D�)�6�2�����S�)�6�2�$�%������\�*�F�3�����k�*�F�3�����z�*�F�3�����	�*�F�3������*�F�3�����'�*�F�3�����6�*�F�3�����E�*�F�3�����T�*�F�3�����c�*�F�3�����r�*�F�3rc�P�gd�}|D]}|jd|zdd|zfg��y)N)
�HTMLzOHTML 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>r5zDOCTYPE ri)r�dtds�dtds   r�test_valid_doctypesz&HTMLParserTestCase.test_valid_doctypes�s9��@��$�C��O�O�O�c�1�$�j�3�&6�7�8�
:�rc��|jdddgfg�|jdddgfdg�|jdddgfddd	gfdg�y)
Nz<p/>r$rwz<p></p>rrxz<p><img src='foo' /></p>ro)rp�foorirWs r�test_startendtagz#HTMLParserTestCase.test_startendtag�sq������
�C��$�!�	�	
���	�
��b�!��$�	�	
���2�
��b�!�
�E�N�#3�4��5�	rc�>�d}|j|ddddgfd|fg�y)Nz <foo:bar   
   one="1"	two=2   >rzfoo:bar)�one�1)�two�2rG)re)rrbs  r�test_get_starttag_textz)HTMLParserTestCase.test_get_starttag_texts3��4�����a�
��\�<�$@�A�
�a� �""�	#rc	��gd�}gd�}|D]H}|D]A}|j�}dj||��}|j|d|gfd|fd|fg��C�Jy)N)z*<!-- 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�style�SCRIPT�STYLE�Script�Stylez <{element}>{content}</{element}>��element�contentrrr')�lower�formatrc)r�contents�elementsr�r��
element_lowerrbs       r�test_cdata_contentz%HTMLParserTestCase.test_cdata_contentsx��
��(M���G�#�� '�
�
��
�6�=�=�g�GN�>�P������Z���$C�%+�W�$5�%-�}�$=�$?�@�	$� rc���Gd�dt�}d}dD]X}|j�j�}dj||��}|j	|d|gfd|fd	|fg|d
�����Zy)
Nc��eZdZd�Zy)�BHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.Collectorc��|jSr)rrWs rrzMHTMLParserTestCase.test_cdata_with_closing_tags.<locals>.Collector.get_events0s���{�{�"rN)r@rArBrrCrr�	Collectorr�/s��
#rr�z�<!-- 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}>r�rrr'FrU�ra)rr��stripr�rc)rr�r�r�r�rbs      r�test_cdata_with_closing_tagsz/HTMLParserTestCase.test_cdata_with_closing_tags*s���
	#��	#�&��>�G�#�M�M�O�1�1�3�M�/�6�6�w�?F�7�H�A��O�O�A��]�B� ?�!'�� 1�!)�=� 9� ;�'0��&G�
�
I�>rc�4�d}gd�}|j||�y)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*z I'm a valid comment )r*zme too!)r*z--�r*r�)r*z--I have many hyphens--)r*z I have a > in the middle )r*z and I have -- in the middle! ri�rr
�expecteds   r�
test_commentsz HTMLParserTestCase.test_comments@s!��8��C��	
����h�'rc�4�d}gd�}|j||�y)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]rir�s   r�
test_condcomsz HTMLParserTestCase.test_condcomsQs!��8��C��	
����h�'rc
��d�}|j|�j�gd�}dddgfddg}|D]*}|jdj|�||��	��,d
ddgd�fd
dd
g}|D]*}|jdj|�||��	��,|D]U}d
j	|gdz�}d
ddgfd|fdd
ddgfd|fdd
g	}|jdj||�||��	��Wd}tdt
|��D]$}|j|d|d|d|fg|��	��&|jddg|��	�y)Nc��t�Sr)rJrCrr�<lambda>z:HTMLParserTestCase.test_convert_charrefs.<locals>.<lambda>\s��2�4r)z&quot;z&#34;z&#x22;z&quotz&#34z&#x22rr)�hrefzfoo"zar)rza"zr�z<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�r)r'r�r�)r'r�z/{1}<script>{0}</script>{1}<style>{0}</style>{1}z&quo &# &#xr�no charrefs here)rr�)�
assertTruerVrcr��join�range�len)rra�charrefsr�r/�textr
r�s        r�test_convert_charrefsz(HTMLParserTestCase.test_convert_charrefsZs���4�	����	��4�4�5�J����':�&;�<�#�_�6���G��O�O�;�B�B�7�K�$�	��
�
=� �"���&L�M�!�?�M�C�� �G��O�O�)�)/����$�	��
�
=� �
 �G��8�8�W�I�a�K�(�D�%�#�X�r�2�V�T�N�,�m�#�W�b�1�F�D�>�+�]�	<�H�

�O�O�4�4:�F�4��4I�$�	��
�
=� ����q�#�d�)�$�A��O�O�D��!�H���R�a��'9�&:�&/�k�
�
3�%�	
���*�-I�,J�"+�+�	�	/rc�J�|jddddgfdddddd	gfd
ddd
g	�y)NzF<html <html>te>>xt&a<<bc</a></html>
<img src="URL><//img></html</html>rr
)z<htmlN)rzte>>xt)r8r)rr�zbc<)rNrt)rz
<img src="URL>)r*z/img)r'zhtml<rirWs r�test_tolerant_parsingz(HTMLParserTestCase.test_tolerant_parsing�sF�����=�'��/�1B�C�.�.�)�'���
�>�.�8�/�/�	?1�
	2rc��|jdg�|jddg�|jddg�|jddg�|jdd	d
gfg�|jddg�|jd
dg�|jddg�|jddg�|jddg�|jddg�|jddg�|jdd	dgfg�|jdd	dgfg�|jdddgfg�|jdd	dgfg�|jd ddgfg�y)!Nz</>z</$>)r*�$�</)rr��</a)rr�z<a<a>r�a<az</a<a>)r'r�r�)rr��<a)rr��<a foo='bar')rr��<a foo='bar)rr��
<a foo='>')rr��	<a foo='>)rr�z<a$>za$z<a$b>za$bz<a$b/>r$z<a$b  >z<a$b  />rirWs r�test_starttag_junk_charsz+HTMLParserTestCase.test_starttag_junk_chars�sP������r�"�����!1� 2�3�����~�.�/������0�1�����:�u�b�"9�!:�;�����#4�"5�6�����~�.�/�����~�.�/�����)A�(B�C����
�(?�'@�A�����'=�&>�?�����&;�%<�=�����*�d�B�!7� 8�9�����:�u�b�"9�!:�;�����M�5�"�#=�">�?����	�Z���$;�#<�=����
�m�U�B�%?�$@�Arc
��|jddddgfg�d}ddgd�fg}|j||�d}ddgd	�fd
dgd	�fg}|j||�d}d
dgfd
dgfd
dgfd
dgfddgfddgfddgfddgfg}|j||�y)
Nz<a foo="var"/>r$r)r��varzj<img width=902 height=250px src="/sites/default/files/images/homepage/foo.jpg" /*what am I doing here*/ />ro))�width�902)�height�250px)rpz,/sites/default/files/images/homepage/foo.jpg)z*whatN)�amN)�iN)�doingN)zhere*Nz9<a / /foo/ / /=/ / /bar/ / /><a / /foo/ / /=/ / /bar/ / >))r�N)�=N)�barNrzD<meta><meta / ><meta // ><meta / / ><meta/><meta /><meta //><meta//>�metarir�s   r�test_slashes_in_starttagz+HTMLParserTestCase.test_slashes_in_starttag�s������(�M�3��@P�+Q�*R�S�.��
�5�
/�
���	
����h�'�/���C�!L�M�
��I�J�
��	
����h�'�3�����$�z�6�2�&>�
���$�z�6�2�&>�
�F�B�'�-���)D�
�F�B�'�-���)D�	
��	
����h�'rc�*�|jddg�y)Nz<!DOCTYPE foo $ >)r5zDOCTYPE foo $ rirWs r�test_declaration_junk_charsz.HTMLParserTestCase.test_declaration_junk_chars�s�����+�.H�-I�Jrc�*�|jddg�y)Nz"<!spacer type="block" height="25">)r*zspacer type="block" height="25"rirWs r�test_illegal_declarationsz,HTMLParserTestCase.test_illegal_declarations�s�����<�G�H�	Jrc�r�d}ddgfdddgfdddgfdddgfdddgfdddgfddgfg}|j||�y)Nzn<br></label</p><br></div end tmAd-leaderBoard><br></<h4><br></li class="unit"><br></li
						</ul><br></><br>r�br)r'zlabel<rz)r*z<h4)r'�lirir�s   r�test_invalid_end_tagsz(HTMLParserTestCase.test_invalid_end_tags�sv��M����r�*�(���r�*�%���r�*�&���r�*�$���r�*�$���r�*���r�*�#,��$	
����h�'rc�>�d}ddgfdddg}|j||�y)Nz(<b>This</b attr=">"> confuses the parserrr�)r�Thisr�)rz"> confuses the parserrir�s   r�test_broken_invalid_end_tagz.HTMLParserTestCase.test_broken_invalid_end_tag�s3��
:����b�)�$�#�6�8��	
����h�'rc��d}dddgfddgfddddgfd	d
ddd
gfdddgfddddg}|j||�d}ddgd�fddgfddddgfd	d
g}|j||�y)Nz[<div style=""    ><b>The <a href="some_url">rain</a> <br /> in <span>Spain</span></b></div>rry�r�r�r�)rzThe r)r��some_url)r�rainr��r� r$r�)rz in �span)r�Spain�r'rr�rzz><div style="", foo = "bar" ><b>The <a href="some_url">rain</a>)r���,N)r�r�rir�s   r�$test_correct_detection_of_start_tagsz7HTMLParserTestCase.test_correct_detection_of_start_tags�s���9������0�
��b�!��
��3�4�5����
�D�"�%��
���$�����
�� 	
����h�'�O��
�� L�M�
��b�!��
��3�4�5���

��	
����h�'rc�d�ddgfddgfdgd�fddd	gfg}|D]\}}|j||��y)
N�a&)rr
za&b)r�abza&b )�rr�r8r�rza&b;rr
ri)rrr
r�s    r�test_EOF_in_charrefz&HTMLParserTestCase.test_EOF_in_charrefsV���N�#�$�
�^�$�%�
�G�H�
�m�%7�8�9�	
��#�N�D�(��O�O�D�(�+�#rc�4�d}gd�}|j||�y)Nz�<! not really a comment ><! not a comment either --><! -- close enough --><!><!<-- this was an empty comment><!!! another bogus comment !!!>))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 !!!rir�s   r�test_broken_commentsz'HTMLParserTestCase.test_broken_commentss ��2��

��	
����h�'rc�p�d}dddddddgfdd	dd
dgfddd
dgfdddddd
dgfdg}|j||�y)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]>)r>zif !(IE))rzbroken condcom)r>�endif)r>zif ! IEr$�link)r�zfavicon.tiff)r>zif !IE 6ro)rpzfirefox.png)r>zif !ie 6rr�)rr�r�)r>zif (!IE)|(lt IE 9))rpzmammoth.bmprir�s   r�test_broken_condcomsz'HTMLParserTestCase.test_broken_condcoms.s~��M��
)�&�%�'�
�F�%=�$>�?�%�(�
�E�$:�#;�<�%�(�
��b�!���%�2�
�E�$:�#;�<�%�#
��&	
����h�'rc��td��}|jd�|j|j�dddgfddd	g�y)
NTrUzfoo <a>link</a> bar &amp; baz)rzfoo rr)rrr�)rz
 bar & baz)rrZ�assertEqualr)rrs  r�"test_convert_charrefs_dropped_textz5HTMLParserTestCase.test_convert_charrefs_dropped_textOsO�� ��6�����3�4��������
�
�C��4�6F�
�4�
6�	
rN) r@rArBrjrur{r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrCrrrgrgks�����@��	��
�
L�4�<:�0�#�@�>I�,(�"(�%/�R2�B�&(�>K�J�(�4
(�(�B,�(� (�B

rrgc�r�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�AttributesTestCasec��ddgd�fg}|jd|�|jd|�|jd|�|jd|�y)Nrr))r��v)�cr)�dr)�eNz<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>rir�s  r�test_attr_syntaxz#AttributesTestCase.test_attr_syntax^sR���s�M�
N�
��	
���3�V�<����:�F�C����C�V�L����C�V�Lrc��|jdddgd�fg�|jdddddgfg�|jddd	d
gfg�|jddddgfg�y)
Nz'<a b='xxx
	xxx' c="yyy	
yyy" d='	xyz
'>rr))r�zxxx
	xxx)rzyyy	
yyy)rz	xyz
z
<a b='' c="">)r�r�)rr�z<e a=rgb(1,2,3)>r)rz
rgb(1,2,3)z<a href=mailto:xyz@example.com>)r�zmailto:xyz@example.comrirWs r�test_attr_valuesz#AttributesTestCase.test_attr_valuesgs������K�$�c�,>�?�@�	A�	
���+�$�c�I�y�+A�B�C�	E�	
���*�$�c�,?�+@�A�B�	D�	
���-��#� B�C�
D�E�	Grc��|jdddddgfg�|jddddd	gfg�|jd
dddd	gfg�y)Nu!<img src=/foo/bar.png alt=中文>rro)rpz/foo/bar.png)�altu中文u+<a title='テスト' href='テスト.html'>r)�titleu	テスト)r�uテスト.htmlu+<a title="テスト" href="テスト.html">rirWs r�test_attr_nonasciiz%AttributesTestCase.test_attr_nonasciivs������5��%�"9�"9�";�<�
=�	>�	
���K��#� ?� C� E�F�
G�	H�	
���K��#� ?� C� E�F�
G�	Hrc�2�|jddddgfg�y)Nz!<a b='&amp;&gt;&lt;&quot;&apos;'>rr)r�z&><"'rirWs r�test_attr_entity_replacementz/AttributesTestCase.test_attr_entity_replacement�s!�����/��#��0�
1�2�	4rc�4�|jdddgd�fg�y)Nz<a a.b='v' c:d=v e-f=v>rr))za.br)zc:dr)ze-frrirWs r�test_attr_funky_namesz(AttributesTestCase.test_attr_funky_names�s �����%��#�I�
J�K�	Mrc�2�|jddddgfg�y)Nz0<html foo='&euro;&amp;&#97;&#x61;&unsupported;'>rr
)r�u€&aa&unsupported;rirWs r�test_entityrefs_in_attributesz0AttributesTestCase.test_entityrefs_in_attributes�s#�����>��&�#D�"E�
F�G�	Irc�F�|jddddgfdddgfdddgfg�y)	Nz<a $><b $=%><c \=/>rr)r�Nr�)r��%r)�\�/rirWs r�test_attr_funky_names2z)AttributesTestCase.test_attr_funky_names2�s:�����"��#��}�
-��#�
�|�
,��#��}�
-�
/�	0rc��dD]P}|jd|zdddgfg�|jd|zdddgfg�|jd|zdddgfg��Ry)N)�&z&amp;z&#38;z&#x26;z
<a href="%s">rr)r�r2z
<a href='%s'>z<a href=%s>ri)rrms  r� test_entities_in_attribute_valuez3AttributesTestCase.test_entities_in_attribute_value�su��7�F��O�O�O�f�4�(�#�
��?�@�
B��O�O�O�f�4�(�#�
��?�@�
B��O�O�M�F�2�(�#�
��?�@�
B�8rc�h�d}dddgfdddddgfddddd	gfd
ddddgfddg}|j||�y)
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 - bad1r�)r�ztest'+style='color:red;ba2')rztest - bad2)r�utest' style='color:red;bad3')rztest - bad3)r�utest' style='color:red;bad4')rztest - bad4rir�s   r�test_malformed_attributesz,AttributesTestCase.test_malformed_attributes�sr��
L�	
���F�G�H�#�_�
��F�G�H�#�_�
��J�K�L�#�_�
��J�K�L�#�_�	
��	
����h�'rc�x�|jdddgfddddgfdg�|jd	ddgfdddd
gfdg�y)Nz<x><y z=""o"" /></x>rr�r$r�)r�r�)zo""N)r'r�z<x><y z="""" /></x>)z""NrirWs r�"test_malformed_adjacent_attributesz5AttributesTestCase.test_malformed_adjacent_attributes�sd�����.�$�c�2�.�*�C�)�]�1K�L�+�-�	.�	
���-�$�c�2�.�*�C�)�\�1J�K�+�-�	.rc�d�|jdddddgfg�|jdddddgfg�y)	Nz<a width="100%"cellspacing=0>rr�r�z100%��cellspacing�0z<a id="foo"class="bar">)�idr���classr�rirWs r�test_adjacent_attributesz+AttributesTestCase.test_adjacent_attributes�sT�����7�$�c�,�.A�B�D�E�	F�	
���1�$�c�(�/�:�<�=�	>rc�2�|jddddgfg�y)Nz<a v=>rr)rr�rirWs r�test_missing_attribute_valuez/AttributesTestCase.test_missing_attribute_value�s������$�c�I�;�7�8�	:rc�2�|jddddgfg�y)Nz-<a href=javascript:popup('/popup/help.html')>rr)r�z$javascript:popup('/popup/help.html')rirWs r�test_javascript_attribute_valuez2AttributesTestCase.test_javascript_attribute_value�s)�����G�$�c�K�L�N�O�	Prc�6�|jddddgfddg�y)Nz-<a href='http://www.example.org/">;'>spam</a>rr)r�zhttp://www.example.org/">;)r�spamr�rirWs r�test_end_tag_in_attribute_valuez2AttributesTestCase.test_end_tag_in_attribute_value�s,�����H�$�c�B�C�E�)�?�<�	=rc��d}ddgfddddgfddgd�fdd	gfdd
dgfddd
gfddddgfdddgfdddddddgfdddgfddddg}|j||�y)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)�bgcolor�d0ca90)r��181008�table)r:)�cellpaddingr�r9�tr�td)�align�left�font)�sizez-1)rz- r)r�z/rabota/r)r?�en)rz software-and-irr�)r�z/1/)rz library)r'rMrir�s   r�test_with_unquoted_attributesz0AttributesTestCase.test_with_unquoted_attributes�s���M�����$�
��"7�9K�!L�M�
��O�
Q�
��r�"�
�� 1�2�3�
��.�!1�2��Z��/C�.D�E�
��/�!2�3�5P����Z���.?�@�
��/�!2�3�5I���1D�
��	
����h�'rc��d}dddgfddddgfddddgfddgd	�fdddd
gfddddgfddd
dgfddddgfddddgfg	}|j||�y)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">rry)r?zbar,baz=asdr>)z,baz�asd)r?zbar,)�bazzasd,)r>r)rYrXrr)r?z,bar)rYz,asd)r?z,"bar")rYz,"asd")z,classr�)zclass,r�)zbaz,rXrir�s   r�test_comma_between_attributesz0AttributesTestCase.test_comma_between_attributes�s���0����!9� ;�<�
��!1�?� C�D�
��!2�O� D�E�
��!>�
?�
��!1�;� ?�@�
��!2�O� D�E�
��!4�6G� H�I�
��!2�O� D�E�
��!2�O� D�E�
��	
����h�'rc�2�|jddddgfg�y)Nz<form action=bogus|&#()value>r�form)�actionzbogus|&#()valuerirWs r�-test_weird_chars_in_unquoted_attribute_valuesz@AttributesTestCase.test_weird_chars_in_unquoted_attribute_valuess)�����7�'��!>� ?�A�:B�	CrN)r@rArBrr!r%r'r)r+r0r3r5r7r@rBrDrGrVrZr^rCrrrr\s_��M�
G�
H�4�
M�
I�0�B�(�(	.�>�:�P�
=�(�0(�8Crrc�>�eZdZed�ed�d���Zy)�TestInheritancez_markupbase.ParserBase.__init__z_markupbase.ParserBase.resetc��td�5}t�|j�|j�ddd�y#1swYyxYw)Nz_markupbase.ParserBase)rr�assert_called_once)r�super_reset_method�super_init_method�parser_bases    r�test_base_class_methods_calledz.TestInheritance.test_base_class_methods_calleds9���+�
,�����0�0�2��1�1�3�-�
,�
,�s�+A�A	N)r@rArBrrfrCrrr`r`s(��
�,�-�
�)�*�4�+�.�4rr`�__main__)�html.parserr
r]�unittest�
unittest.mockrrrrrErJ�TestCaserRrgrr`r@�mainrCrr�<module>rms�����
���6,�T�[�[�+�+�6,�rA�.�A�L�^�L�E�8�$�$�E�0n
��n
�bzC��zC�z4�h�'�'�4��z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists