Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_xml_etree.cpython-39.pyc

a

��gh{�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZmZddlmZddlmZmZmZmZmZmZdadaeddd�Zze�d	�Wney�e� d
��Yn0eddd�Z!eddd�Z"d
Z#dZ$dZ%dZ&dZ'dZ(dd�dd�Z)dd�Z*Gdd�dej+�Z,dpdd�Z-dd �Z.Gd!d"�d"�Z/Gd#d$�d$ej+�Z0Gd%d&�d&ej+�Z1iZ2d'e2d(<d)e2d*<d+e2d,<d-e2d.<d/e2d0<d1e2d2<d3e2d4<d5e2d6<d7�3e�4ed��e2d8<d9e2d:<iZ5d;e5d<<d=e5d><d?e2d@<dAe2dB<dCe2dD<GdEdF�dFej+�Z6GdGdH�dHej+�Z7GdIdJ�dJe/ej+�Z8GdKdL�dLe/ej+�Z9GdMdN�dNe:�Z;e:j<e;_<GdOdP�dPe:�Z=e:j<e=_<GdQdR�dRe/ej+�Z>GdSdT�dTej+�Z?GdUdV�dVej+�Z@GdWdX�dXej+�ZAGdYdZ�dZej+�ZBGd[d\�d\ej+�ZCGd]d^�d^ej+�ZDGd_d`�d`ej+�ZEGdadb�dbej+�ZFGdcdd�ddej+�ZGGdedf�dfej+�ZHGdgdh�dhej+�ZIdidj�ZJGdkdl�dlej+�ZKdqdmdn�ZLeMdok�r�eL�dS)r�N)�partial)�product�islice)�support)�TESTFN�findfile�import_fresh_module�
gc_collect�	swap_attr�	swap_itemz
simple.xml�xmltestdata�Zsubdir�utf-8z!filename is not encodable to utf8z
simple-ns.xmlzexpat224_utf8_bug.xmlz�<body>
  <tag class='a'>text</tag>
  <tag class='b' />
  <section>
    <tag class='b' id='inner'>subtext</tag>
  </section>
</body>
zz<section>
  <tag class='b' id='inner'>subtext</tag>
  <nexttag />
  <nextsection>
    <tag />
  </nextsection>
</section>
zy
<body xmlns="http://effbot.org/ns">
  <tag>text</tag>
  <tag />
  <section>
    <tag>subtext</tag>
  </section>
</body>
z�
<root>
<h:table xmlns:h="hello">
  <h:tr>
    <h:td>Apples</h:td>
    <h:td>Bananas</h:td>
  </h:tr>
</h:table>

<f:table xmlns:f="foo">
  <f:name>African Coffee Table</f:name>
  <f:width>80</f:width>
  <f:length>120</f:length>
</f:table>
</root>
zy<!DOCTYPE points [
<!ENTITY % user-entities SYSTEM 'user-entities.xml'>
%user-entities;
]>
<document>&entity;</document>
zl<!DOCTYPE points [
<!ENTITY entity SYSTEM "file:///non-existing-file.xml">
]>
<document>&entity;</document>
F)�quietcs��fdd�}|S)Ncs ���fdd�}t�|��|S)NcsBtj�d�i���|i|��Wd�n1s40YdS)Nr)rZcheck_warnings)�args�kwargs)�filtersr�test��//usr/local/lib/python3.9/test/test_xml_etree.py�newtestmsz1checkwarnings.<locals>.decorator.<locals>.newtest)�	functools�update_wrapper)rr�rr)rr�	decoratorlsz checkwarnings.<locals>.decoratorr)rrrrrr�
checkwarningsksrcCs|�dtj���S)N�
)�replace�os�linesep�encode)�datarrr�convlineseptsr"c@seZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree��ElementInclude��ElementPath)�	xml.etreer$r&r()�selfr$r&r(rrr�test_sanityyszModuleTest.test_sanitycCsd}tj|t|dd�dS)N)�xml.etree.ElementTree�_elementtree)Z
HTML_EMPTY)Z	blacklist)rZcheck__all__�ET)r*�namesrrr�test_all�szModuleTest.test_allN)�__name__�
__module__�__qualname__r+r0rrrrr#xsr#T�unicodecKsX|dkrt��}nt��}t�|�}|j|fd|i|��|rF|��S|�d�|SdS)Nr4�encodingr)�io�BytesIO�StringIOr.r$�write�getvalue�seek)�elem�	to_stringr5�options�file�treerrr�	serialize�s


rAcCsdd�|D�S)NcSsg|]
}|j�qSr��tag��.0r<rrr�
<listcomp>��z"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_list�srIc@s(eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS�N)�pyETr.�modules)�clsrrr�
setUpClass�szElementTestCase.setUpClassc
Cs�zvttj||��t�||�}Wd�n1s20Yttj||��t�|�}Wd�n1sj0YWn`tjy�}zFttdft	dfg�}	t
�d||	�||�|	�||�f�|�WYd}~n
d}~00|S)NZcETrLz%Failed to round-trip %r from %r to %r)
r�sysrM�pickle�dumps�loads�
PicklingError�dictr.rLrZ
TestFailed�get)
r*�obj�name�dumper�loader�protoZtemp�result�peZhumanrrr�pickleRoundTrip�s *,

���zElementTestCase.pickleRoundTripcCs�|�|tjtjf�|�|tjtjf�|�tt|��tt|���t||�D]\}}|�||�qNt	�
dddd�}|�||�||��dS)NrC�tail�text�attrib)�assertIsInstancer.�ElementrL�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)r*Zalice�bob�x�yZ
propertiesrrrrh�sz#ElementTestCase.assertEqualElementsN)r1r2r3�classmethodrOr^rhrrrrrJ�s
rJc@sleZdZdd�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#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYS)Z�ElementTreeTestcCs|�t|�|�dSrK)rdrA)r*r<�expectedrrr�serialize_check�szElementTreeTest.serialize_checkcs��fdd���fdd������fdd��t�d�}�|�t�|�}�|���tjdd	d
�}t�|�}��t|�d�tjdd	d
�}�fdd
���|j��|j��|j��|j	��|j
��|j��|j��|j
��|j��|j��|j��|j��|j��|j��|j��fdd�}||�d��||�d��||�d��||�d����tjtj���tjtj�dS)NcsJt|�|D]}�jt|�dd|d�q|d}|d}|dd�dS)N�z%expected one-character string, got %r��msg�� r)rerd)�string�charZ
new_string�r*rr�check_string�s�z4ElementTreeTest.test_interface.<locals>.check_stringcsRt|�|��}|��}|D]}||}qd|d<�j|ddd|dd�dS)N�value�keyzexpected value string, got %rrs)re�keys�itemsrd)�mappingr}r~r|�itemryrr�
check_mapping�s

�z5ElementTreeTest.test_interface.<locals>.check_mappingcs��jt�|�dd�t|�}dD]0}�jt||�d|d��j||d|d�q �|j��|j�|jdurz�|j�|j	dur��|j	�|D]}�|�q�dS)Nznot an elementrs)rCrar`r_zno %s memberzno %s visible by dir)
�
assertTruer.Z	iselement�dir�hasattr�assertInrCrar`r_)�elementZdirelem�attrr<)�
check_elementr�rzr*rrr��s"��





z5ElementTreeTest.test_interface.<locals>.check_elementrC�tägr{�r|z^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callablers)r�r���methodryrr�check_method�s�z4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dSrK)�__next__)�it)r�rr�
check_itersz2ElementTreeTest.test_interface.<locals>.check_iter�*)r.rcr$�getroot�assertRegex�repr�append�extend�insert�remove�find�iterfind�findall�findtext�clearrV�setr}r~�iter�itertextrd�XML�
fromstring�PI�ProcessingInstruction)r*r�r@r�r)r�r�r�rzr*r�test_interface�sD	


















zElementTreeTest.test_interfacecCs�t�d�}|�|jd�d|_|�|jd�d|_|�|jd�|�|j�d|_|�|jd�d|_|�|jd�|�|j�d|_|�|jd�d|_|�|jd�|�|ji�dd	d
�|_|�|jdd	d
��ddd
�|_|�|jddd
��dS)NrC�TagZTAG�TextZTEXTZTailZTAIL�b�d)�a�c�B�D)�A�C)r.rcrdrC�assertIsNoner`r_ra)r*r�rrr�test_set_attributes*
z"ElementTreeTest.test_set_attributecCst�d�}|�|d�t�d�}|�|�|�|d�|�|�|�|d�|�d|�|�|d�|�|�|�|g�|�|d�|�|�|�t|g��|�|d�|�|�tjddd	�}|�|d
�t�d�}|�|�|�|d�|�d|�|�|d
�|�|�|�|d�|�|�|�|d
�|�	t
��}|�|�Wd�n1�s`0Y|�t|j
�d�|�|d
�|||g|dd�<|�|dd�|�|dd�|d|dg�|�|ddd�|d|dg�|dd�=|�|d
�dS)N�<body><tag/></body>�<body><tag /></body>�tag2z<body><tag /><tag2 /></body>rz<body><tag2 /><tag /></body>rCr{r�z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listrrz
<subtag />�	�)r.r�rqrcr�r�r�r�r��assertRaises�
ValueErrorrd�str�	exception)r*r<�er�Z
subelement�cmrrr�test_simpleops,sR








�

* "
�zElementTreeTest.test_simpleopscCs:|�t�d�d�|�t�d�d�|�t�d�d�dS)Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)rqr.r�ryrrr�
test_cdataXs���zElementTreeTest.test_cdatacCs|t�t�d��}tj|d�}|�|�d�jd�|�|�d�jd�tjt	d�}|�|�d�jd�|�|�d�jd�dS)Nr)r?rC�section/tagr�zelement/../empty-element�
empty-element)
r6r7�
SAMPLE_XMLr r.r$rdr�rC�SIMPLE_XMLFILE)r*Z
stringfiler@rrr�test_file_initbs�zElementTreeTest.test_file_initcCs�ddlm}t�t�}td�D]}t�|��dt|��qt	|j
�}td�D]}t�|��dt|��qN|�t	|j
�|�td�D]}t�|��dt|��q�|�t	|j
�|�td�D]}t�|��dt|��q�|�
t	|j
�d�dS)Nrr'�
z./�iXi�)r)r(r.r�r��ranger$r�r�re�_cacherdZ
assertGreaterZ
assertLess)r*r(r<�iZcache_len_10rrr�test_path_cachems
&
&&&zElementTreeTest.test_path_cachecCsZddl}t�d�}|�|�}|�|�}d|�d�_|�|d�|�|d�|�|d�dS)Nrz<tag>hello<foo/></tag>�bar�fooz<tag>hello<bar /></tag>z<tag>hello<foo /></tag>)�copyr.r��deepcopyr�rCrq)r*r��e1�e2�e3rrr�	test_copy|s


zElementTreeTest.test_copycCs&t�d�}|�d�|�|�dd�d�|�dd�|�|�d�d�tjddd�}|�|�d�d�|�|jddi�ddi}t�d|�}|��|�|�d�d�|�|jddi�ddi}tjdi|��}|��|�|�d�d�|�|jddi�tjdddidd�}|�|�d�d�|�|jddi�t�d�}d|_|�d	d
�|�dd�|�t�|�d
�|�t	|�
��d	dg�|�t	|���ddg�|�|jdd�d|jd<d|jd<|�t�|�d�t�d�}|�dd�|�dd�|�dd�|�dd�|�t�|�d�dS)NrCr|�defaultr{r��otherrZaa�testa�testval�testb�test2s-<test testa="testval" testb="test2">aa</test>)r�r�)r�r�Ztest1Ztestcs;<test testa="testval" testb="test1" testc="test2">aa</test>r��
r��
r�z	

 r�z



		  s[<test a="&#13;" b="&#13;&#10;" c="&#09;&#10;&#13; " d="&#10;&#10;&#13;&#13;&#09;&#09;  " />)rC)r.rcrVrdr�rar�r`�tostring�sortedr}r~)r*r<rarrr�test_attrib�s\


��

�
�zElementTreeTest.test_attribcCs�t�d�}ddi}|�d|�}|j|j|dd�|�|�|�|d�|��|�|d�|�|�|�|d�|�||g�|�|d	�|g|dd�<|�|d�t	|g�|dd�<|�|d�dS)
NrCr|r{r�zattrib aliasingrsz!<tag><subtag key="value" /></tag>�<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r.rcZmakeelement�assertIsNotrar�rqr�r��tuple)r*r<ra�subelemrrr�test_makeelement�s$


�z ElementTreeTest.test_makeelementcCs�t�t�}t��}|j|dd�|�|��d�t�t�}t��}|j|dd�|�|��d�t	t��}|�
�}Wd�n1s�0Yt��}|�|j
d�|�|�|�|��d�t��}tj|d�}|�|�|�|��d�dS)Nr4�r5zi<root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>z�<ns0:root xmlns:ns0="namespace">
   <ns0:element key="value">text</ns0:element>
   <ns0:element>text</ns0:element>tail
   <ns0:empty-element />
</ns0:root>z^Expat ��target)r.�parser�r6r8r9rdr:�SIMPLE_NS_XMLFILE�open�read�	XMLParserr��version�feedrq�close�TreeBuilder)r*r@�stream�fr!�parserr�rrr�test_parsefile�s4

�

�
&

�

�zElementTreeTest.test_parsefilecCs�t�d�}|�tj|dd�d�t�d�}|�tj|dd�d�gd�}t�|�}|�t�|�d�|�d�t�|��d�|�t�|d�d�t�d�\}}|�t	|�d	�t�d
�\}}|�t	|�d�|�|dj
d�dS)
N�<html><body>text</body></html>r4r�)z<html><body>ztext</boz
dy></html>�<html><body>text</body></html>rG�asciisE<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>rz(<html><body id='body'>text</body></html>rr�body)r.r�rdr�r�Zfromstringlist�join�tostringlistZXMLIDrerC)r*r�Zsequence�_Zidsrrr�test_parseliterals0
�
�
���z!ElementTreeTest.test_parseliteralc	Cs8tj}|t�}t|�\}}|�||jfd�|�dd�|D�gd��|�|jjd�|t�}|�dd�|D�gd��d}|t|�}|�d	d�|D�g�d}|t|d
�}|�dd�|D�g�d}|t|�}|�d
d�|D�gd��d}|t|�}|�dd�|D�gd��d}|t�	d�|�}dd�|D�}|�|ddg�d}t
td��R}|�t��}|||�Wd�n1�s�0Y|�
|j�Wd�n1�s�0Y|�t|j�d�t�|��Z|�t��}|t|�Wd�n1�s0Y|�t|j�d�~Wd�n1�s40Yt�d�}	d}||	|�}|�dd�|D�ddg�t�	d�}	||	�}
t|
�\}}|�||jfd �|�tj��}t|
�Wd�n1�s�0Y|�t|j�d!�|�tjt�t
td"��}|�d#�Wd�n1�s"0Y|t�}
t|
�\}}|�||jfd �t�|��\|�tj��}t|
�Wd�n1�s�0Y|�t|j�d!�~~
Wd�n1�s�0Yt�|��|t�}
~
Wd�n1�s�0Y|�t��|d$�Wd�n1�s*0YdS)%N��endr�cSsg|]\}}||jf�qSrrB�rE�actionr<rrrrFrGz2ElementTreeTest.test_iterparse.<locals>.<listcomp>)r��r�r��r��rootrcSsg|]\}}||jf�qSrrBr�rrrrF'rG)�r��{namespace}elementr�r��{namespace}empty-element�r��{namespace}rootrcSsg|]\}}||jf�qSrrBr�rrrrF0rG��eventscSsg|]\}}||jf�qSrrBr�rrrrF4rG��startr�cSsg|]\}}||jf�qSrrBr�rrrrF8rG��rr�rr�r�rr�)rr�rr)rr��start-ns�end-nscSs*g|]"\}}|dvr||jfn||f�qS)rrBr�rrrrFEs�)
�r)ru�	namespace�rr�rrrrr�rrrr�rN�rrz<root xmlns=''/>cSsg|]\}}|�qSrrr�rrrrFVrGrr�rr�Zbogus�rbzunknown event 'bogus's�<?xml version='1.0' encoding='iso-8859-1'?>
<body xmlns='http://&#233;ffbot.org/ns'
      xmlns:cl�='http://effbot.org/ns'>text</body>
)rcSsg|]\}}||f�qSrrr�rrrrFlrG)r)ruuhttp://éffbot.org/ns)r)uclé�http://effbot.org/nsz<document />junk)r��documentz.junk after document element: line 1, column 12�wbs<document />junkZnonexistent)r.�	iterparser��nextrdrCrr�r6r8r�r�r��assertFalse�closedr�r�rZcheck_no_resource_warningr7�
ParseError�
addCleanup�unlinkrr9�FileNotFoundError)r*r�contextr�r<r
�resr�r��sourcer�rrr�test_iterparses�



��*,*"�
�
(�*(�$"zElementTreeTest.test_iterparsecCs�t�d�}d|_|�|d�dt�|d�_|�|d�d|_|�|d�|�dt�d	��|�|d
�t�dd�|d<|�|d
�dS)NrCr`z<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>r|r{z)text<?key value?><subtag>subtext</subtag>)	r.rcr`rq�
SubElementrCr��Commentr��r*r<rrr�test_writefile�s
�zElementTreeTest.test_writefilecCs�tt��}|��}Wd�n1s&0YGdd�dt�}|�}tj|d�}|�|�|�|gd��tt��}|��}Wd�n1s�0YGdd�dt�}|�}tj|d�}|�|�|�|gd��dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)�4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|�d|f�dS�Nr�r��r*rCrarrrr�s�:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|�d|f�dS�Nr�r2�r*rCrrrr��s�8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdSrKr�r*r`rrrr!�s�9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r1r2r3rr�r!rrrr�Builder�sr:r�r
c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r0cSs|�d|f�dSr1r2r3rrrr�sr4cSs|�d|f�dSr5r2r6rrrr��sr7cSsdSrKrr8rrrr!�sr9cSs|�d||f�dS)N�pir2)r*r�r!rrrr;�sz7ElementTreeTest.test_custom_builder.<locals>.Builder.picSs|�d|f�dS)Nr+r2)r*r!rrrr+�sz<ElementTreeTest.test_custom_builder.<locals>.Builder.commentcSs|�d||f�dS)Nrr2)r*�prefix�urirrr�start_ns�sz=ElementTreeTest.test_custom_builder.<locals>.Builder.start_nscSs|�d|f�dS�Nrr2�r*r<rrr�end_ns�sz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_nsN)
r1r2r3rr�r!r;r+r>rArrrrr:�s))r;r;r!)r+�	 comment )rrurrrrrrrrr�rru)	r�r�r�rfr.r�r�rdr�)r*r�r!r:�builderr�rrr�test_custom_builder�s
&

&
z#ElementTreeTest.test_custom_buildercCsFGdd�dt�}|�}tj|d�}|�t�d��|�|gd��dS)Nc@seZdZdd�ZdS)z@ElementTreeTest.test_custom_builder_only_end_ns.<locals>.BuildercSs|�d|f�dSr?r2r@rrrrA�szGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_nsN)r1r2r3rArrrrr:�sr:r�a            <?pi data?>
            <!-- comment -->
            <root xmlns='namespace' xmlns:p='pns' xmlns:a='ans'>
               <a:element key='value'>text</a:element>
               <p:element>text</p:element>tail
               <empty-element/>
            </root>
            ))rr�)r�prC)rfr.r�r��textwrap�dedentrd)r*r:rDr�rrr�test_custom_builder_only_end_ns�s
	z/ElementTreeTest.test_custom_builder_only_end_nscCs8tjdd�}|�|jtj�t��}|�|jtj�dS)Nr�)r.r�rbr�r�)r*r��parser2rrr�%test_initialize_parser_without_target�sz5ElementTreeTest.test_initialize_parser_without_targetcCs|ttd��}t�|�}Wd�n1s*0Y|�dd�|����D�gd�gggg�|�dd�|��D�gd�gggg�t�t�}|�t	t
|��d�|�t	t
|d��d�|�|dd�t
|��|d	}|d}|dd�=|�t	t
|��d�|�||d	�|�||d�||g|d	d�<|�||d	�|�||d�|�||d	�|��|�t
|�g�dS)
NrcSsg|]}t|��qSr�rIrDrrrrFs�z1ElementTreeTest.test_children.<locals>.<listcomp>)r�r�r�cSsg|]}t|��qSrrLrDrrrrFs��r�rrr)
r�r�r.r�rdr�r�r�r�rerf�assertNotEqualr�)r*r�r@r<�child1�child2rrr�
test_children�sH(

���
���

zElementTreeTest.test_childrencCs<t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nr�r�)r.r�rdr�r�r.rrr�test_writestring!s

z ElementTreeTest.test_writestringcCs�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d	�t�d
�}t�|�|�t�|�d�dS)Nz
<root></root>s<root />r�s"<html>
  <body>text</body>
</html>z!<html> <body>text</body>  </html>z"<html><body>text</body>tail</html>s%<html>
  <body>text</body>tail</html>z=<html><body><p>par</p>
<p>text</p>	<p><br/></p></body></html>s^<html>
  <body>
    <p>par</p>
    <p>text</p>
    <p>
      <br />
    </p>
  </body>
</html>�8<html><body><p>pre<br/>post</p><p>text</p></body></html>sJ<html>
  <body>
    <p>pre<br />post</p>
    <p>text</p>
  </body>
</html>�r.r��indentrdr�r.rrr�test_indent's0









�

�zElementTreeTest.test_indentcCsXt�d�}tj|dd�|�t�|�d�t�d�}tj|dd�|�t�|�d�dS)NrS�	)�spacesD<html>
	<body>
		<p>pre<br />post</p>
		<p>text</p>
	</body>
</html>rus><html>
<body>
<p>pre<br />post</p>
<p>text</p>
</body>
</html>rTr.rrr�test_indent_spaceSs
�

�z!ElementTreeTest.test_indent_spacecCs�t�d�}t�|�|�dd�|��D�hd��|�dd�|��D�hd��|�tdd�|��D��tdd�|��D���dS)	Nz@<html><body><p>par</p><p>text</p><p><br/></p><p /></body></html>cSsh|]
}|j�qSr�r_�rE�elrrr�	<setcomp>prGz<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>>�
    �
�
  NcSsh|]
}|j�qSr�r`r[rrrr]trG>Zparz
      r^r`Nr`cSsh|]
}|j�qSrrZr[rrrr]xrGcSsh|]}t|j��qSr)�idr_r[rrrr]yrG)r.r�rUrdr�rer.rrr�test_indent_space_cachingls

���z)ElementTreeTest.test_indent_space_cachingcCs�t�d�}|�t��tj|dd�Wd�n1s80Y|�t�|�d�tj|dd�|�t�|�d�t�d�}tj|ddd	�|�t�|�d
�dS)NrS���)�levels9<html><body><p>pre<br />post</p><p>text</p></body></html>r�s^<html>
      <body>
        <p>pre<br />post</p>
        <p>text</p>
      </body>
    </html>rrrv)rerXsI<html>
  <body>
   <p>pre<br />post</p>
   <p>text</p>
  </body>
 </html>)r.r�r�r�rUrdr�r.rrr�test_indent_level|s$
,��

�z!ElementTreeTest.test_indent_levelcCs<t�d�}|�tj|dd�d�|�tj|ddd�d�dS)N�0<body xmlns="http://effbot.org/ns"><tag/></body>r4r��A<ns0:body xmlns:ns0="http://effbot.org/ns"><ns0:tag /></ns0:body>r�r5�default_namespace�1<body xmlns="http://effbot.org/ns"><tag /></body>�r.r�rdr�r.rrr�test_tostring_default_namespace�s
��z/ElementTreeTest.test_tostring_default_namespacecCs&t�d�}|�tj|ddd�d�dS)Nrgr4�foobarrizP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>rlr.rrr�3test_tostring_default_namespace_different_namespace�s

�zCElementTreeTest.test_tostring_default_namespace_different_namespacecCsNt�d�}d}|�t|�� tj|ddd�Wd�n1s@0YdS)Nr�z>^cannot use non-qualified names with default_namespace option$r4rnri)r.r��assertRaisesRegexr�r�)r*r<ZEXPECTED_MSGrrr�5test_tostring_default_namespace_original_no_namespace�s
zEElementTreeTest.test_tostring_default_namespace_original_no_namespacecCs$t�d�}|�tj|dd�d�dS)Nr�r4r�r�rlr.rrr� test_tostring_no_xml_declaration�s

�z0ElementTreeTest.test_tostring_no_xml_declarationcCs&t�d�}|�tj|ddd�d�dS)Nr��utf8T�r5�xml_declarations:<?xml version='1.0' encoding='utf8'?>
<body><tag /></body>rlr.rrr�test_tostring_xml_declaration�s

�z-ElementTreeTest.test_tostring_xml_declarationcCs&t�d�}|�tj|ddd�d�dS)Nr�r4Trt�;<?xml version='1.0' encoding='utf-8'?>
<body><tag /></body>rlr.rrr�.test_tostring_xml_declaration_unicode_encoding�s

�z>ElementTreeTest.test_tostring_xml_declaration_unicode_encodingc	Cstt�d�}gd�}|D]X\}}}|�d|�d|����(|�tj|||d�|�Wd�q1sd0YqdS)N�<body><tag>ø</tag></body>))�<body><tag>&#248;</tag></body>NN)�<body><tag>ø</tag></body>�UTF-8N)rz�US-ASCIIN)�E<?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag>�</tag></body>�
ISO-8859-1N)ryr4N)rzNF)r{r|F)rzr}F)s<body><tag>�</tag></body>rF)ryr4F)sH<?xml version='1.0' encoding='us-ascii'?>
<body><tag>&#248;</tag></body>NT)sA<?xml version='1.0' encoding='UTF-8'?>
<body><tag>ø</tag></body>r|T)sH<?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>r}T)r~rT)uA<?xml version='1.0' encoding='utf-8'?>
<body><tag>ø</tag></body>r4Tz	encoding=z xml_declaration=rt)r.r��subTestrdr�)r*r<Z	TESTCASESZexpected_retvalr5rurrr�#test_tostring_xml_declaration_cases�s
�
��z3ElementTreeTest.test_tostring_xml_declaration_casesc	CsHt�d�}|�d�tj|dd��d�|�d�tj|ddd��d�dS)	Nrgrur4r�rhrrirk)r.r�rdr�r�r.rrr�#test_tostringlist_default_namespace�s
��z3ElementTreeTest.test_tostringlist_default_namespacecCs�t�d�}|�d�tj|dd��d�|�d�tj|dd��d	�tj|ddd
�}|�d�|�d�|�|dd
�|�gd�|dd��dS)Nr�rur4r�r�rGT)rus><?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>rtrwrz%^<\?xml version='1.0' encoding='.+'?>)z<body�>z<tagz />z</body>rr)r.r�rdr�r�r�)r*r<Z
stringlistrrr�!test_tostringlist_xml_declarations 
���z1ElementTreeTest.test_tostringlist_xml_declarationc	sd�fdd�	}|dd�|dd�|dd�|d	d
�|dd�|d
d�dd���fdd�}gd�}|D] }��t�t�||���d�qjgd�}|D]}��ttj||��q�gd�}|D]}��tjtj||��q���ttj�d��d����ttj�d��d��dS)Nrucs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)rdr.r�r r`)r5r��xmlryrr�checks
�z,ElementTreeTest.test_encoding.<locals>.checkr�r��us-ascii�
iso-8859-1�½ziso-8859-15u€�cp437u√�	mac-romanu˚cSsd|S)Nz*<?xml version='1.0' encoding='%s'?><xml />rr�rrrr� sz*ElementTreeTest.test_encoding.<locals>.xmlcs�|��|�SrK)r r�)r�rr�bxml"sz+ElementTreeTest.test_encoding.<locals>.bxml)Cr�rz	utf-8-sig�utf-16�utf-16be�utf-16lez	iso8859-1z	iso8859-2z	iso8859-3z	iso8859-4z	iso8859-5z	iso8859-6z	iso8859-7z	iso8859-8z	iso8859-9z
iso8859-10z
iso8859-13z
iso8859-14z
iso8859-15z
iso8859-16r�Zcp720Zcp737�cp775�cp850�cp852�cp855Zcp856�cp857�cp858�cp860�cp861�cp862�cp863�cp865�cp866�cp869Zcp874Zcp1006�cp1125�cp1250�cp1251�cp1252�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258zmac-cyrillicz	mac-greekzmac-icelandz
mac-latin2r�zmac-turkishz
iso2022-jpziso2022-jp-1ziso2022-jp-2ziso2022-jp-2004ziso2022-jp-3ziso2022-jp-extzkoi8-rzkoi8-tzkoi8-u�kz1048�hz�ptcp154s<xml />)�big5�	big5hkscs�cp932�cp949�cp950zeuc-jpzeuc-jis-2004zeuc-jisx0213zeuc-kr�gb2312�gbk�gb18030z
iso2022-kr�johabz	shift-jiszshift-jis-2004zshift-jisx0213zutf-7)
�cp037�cp424�cp500�cp864Zcp875�cp1026�cp1140�utf_32�	utf_32_be�	utf_32_leZ	undefinedZxxx)ru)	rdr.r�r�r�r�r"r �LookupError)r*r�r�Zsupported_encodingsr5Z&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr�r*r�r�
test_encodings(





	zElementTreeTest.test_encodingcCstt�d�}d|_|�t|�d�|�t|dd�d�|�t|dd�d�|�t|dd�d�|�t|dd�d	�dS)
Nz-<html><link/><script>1 &lt; 2</script></html>r_z/<html><link /><script>1 &lt; 2</script></html>
r�r��htmlz*<html><link><script>1 < 2</script></html>
r`z1 < 2
)r.r�r_rdrA�r*r�rrr�test_methodsNs

����zElementTreeTest.test_methodscCs2t�d�}|�t|�d�|�t|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>r�r��r.r�rdrAr�rrr�test_issue18347]s

��zElementTreeTest.test_issue18347cCs8t�d�}|�t|dd�d�|�|d�|�tj��}t�d�Wd�n1sV0Y|�t|j�d�|�tj��}t�t	�Wd�n1s�0Y|�t|j�d�t�
�}d	|jd
<|�t	�|�
�}|�|d�|�tj��}t�t�Wd�n1�s0Y|�t|j�d�dS)
Nz*<document title='&#x8230;'>test</document>r�r�s*<document title="&#33328;">test</document>u%<document title="舰">test</document>z<document>&entity;</document>z#undefined entity: line 1, column 10z,undefined entity &entity;: line 5, column 10r`�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r.r�rdrArqr�r"r�r��
ENTITY_XMLr�r�r�r��EXTERNAL_ENTITY_XML)r*r�r�r�rrrr�test_entityds2
�(�(�

*�zElementTreeTest.test_entitycCsrt�d�}|�|d�t�d�}|�|d�t�d�}|�|d�t�d�}|�|d�t�t�}|�|d	�dS)
Nz<tag xml:lang='en' />z<tag xml:lang="en" />zC<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' />zC<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />z7<html:html xmlns:html='http://www.w3.org/1999/xhtml' />z7<html:html xmlns:html="http://www.w3.org/1999/xhtml" />zG<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope' />zE<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope" />z�<ns0:body xmlns:ns0="http://effbot.org/ns">
  <ns0:tag>text</ns0:tag>
  <ns0:tag />
  <ns0:section>
    <ns0:tag>subtext</ns0:tag>
  </ns0:section>
</ns0:body>)r.r�rq�
SAMPLE_XML_NSr.rrr�test_namespace�s$

�
�
�
�zElementTreeTest.test_namespacecCs�t�d�}|�|d�t�t�d��}|�|d�t�t�dd��}|�|d�t�t�dd��}t�|t�dd��}t�|t�dd��}|�|d�|��d|jd	<|�|d
�|��d|jt�d	�<|�|d
�|��d|jd	<|�|d�|��t�d�|jd	<|�|d
�|��t�d�}t�d�|jd<|�|�|�|�|�|d�|�t	t�dd��d�|�t	t�d��d�t�dd�}t�dd�}|�||�t�dd�}|�
||�|�
|d�|�|d�dS)Nz{uri}tagz<ns0:tag xmlns:ns0="uri" />r=rCZtag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>r{z{uri}keyz+<ns0:tag xmlns:ns0="uri" ns0:key="value" />z
{uri}valuez0<ns0:tag xmlns:ns0="uri" ns0:key="{uri}value" />z/<ns0:tag xmlns:ns0="uri" ns0:key="ns0:value" />z{uri2}valuez	{uri1}keyz{<ns0:tag xmlns:ns0="uri" xmlns:ns1="uri1" xmlns:ns2="uri2"><tag ns1:key="ns2:value" /><tag ns1:key="ns2:value" /></ns0:tag>�nsz{ns}tagz	other-tagzns:tag)r.rcrq�QNamer,r�rar�rdr�rN)r*r<r�Zq1Zq2rrr�
test_qname�sb
�
��
��


�zElementTreeTest.test_qnamecCst�d�}dS)Nz�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>)r.r�r.rrr�test_doctype_public�sz#ElementTreeTest.test_doctype_publiccs�ddlm�d?��fdd�	}|ddg�|dddg�|d	d
dg�|dd
dg�|d
gd��|dgd��|dgd��|dgd��|dgd��|dddg�|dgd��|ddg�|dgd��|ddg�|d gd!��|d"gd#��|d$gd%��|d&d
d'g�|d(d(g�|d)gd*��|d+gd,��|d-d-g�|d.d.g�|d/d/g�|d0d0g�|d1gd2��|d3gd4�d5d6i�|d7d8gd9d6i�|d:d
d8gd5d6i�|d;d
d7gd9d6i�|d<d
d=gd9d6i�|d&d
d'gd6d6d>��dS)@Nrr'cs"��dd���||�D�|�dS)NcSsg|]\}}|p|�qSrr)rE�oprCrrrrF�s�zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)rdZxpath_tokenizer)rFrp�
namespaces�r(r*rrr��s


��z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkr�ztext()r`�()z@name�@rXz@*zpara[1])�para�[�1�]zpara[last()])r�r��lastr�r�z*/para)r��/r�z/doc/chapter[5]/section[2])r��docr��chapterr��5r�r��sectionr��2r�z
chapter//para)r��//r�z//parar�r�z//olist/item)r�Zolistr�r��.z.//para)r�r�r��..z../@lang)r�r�r��langzchapter[title])r�r��titler�z#employee[@secretary and @assistant])
Zemployeer�r�Z	secretaryru�andrur�Z	assistantr�z	@{ns}attrz{ns}attr�{http://spam}eggz
./spam.egg)r�r�zspam.eggz.//{http://spam}egg)r�r�r�z{ns}*�{}*�{*}tag�{*}*z	.//{*}tag)r�r�r�z
./xsd:type)r�r��&{http://www.w3.org/2001/XMLSchema}typeZxsdz http://www.w3.org/2001/XMLSchema�typer�ruz	@xsd:typez@typez@{*}typez{*}type)rur�)N)r)r()r*r�rr�r�test_xpath_tokenizer�sd�
��
�
�
�
��z$ElementTreeTest.test_xpath_tokenizercCsn|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd�d�d�dS)	NrZinstructions<?test instruction?>z
<testing&>s<?test <testing&>?>u<testing&>ãzlatin-1s=<?xml version='1.0' encoding='latin-1'?>
<?test <testing&>�?>)rdr.r�r�r�ryrrr�test_processinginstruction-s����z*ElementTreeTest.test_processinginstructioncCspdD]f}||��fD]T}d|}tt�d|�dd�}|�||�tt�d||f�dd�}|�||�qqdS)N)
ZAREAZBASEZBASEFONTZBRZCOL�FRAMEZHRZIMGZINPUTZISINDEXZLINKZMETAZPARAMz<%s>z<%s />r�r�z	<%s></%s>)�lowerrAr.r�rd)r*r�r<rpZ
serializedrrr�#test_html_empty_elems_serialization=s�z3ElementTreeTest.test_html_empty_elems_serializationcCsVtjdddd�}t���}t�|�Wd�n1s80Y|�|��d�dS)N�
cirriculum�public�example��statusZcompanyz1<cirriculum status="public" company="example" />
)r.rcr�captured_stdout�dumprdr:)r*r��stdoutrrr�test_dump_attribute_orderJs
(
�z)ElementTreeTest.test_dump_attribute_ordercCs8tjdddd�}|�t|�d�|�t|dd�d�dS)	Nr�r�r�r�z0<cirriculum status="public" company="example" />r�r�z;<cirriculum status="public" company="example"></cirriculum>)r.rcrdrA�r*rrrr�test_tree_write_attribute_orderRs
��z/ElementTreeTest.test_tree_write_attribute_orderN)/r1r2r3rqr�r�r�r�r�r�r�r�r�r�r�r)r/rErIrKrQrRrVrYrcrfrmrorqrrrvrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrro�sXV,
6-x=	%, ,;%!A:
roc@s�eZdZd.dd�Zd/dd�Zd0dd�Zd1d	d
�Zd2dd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Ze�ejd'kd(ej�d)��d*d+��Zd,d-�ZdS)3�XMLPullParserTestNFcCsP|dur|�|�n,tdt|�|�D]}|�||||��q$|rL|��dS�Nr)r�r�re�flush)r*r�r!�
chunk_sizer�r�rrr�_feed]szXMLPullParserTest._feedcCs$|�dd�t|��|�D�|�dS)NcSs g|]\}}||j|jff�qSr)rCr`)rE�eventr<rrrrFhs�z3XMLPullParserTest.assert_events.<locals>.<listcomp>)rdr�read_events�r*r�rp�
max_eventsrrr�
assert_eventsfs��zXMLPullParserTest.assert_eventscCs|�tt|��|��|�dSrK)rdrfrrrrrr�assert_event_tuplesls�z%XMLPullParserTest.assert_event_tuplescCs(t|��|�}|�dd�|D�|�dS)NcSsg|]\}}||jf�qSrrBr�rrrrFsrGz7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)rrrd)r*r�rprr
rrr�assert_event_tagsqs�z#XMLPullParserTest.assert_event_tagscCs�t��}|�|g�|�|d||�|�|g�|�|d||�|�|g�|�|d||�|�|dg�|�|d||�|�|d||�|�|ddg�|�|d||�|�|d	g�|�|���dS)
N�<!-- comment -->
z+<root>
  <element key='value'>text</element�>
r��<element>text</element>tail
�<empty-element/>
r�</root>
r�r.�
XMLPullParserrr�r�r�)r*r�r�r�rrr�test_simple_xmlvs(��z!XMLPullParserTest.test_simple_xmlcCs|jddd�dS)NrrT�r�r��r
ryrrr�test_simple_xml_chunk_1�sz)XMLPullParserTest.test_simple_xml_chunk_1cCs|jddd�dS)N�Trrryrrr�test_simple_xml_chunk_5�sz)XMLPullParserTest.test_simple_xml_chunk_5cCs|jdd�dS)N�)r�rryrrr�test_simple_xml_chunk_22�sz*XMLPullParserTest.test_simple_xml_chunk_22cCs�t��}|��}|�|d�t|�\}}|�||jfd�|�|d�t|�\}}|�||jfd�|�t��t|�Wd�n1s�0YdS)Nz-<root>
  <element key='value'>text</element>
r�r
r)	r.rrr�rrdrCr��
StopIteration)r*r�r�r�r<rrr�test_feed_while_iterating�sz+XMLPullParserTest.test_feed_while_iteratingcCs�t��}|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d�|�|ddg�|�|d	�|�|d
g�|�|���dS)Nr�<root xmlns='namespace'>
�"<element key='value'>text</elementrrrr	rr
rr�r*r�rrr�test_simple_xml_with_ns�s&�z)XMLPullParserTest.test_simple_xml_with_nscCs�tjdd�}|�|d�|�|d�|�t|���dg�|�|d�|�|d�|�|d�|�|d	�|�|d
�|�t|���dg�|�|���dS)Nrr	rrrrrrr	r
r)r.rr�rdrfrr�r�rrrr�test_ns_events�s
�z XMLPullParserTest.test_ns_eventscCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|�|dg�dS)N)rrr�r	� <tag xmlns='abc' xmlns:p='xyz'>
�r)ru�abc�r)rFZxyzr��r�r�{abc}tagrr�
<child />
�r�
{abc}child�r�r%�</tag>
�r�r"�r.rr�rrr�rrrr�test_ns_events_start�s.������z&XMLPullParserTest.test_ns_events_startcCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|j|dgd	d�|�|ddg�dS)N)rrr�rr	rrrr�r r!rrr#r$r&r'r(rr)rrrr�test_ns_events_start_end�s:��������z*XMLPullParserTest.test_ns_events_start_endcCs�tjdd�}|�|d�|�|g�tjdd�}|�|d�|�|g�tjdd�}|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|dg�|�|d�|�|gd
��|�|d�|�|���|�|dg�tjdd�}|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|g�|�|d�|�|ddg�|�|d�|�|���dS)Nrr	z<root/>
r�<!-- text here -->
z<root>
rrrrr�z8<element xmlns='foo'>text<empty-element/></element>tail
)�r�{foo}element�r�{foo}empty-element)r�r0)r�r.z</root>r)rrr-r/)r.rr�rrr�r�rrrr�test_events�sL���zXMLPullParserTest.test_eventscCstjdd�}|�|d�|�|dtjdffg�|�|d�|�|dtjdffg�|�|d�|�|d	g�|�|d
�|�|dtjdffg�|�|d�|�|d
g�|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)N)rr+r�r	r,r+z text here z<!-- more text here -->
z more text here z<root-tag>text)r�root-tagz<!-- inner comment-->
z inner commentz</root-tag>
)r�r2z<!-- outer comment -->
z outer comment )r+)r.rr�rr-rrrrr�test_events_comment$s z%XMLPullParserTest.test_events_commentcCsdtjdd�}|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)	N)rr;r�r	z
<?pitarget?>
r;�pitarget)r;z<?pitarget some text ?>
zpitarget some text )r.rr�rr�rrrr�test_events_pi7sz XMLPullParserTest.test_events_picCslddh}tj|d�}|�|d�|�|ddg�Gdd�d�}tj|�d�}|�|d�|�|ddg�dS)	Nr�rr	z<foo>bar</foo>)rr�)r�r�c@s$eZdZdd�Zdd�Zdd�ZdS)z9XMLPullParserTest.test_events_sequence.<locals>.DummyItercSstgd��|_dS)N)rr�r)r�r
ryrrr�__init__GszBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|SrKrryrrr�__iter__IszBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�SrK)rr
ryrrrr�KszBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r1r2r3r6r7r�rrrr�	DummyIterFsr8)r.rr�r)r*Zeventsetr�r8rrr�test_events_sequence?sz&XMLPullParserTest.test_events_sequencecCs:|�t��tjdd�Wd�n1s,0YdS)Nrr	)r�r�r.rryrrr�test_unknown_eventRsz$XMLPullParserTest.test_unknown_event�r��rzExpat z" does not support reparse deferralcCs�tjdd�}dD]}|�|�q|�|g�tturF|�|jj���|��|�|dg�tturv|�|jj���|�d�|�	�|�|dg�dS)Nrr	�z<docr��rr��</doc>�r�r�)
r.rr�rrLr��_parser�GetReparseDeferralEnabledr�r��r*r��chunkrrr�#test_flush_reparse_deferral_enabledVs
z5XMLPullParserTest.test_flush_reparse_deferral_enabledcCs�tjdd�}dD]}|�|�qtjdkrVttur<|�d�|jj�d�|�	|g�tturp|�
|jj���|��|�	|dg�ttur�|�
|jj���|�d�|�
�|�	|d	g�dS)
Nrr	r=r;zDXMLParser.(Get|Set)ReparseDeferralEnabled methods not available in CFr>r?r@)r.rr��pyexpat�version_inforL�skipTestrAZSetReparseDeferralEnabledrr rBr�r�rCrrr�$test_flush_reparse_deferral_disabledns"


z6XMLPullParserTest.test_flush_reparse_deferral_disabled)NF)N)N)N)NF)r1r2r3r�rrrr
rrrrrrr*r+r1r3r5r9r:�unittest�skipIfrFrGrErIrrrrr�[s.
	



.�
r�z�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <xi:include href="disclaimer.xml"/>
</document>
�C1.xmlz�<?xml version='1.0'?>
<disclaimer>
  <p>The opinions represented herein represent those of the individual
  and should not be interpreted as official policy endorsed by this
  organization.</p>
</disclaimer>
zdisclaimer.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>This document has been accessed
  <xi:include href="count.txt" parse="text"/> times.</p>
</document>
�C2.xmlZ324387z	count.txtz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>This document has been <em>accessed</em>
  <xi:include href="count.txt" parse="text"/> times.</p>
</document>
�C2b.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source of the "data.xml" resource:</p>
  <example><xi:include href="data.xml" parse="text"/></example>
</document>
�C3.xmlzQ<?xml version='1.0'?>
<data>
  <item><![CDATA[Brooks & Shields]]></item>
</data>
zdata.xmlaW<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="example.txt" parse="text">
    <xi:fallback>
      <xi:include href="fallback-example.txt" parse="text">
        <xi:fallback><a href="mailto:bob@example.org">Report error</a></xi:fallback>
      </xi:include>
    </xi:fallback>
  </xi:include>
</div>
�C5.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>Example.</p>
  <xi:include href="{}"/>
</document>
�default.xmla
<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
</document>
�include_c1_repeated.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <xi:include href="disclaimer.xml" parse="BAD_TYPE"/>
</document>
�B1.xmlzn<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:fallback></xi:fallback>
</div>
�B2.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive2.xml:</p>
  <xi:include href="Recursive2.xml"/>
</document>
�Recursive1.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive3.xml:</p>
  <xi:include href="Recursive3.xml"/>
</document>
zRecursive2.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="Recursive1.xml"/>
</document>
zRecursive3.xmlc@sHeZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�XIncludeTestr�NcCs>zt|}Wnty&td��Yn0|dkr:t�|�}|S)N�resource not foundr�)�XINCLUDE�KeyError�OSErrorr.r�)r*�hrefr�r5r!rrr�xinclude_loaders
zXIncludeTest.xinclude_loadercCsdSrKr)r*r[r�r5rrr�none_loaderszXIncludeTest.none_loadercCsJ|dkrBt|d��}t�|���Wd�S1s60YndSdS)Nr�r)r�r.r�r�)r*r[r�r�rrr�
_my_loaders.zXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nrr%rQz�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r)r&r\�includer^rdrA)r*r&r�rrr�test_xinclude_default$s

�z"XIncludeTest.test_xinclude_defaultcCsddlm}|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d	�}|�||j�|�t|�d
�|�d�}|�t��}|�||j�Wd�n1s�0Y|�t|j	�d�|�t|�d
�dS)Nrr%rLa<document>
  <p>120 Mz is adequate for an average home user.</p>
  <disclaimer>
  <p>The opinions represented herein represent those of the individual
  and should not be interpreted as official policy endorsed by this
  organization.</p>
</disclaimer>
</document>rMzO<document>
  <p>This document has been accessed
  324387 times.</p>
</document>rNzX<document>
  <p>This document has been <em>accessed</em>
  324387 times.</p>
</document>rOz�<document>
  <p>The following is the source of the "data.xml" resource:</p>
  <example>&lt;?xml version='1.0'?&gt;
&lt;data&gt;
  &lt;item&gt;&lt;![CDATA[Brooks &amp; Shields]]&gt;&lt;/item&gt;
&lt;/data&gt;
</example>
</document>rPrWaI<div xmlns:ns0="http://www.w3.org/2001/XInclude">
  <ns0:include href="example.txt" parse="text">
    <ns0:fallback>
      <ns0:include href="fallback-example.txt" parse="text">
        <ns0:fallback><a href="mailto:bob@example.org">Report error</a></ns0:fallback>
      </ns0:include>
    </ns0:fallback>
  </ns0:include>
</div>)
r)r&r\r_rdrAr�rZr�r��r*r&rr�rrr�
test_xinclude2s8

�

�

�

�
,
�zXIncludeTest.test_xincludecCs>ddlm}|�d�}|�||j�|�dt|�d���dS)Nrr%rRr�z.//p)r)r&r\r_rdrer�)r*r&rrrr�test_xinclude_repeatedrs
z#XIncludeTest.test_xinclude_repeatedcCs�ddlm}t�td�}|�|j�� }|j||jd�Wd�n1sL0Y|�	t
|j�d�t�td�}|�|j�� }|j||jd�Wd�n1s�0Y|�	t
|j�d�t�td�}|�|j�� }|j||jd�Wd�n1�s0Y|�	t
|j�d	�t�td
�}|�|j�� }|j||jd�Wd�n1�sd0Y|�	t
|j�d�|�
d�}|�|j��}|�||j
�Wd�n1�s�0Y|�	t
|j�d
�|�
d�}|�|j��"}|j||j
dd�Wd�n1�s0Y|�	t
|j�d
�|�
d�}|�|j��"}|j||j
dd�Wd�n1�st0Y|�	t
|j�d�|�
d�}|�|j��"}|j||j
dd�Wd�n1�s�0Y|�	t
|j�d�|�
d�}|�|j��"}|j||j
dd�Wd�n1�s,0Y|�	t
|j�d�|�
d�}|�|j��"}|j||j
dd�Wd�n1�s�0Y|�	t
|j�d
�dS)Nrr%rL)rZz%cannot load 'disclaimer.xml' as 'xml'rMz!cannot load 'count.txt' as 'text'rSz1unknown parse type in xi:include tag ('BAD_TYPE')rTzYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')rUz#recursive include of Recursive2.xml)Z	max_depthzAmaximum xinclude depth reached when including file Recursive2.xmlrrzAmaximum xinclude depth reached when including file Recursive3.xmlr�zAmaximum xinclude depth reached when including file Recursive1.xmlrM)r)r&r.r�rXr�ZFatalIncludeErrorr_r]rdr�r��XINCLUDE_BADr\ZLimitedRecursiveIncludeErrorrarrr�test_xinclude_failuresysz.�.�0�0�
.�
2�
2�
2�
2�
2�z#XIncludeTest.test_xinclude_failures)r�N)N)
r1r2r3r\r]r^r`rbrcrerrrrrV
s
	
	@rVc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Ze�
e��d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:S);�BugsTestcs��fdd�}t�d�}||�t�d�}d|_||�t�d�}d|_||�t�d�}|�dd�||�t�d�}|�dd�||�dS)NcsH��t��}t|�Wd�n1s(0Y��t|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorrArdr�r�)r<r�ryrrr��s
&�z-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r<Z123)r.rcr`r_r�)r*r�r<rryr�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)NrCr`r�r*)r.r�r�r$rdr�)r*r<r@rrr�test_bug_xmltoolkit25�s

zBugsTest.test_bug_xmltoolkit25cCs<t�d�}|�t|�d��g�|�t|�d��dg�dS)N�"<doc><table><tbody/></table></doc>z.//theadz.//tbodyZtbody)r.r�rdrIr��r*r@rrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28cCsPt�d�}t���*}t�|�|�|��d�Wd�n1sB0YdS)Nrkz$<doc><table><tbody /></table></doc>
)r.r�rr�r�rdr:)r*r@r�rrr�test_bug_xmltoolkitX1�s


zBugsTest.test_bug_xmltoolkitX1cCs�t�d�}|�t�|d�d�t�d�}|�|jddi�|�t�|d�d�t�d�}|�t�|d�d	�t�d
�}|�t�|d�d�t�d�}|�dd�|�t�|d�d�dS)Ns2<?xml version='1.0' encoding='iso-8859-1'?><t�g />rs<täg />sD<?xml version='1.0' encoding='iso-8859-1'?><tag �ttr='v&#228;lue' />uättruvälues<tag ättr="välue" />s:<?xml version='1.0' encoding='iso-8859-1'?><t�g>text</t�g>s<täg>text</täg>r�rC)r.r�rdr�rarcr�rlrrr�test_bug_xmltoolkit39�s$

�
�

�zBugsTest.test_bug_xmltoolkit39cCs2t�d�}|�t|dd�d�|�t|�d�dS)Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>r�r�s<doc>&#33328;</doc>u<doc>舰</doc>r�r�rrr�test_bug_xmltoolkit54s

�zBugsTest.test_bug_xmltoolkit54cCsL|�tj��}t�d�Wd�n1s,0Y|�t|j�d�dS)Ns?<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>z+undefined entity &ldots;: line 1, column 36)r�r.r"r�rdr�r�)r*r�rrr�test_bug_xmltoolkit55s
(�zBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|�ttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�dSrK)rZ�r*rlrrrr�'sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r1r2r3r�rrrr�
ExceptionFile&srs)r�rZr.r�)r*rsrrr�test_bug_xmltoolkit60#szBugsTest.test_bug_xmltoolkit60cCsHddd�}t��}|j�|�|�d�|��}|�|�d�jd�dS)Nu’u‘)ZrsquoZlsquoaF<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE patent-application-publication SYSTEM "pap-v15-2001-01-31.dtd" []>
<patent-application-publication>
<subdoc-abstract>
<paragraph id="A-0001" lvl="0">A new cultivar of Begonia plant named &lsquo;BCT9801BEG&rsquo;.</paragraph>
</subdoc-abstract>
</patent-application-publication>z.//paragraphu7A new cultivar of Begonia plant named ‘BCT9801BEG’.)	r.r�r��updater�r�rdr�r`)r*ZENTITIESr��trrr�test_bug_xmltoolkit62,s

�zBugsTest.test_bug_xmltoolkit62zSkips under coverage.cCsBdd�}|�t�d�}td�D]
}|�q |�t�d�|�dS)NcSs,t��}|�di�|�d�|�d�dS)NrCr`)r.r�rr!r�)r@rrr�xmltoolkit63@s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)rP�getrefcountr�rd)r*rx�countr�rrr�test_bug_xmltoolkit63=s
zBugsTest.test_bug_xmltoolkit63c	Cs`tjddd�}|�t�|�d�|�t�t�|���d�d�|�t�t�t�|���d�dS)NZSomeTagzdef _f():
  return 3
ras0<SomeTag text="def _f():&#10;  return 3&#10;" />r`)r.rcrdr�r�rVr�rrr�test_bug_200708_newlineLs���z BugsTest.test_bug_200708_newlinecCs`t��}|�d�|�|��jd�Gdd�d�}tj|�d�}|�d�|�|��jd�dS)Nz<element>some text</element>r�c@seZdZdd�ZdS)z2BugsTest.test_bug_200708_close.<locals>.EchoTargetcSs
t�d�S)Nr��r.rcryrrrr�_sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN�r1r2r3r�rrrr�
EchoTarget^srr�)r.r�r�rdr�rC)r*r�rrrr�test_bug_200708_closeWs

zBugsTest.test_bug_200708_closecCs�t�d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t��}t|dd�Wd�n1s�0Y|�t|j�d�dS)	Nz
{default}elemr�)rjz%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>r<z<cannot use non-qualified names with default_namespace option)	r.rcr,rdrAr�r�r�r�)r*r��sr�rrr�!test_bug_200709_default_namespacees&
�
�
*�z*BugsTest.test_bug_200709_default_namespacecCsdt�d�}|�t�|�d�t�dd�t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nz/{http://namespace.invalid/does/not/exist/}titlesB<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />r�z(http://namespace.invalid/does/not/exist/sB<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />z'{http://purl.org/dc/elements/1.1/}titles8<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />)r.rcrdr��register_namespacer�rrr�"test_bug_200709_register_namespace|s
�
�
�z+BugsTest.test_bug_200709_register_namespacecCs`t�d�}|�t�d��|�|djtj�t�d�}|�t�d��|�|djtj�dS)Nr�r�r)r.rcr�r-rdrCr�)r*r�rrr�test_bug_200709_element_comment�s

z(BugsTest.test_bug_200709_element_commentcCspt�d�}t�|d�}t�|d�}t�d�}|�d|�|�t|�gd��|�d|�|�t|�gd��dS)	Nr�r�r�r�r)r�r�r�rd)r�r�r�r�)r.rcr,r�rdrI�r*r�r�r�r�rrr�test_bug_200709_element_insert�s

z'BugsTest.test_bug_200709_element_insertcCsJt�d�}t�|d�}t�d�}|�|�|�t|�tj��tjg�dS)Nr�r�zTEST-b)r.rcr,r-r�rdrIr�)r*r�r�Z	comment_brrr�test_bug_200709_iter_comment�s



z%BugsTest.test_bug_200709_iter_commentcCsDt��}|�d�}|�di�}|�d�}|��}|�t|�d�dS)Nr!rCr�)r.r�r!rr�r�rdrA)r*rkr�rrr�test_bug_1534630�s

zBugsTest.test_bug_1534630cCs@t�d�}|�t�|d�d�t�d�}|�t�|d�d�dS)Ns7<?xml version='1.0' encoding='utf-8'?><body>tãg</body>r�s<<?xml version='1.0' encoding='ascii'?>
<body>t&#227;g</body>s;<?xml version='1.0' encoding='iso-8859-1'?><body>t�g</body>rlr�rrr�test_issue6233�s
�
�zBugsTest.test_issue6233cCsRt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�gd��dS)Nr�rC�rCrCr�)r.r�rdrIr�)r*r<Znewelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)NZ	test10777z
http://myuri/)r.r�ryrrr�test_issue10777�szBugsTest.test_issue10777cs`G�fdd�d�}t�d��|��_���}t|�}|�||�|��jt�|��jd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_text.<locals>.Textcs
d�_dS)N�changedTrary�r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N�r1r2r3r�rr�rrr��sr�rCr�)r.rcr`r�rrbr�rd�r*r�r�rvrr�r�test_lost_text�s
zBugsTest.test_lost_textcs|G�fdd�d�}t�d����t�d��|��d_���}t|�}|�||�|��djt�|��djd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_tail.<locals>.Textcsd�d_dS�Nr�rTrZryr�rrr��s
z.BugsTest.test_lost_tail.<locals>.Text.__bool__Nr�rr�rrr��sr�rrCrr�)	r.rcr�r_r�rrbr�rdr�rr�r�test_lost_tail�s
zBugsTest.test_lost_tailcs�G��fdd�d�}t�d����t�|�����t�d����d��zt��}Wntyr|�d�Yn0|�|j|�|��djt	�|�
�djd�dS)NcseZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcst�d��d<t��dSr�)r.rcr)r*r��r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N�r1r2r3r�rr�rrr��sr�rrCzgenerators are not reentrantrr�)r.rcr�r�rr�rHrbrCr�rd)r*r�rvrr�r�test_lost_elem�s

zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�r)r.r�rdrV�decode)r*r`r�rrrr�check_expat224_utf8_bug	s
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r�r8rrr�test_expat224_utf8_bug	s
zBugsTest.test_expat224_utf8_bugcCs�ttd��}|��}Wd�n1s(0Yt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nrr�rr�rvr<���)
r��UTF8_BUG_XMLFILEr�r.r�rVr��striprrd)r*�fp�rawrZxmlattrr`rrr�test_expat224_utf8_bug_file	s&

z$BugsTest.test_expat224_utf8_bug_filecCs.|�tt��jd�|�tt��jdd�dS)NrC)r�rgr.r�rryrrr�test_39495_treebuilder_start	sz%BugsTest.test_39495_treebuilder_startN)#r1r2r3rirjrmrnrorprqrtrwrJrKrP�gettracer{r|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrf�s:			



rfc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BasicElementTestcCs�d}ddi}t�||�}|�|tj�|�dt|��|�dt|��|�dt|��|�dt|��|�|j|�|�|j�|�|j	�|�
|j|�|�|j|�d|d	<|�
|j|�|�|j|�dS)
Nr��zix�wyprCrar`r_�bazr�)
r.rcrbr�r�rdrCr�r`r_r�rarN)r*rCra�element_foorrr�
test___init__)	s zBasicElementTest.test___init__cCs�dttj�vrt�d��t�dddi�}|�t�dddi��|�t��|��}Wd�n1sf0Y|�	||�|�
|j|j�|�
|j|j�|�
|j
|j
�|�
t|�t|��t�||�D]\}}|�||�q�|�
|j|j�dS)	Nr�zElement.copy() not presentr�r�r�r�r��qix)r�r.rcrJ�SkipTestr�ZassertWarns�DeprecationWarningr�r�rdrCr`r_re�	itertools�zip_longest�assertIsra�r*r�Zelement_foo2rOrPrrrr�D	s
&zBasicElementTest.test_copycCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j|j�|�t	|�t	|��t
�||�D]\}}|�||�q�|�|j
|j
�dS�Nr�r�r�r�r�r�)r.rcr�r�r�rdrCr`r_rer�r�r�rar�rrr�
test___copy__a	s
zBasicElementTest.test___copy__cCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j	|j	�|�t
|�t
|��t�||�D]\}}|�||�q�|�|j
|j
�|�|j
|j
�d|j
d<|�|j
|j
�|�|j
|j
�dSr�)r.rcr�r�r�r�rdrCr`r_rer�r�rarNr�rrr�test___deepcopy__y	s

z"BasicElementTest.test___deepcopy__cCs<t�d�}|�t|jd�|�t|jt�d�dg�|�t|jdd�t�d�g|dd�<|�t��d|d<Wd�n1s�0Y|�t��&t�d�dg|dd�<Wd�n1s�0Yt|d�r�ddgdd	d
d�}|�t|j|�t|d��r8Gd
d�dtj�}|d�g|dd�<|�tt	j
|�dS)N�joer�r�r�r�__setstate__rCr�r_r`)rC�	_childrenrar_r`�__deepcopy__c@seZdZdd�ZdS)z9BasicElementTest.test_augmentation_type_errors.<locals>.EcSsdSrKr)r*�memorrrr��	szFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__N)r1r2r3r�rrrr�E�	sr�)r.rcr�rgr�r�r�r�r�r�r�)r*r��stater�rrr�test_augmentation_type_errors�	s*
&4
�z.BasicElementTest.test_augmentation_type_errorscCs�Gdd�d�}|�}tjd|d�|_t�|�}~t�|�|��t�d�}|�}||_t�|�}tj|d|d�}~~~t�|�|��t�d�}t�d�}t�d�}|�|�|�|�|�|�t�|�}~~~t�|�|��dS)	Nc@seZdZdS)z.BasicElementTest.test_cyclic_gc.<locals>.DummyN�r1r2r3rrrr�Dummy�	sr�r�)r�r�r�r�r�)	r.rcZdummyref�weakref�refr	r�r,r�)r*r�r��wrefr�r�r�r�rrr�test_cyclic_gc�	s2









zBasicElementTest.test_cyclic_gccs\d��fdd�}t�d�}t�||�}|�|�jd�~t�|��d�|�|�d�dS)NFcsd�dS�NTr)�w��flagrr�wref_cb�	sz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)r.rcr�r�rdrCr	)r*r�r�r�rr�r�test_weakref�	s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�rrr�rM)rlrm�zrl�)r�r�)r.rcrdrV)r*r�rrr�test_get_keyword_args�	sz&BasicElementTest.test_get_keyword_argsc	Cs�tdtjd�D]�}t|jdd�D]�\}}|jddd�}d|_d|_|�|d	��	|�d
��|�	|�d	��|�
d�d�d
d�|�|d|||�}|�
|jd�|�
|jdd�|�
t|�d�|�||�q"qdS)Nr�rr��repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrr�zother valuer,r�)r�rQ�HIGHEST_PROTOCOLrrMrcr`r_r,r�r�r�r^rdrCrarerh)r*r[rYrZr�r�rrr�test_pickle�	s�zBasicElementTest.test_picklec	Cs�tdtjd�D]z}t|jdd�D]f\}}d}|�|�}t|d�rV|�|��dd�|�	|d|||�}|�|j
d�|�|d	j
d
�q"qdS)Nr�rrr�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__rC�groupr,rZdogs)r�rQr�rrMr�r�rdr�r^rC)r*r[rYrZZXMLTEXTr�r�rrr�test_pickle_issue18997�	s

�z'BasicElementTest.test_pickle_issue18997N)
r1r2r3r�r�r�r�r�r�r�r�r�r�rrrrr�'	s#
r�c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BadElementTestcs|G�fdd�d�}|�g�t�d�}z|���WntyDYn0Gdd�d|tj�}|d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcst�d�g�dd�<tjS)Nr�r}ry��Lrr�	__class__
sz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N�r1r2r3�propertyr�rr�rr�X
sr�r�c@seZdZdS)z2BadElementTest.test_extend_mutable_list.<locals>.YNr�rrrr�Y
sr�rl�r.rcr�rg�r*r�r�r�rr�r�test_extend_mutable_list
s


z'BadElementTest.test_extend_mutable_listcs�G�fdd�d�}|�t�d�g�t�d�}z|���WntyLYn0Gdd�d|tj�}|d�t�d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjSrKr}ryr�rrr� 
s
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__Nr�rr�rrr�
sr�r�r�c@seZdZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.YNr�rrrrr�+
sr�r�r�r�rr�r�test_extend_mutable_list2
s

z(BadElementTest.test_extend_mutable_list2cszG�fdd�dtj�}t�d����|d�g�|�t�jt�d��t�d����t�d�g�|�t�j|d��dS)NcseZdZ�fdd�ZdS)z3BadElementTest.test_remove_with_mutating.<locals>.Xcs�dd�=dS)NFr�r*�or�rrr�3
s
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__Nr�rr�rrr�2
sr�r�r�r�)r.rcr�r�r�r��r*r�rr�r�test_remove_with_mutating1
s

z(BadElementTest.test_remove_with_mutatingc	Cslt�d�}t|d|��B|�t��t|�Wd�n1s@0YWd�n1s^0YdS)Nr�rC)r.rcr
r��RuntimeErrorr�r�rrr�test_recursive_repr>
s
z"BadElementTest.test_recursive_reprcsnG�fdd�dt�}t��}|�di�|�d�|�|d��|�d�|�d�|���|��jd�dS)NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_text.<locals>.Xcs"z
�jWntyYn0dSrK)r`�	NameErrorry�r<rr�__del__H
s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N�r1r2r3r�rr�rrr�G
sr�rC�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�r.r�rr!r�r�rdr`�r*r�r�rr�r�test_element_get_textE
s


z$BadElementTest.test_element_get_textcs�G�fdd�dt�}t��}|�di�|�di�|�d�|�d�|�|d��|�d�|�d�|���|��djd	�dS)
NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_tail.<locals>.Xcs&z�djWnty Yn0dSr�)r_r�ryr�rrr�[
sz7BadElementTest.test_element_get_tail.<locals>.X.__del__Nr�rr�rrr�Z
sr�rrCr�r�r�rr�)	r�r.r�rr�r!r�rdr_r�rr�r�test_element_get_tailX
s



z$BadElementTest.test_element_get_tailcs^G�fdd�d�}t�d����t�d���d|����t�d���dd|��dS)NcseZdZ�fdd�ZdS)z%BadElementTest.test_subscr.<locals>.Xcs�dd�=dS�Nrrrryr�rr�	__index__p
s
z/BadElementTest.test_subscr.<locals>.X.__index__N�r1r2r3r�rr�rrr�o
sr�r<r�rr�)r.rcr�r�rr�r�test_subscrm
s
zBadElementTest.test_subscrcsPG�fdd�d�}t�d��td�D]}��dt�d��q$g�dd|��<dS)NcseZdZ�fdd�ZdS)z)BadElementTest.test_ass_subscr.<locals>.Xcsg�dd�<dSr�rryr�rrr�~
sz3BadElementTest.test_ass_subscr.<locals>.X.__index__Nr�rr�rrr�}
sr�r<r�rr�)r.rcr�r�)r*r�r�rr�r�test_ass_subscr{
s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcSsgSrKr�rlrmrrr�element_factory�
sz>BadElementTest.test_treebuilder_start.<locals>.element_factory�r�rCr�r�)r.r�rr!r��AttributeErrorr	�r*r�r�rrr�test_treebuilder_start�
s
z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|�di�|�d�|�t|jd�~t�dS)NcSsgSrKrr�rrrr��
sz<BadElementTest.test_treebuilder_end.<locals>.element_factoryr�rCr�)r.r�rr!r�r�r�r	r�rrr�test_treebuilder_end�
s
z#BadElementTest.test_treebuilder_endN)
r1r2r3r�r�r�r�r�r�r�r�r�r�rrrrr�

s

r�c@seZdZdd�Zdd�ZdS)�MutatingElementPathcGstj|g|�R�}||_|SrK)r��__new__r<)rNr<rr*rrrr��
szMutatingElementPath.__new__cCs|jdd�=dSr�r�r�rrrr��
szMutatingElementPath.__eq__N)r1r2r3r�r�rrrrr��
sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)Nrrrrr�rrrr��
szBadElementPath.__eq__Nr�rrrrr�
srcsXeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�BadElementPathTestcs(t���ddlm}|j|_i|_dS�Nrr')�super�setUpr)r(r��
path_cache�r*r(�r�rrr�
s
zBadElementPathTest.setUpcs"ddlm}|j|_t���dSr)r)r(rr�r�tearDownrrrrr�
szBadElementPathTest.tearDowncCs0t�d�}|�t�d�g�|�t|d��dS�Nr�r�rl)r.rcr�r�r�r�rrr�test_find_with_mutating�
s
z*BadElementPathTest.test_find_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr	)r.rcr�r�r�ZeroDivisionErrorr�rrr�test_find_with_error�
s
z'BadElementPathTest.test_find_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr	)r.rcr�r�r�r�rrr�test_findtext_with_mutating�
s
z.BadElementPathTest.test_findtext_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr	)r.rcr�r�rrr�rrr�test_findtext_with_error�
s
z+BadElementPathTest.test_findtext_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr	)r.rcr�r�r�r�rrr�test_findall_with_mutating�
s
z-BadElementPathTest.test_findall_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr	)r.rcr�r�rrr�rrr�test_findall_with_error�
s
z*BadElementPathTest.test_findall_with_error)r1r2r3rrr
rr
rrr�
__classcell__rrrrr�
src@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�dSrK)	rbr.r"r�r�r$rcr�r�ryrrr�test_istype�
szElementTreeTypeTest.test_istypecCsZGdd�dtj�}|d�}|�|tj�|�||�|�|jd�d|_|�|jd�dS)Nc@seZdZdS)zDElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementNr�rrrr�	MyElement�
srr�r�)r.rcrbrdrCr`�r*r�myerrr�test_Element_subclass_trivial�
sz1ElementTreeTypeTest.test_Element_subclass_trivialcsVG�fdd�dtj���dddd�ddd	�}|�|jd
�|�t|���gd��dS)Ncs"eZdZif��fdd�	Z�ZS)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcs"t�|�j|d|fi|��dS)N�__)rr6)r*rCra�extra)rr�rrr6�
szQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r1r2r3r6rr�rrrr�
srr�rrr�)r�r�rM�)r�r�Zfoo__))r�rr)r�r�)r�rM)r�r)r.rcrdrCr�r~)r*rrrr�!test_Element_subclass_constructor�
s�z5ElementTreeTypeTest.test_Element_subclass_constructorcCs.Gdd�dtj�}|d�}|�|��d�dS)Nc@seZdZdd�ZdS)zGElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementcSs|jSrKrBryrrr�	newmethodszQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r1r2r3rrrrrrsrr�)r.rcrdrrrrr� test_Element_subclass_new_methodsz4ElementTreeTypeTest.test_Element_subclass_new_methodcCs�Gdd�dtj�}t�d�}d|_|d�}d|_|�|�|�|�d�d�|�|�d�jd�t|�	d��}|�t
|�d|�|�|djd�dS)	Nc@seZdZdS)zAElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementNr�rrrrr
srr�r`r�r*rrr)r.rcr`r�rdr�r�rCrfr�re)r*rr��sub�foundrrr�test_Element_subclass_finds

z.ElementTreeTypeTest.test_Element_subclass_findN)r1r2r3rrrrr!rrrrr�
s


rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�ElementFindTestcCs�t�t�}|�|�d�jd�|�|�d�jd�|�|�d�jd�t�t�|d<|�|�d�jd�|�|�d�d�|�|�d�d�|�|�d�d	�|�|�dd
�d	�|�|�d��|�|�dd
�d
�|�t�d��d
�d	�dS)NrCr��./tagr�zsection/nexttag�nexttagr`r*rur��togz<tag><empty /></tag>�empty)	r.r�r�rdr�rC�SAMPLE_SECTIONr�r�r�rrr�test_find_simples
z ElementFindTest.test_find_simplecCs�d}t�|�}|�|�d�jdd�|�|�d�jdd�|�|�d�jdd�|�|�d	�jdd
�|�|�d�jdd�|�td|jd
�|�td|jd�|�td|jd�|�td|jd�dS)Nz�
        <body>
            <tag class='a'/>
            <tag class='b'/>
            <tag class='c'/>
            <tag class='d'/>
        </body>z./tag[1]�classr�z./tag[2]r�z
./tag[last()]r�z./tag[last()-1]r�z./tag[last()-2]ZXPathz./tag[0]z	./tag[-1]z./tag[last()-0]z./tag[last()+1])r.r�rdr�rarp�SyntaxError)r*Z
LINEAR_XMLr�rrr�test_find_xpath4s
zElementFindTest.test_find_xpathcCs
t�t�}t�t�|d<|�t|�d��dg�|�t|�d��ddg�|�t|�d��g�|�t|�d��g�|�t|�d��gd��|�t|�d	��dgd
�|�t|�d��dg�|�t|�d��dgd�|�t|�d
��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��dg�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dg�|�t|�d��g�|�t|�d ��g�|�t|�d!��dgd�|�|�d"�|�d��|�t|�d#��dg�|�t|�d$��dg�|�t|�d%��dg�|�t|�d&��dg�|�t|�d'��dg�|�t|�d(��dg�|�t|�d)��dg�|�t|�d*��dg�|�t|�d+��dg�|�t|�d,��dg�|�t|�d-��g�|�t|�d.��g�|d|d/<|�t|�d&��ddg�|�t|�d,��ddg�dS)0Nr�r�r�rCr%ztog/foor�r�z.//tagrr�zsection//tagz	section/*)rCr$�nextsectionz
section//*)rCr$r,rCzsection/.//*z*/*z*//*z*/tagz*/./tagr#z././tagz.//tag[@class]rMz.//tag[@class="a"]z.//tag[@class="b"]z.//tag[@id]z.//section[tag]r�z.//section[element]z../tagzsection/../tagz	section//z.//section[tag='subtext']z.//section[tag ='subtext']z.//section[tag= 'subtext']z.//section[tag = 'subtext']z.//section[ tag = 'subtext' ]z.//tag[.='subtext']z.//tag[. ='subtext']z.//tag[.= "subtext"]z.//tag[ . = "subtext" ]z.//tag[. = 'subtext']z.//tag[. = 'subtext ']z.//tag[.= ' subtext']rr)r.r�r�r'rdrIr�r�rrr�test_findallJs�
���������������������������zElementFindTest.test_findallcCs\t�t�}|�t|�d��g�|�t|�d��dgd�|�t|�d��dgd�dS)NrCz{http://effbot.org/ns}tagr�z.//{http://effbot.org/ns}tagrM)r.r�r�rdrIr�r�rrr�test_test_find_with_ns�s
��z&ElementFindTest.test_test_find_with_nscCs�t�d�}ddi}|�t|jd|d��d�|�t|jd|d��d�ddi}|�t|jd|d��d	�|�t|jd|d��d�ddd
�}|�t|jd|d��d�|�t|jd|d��d	�dS)N��
            <a xmlns:x="X" xmlns:y="Y">
                <x:b><c/></x:b>
                <b/>
                <c><x:b/><b/></c><y:b/>
            </a>�xxr�z.//xx:b)r�r��.//br�rr)r0ru)r.r�rdrer�)r*r�nsmaprrr�test_findall_different_nsmaps�s

z-ElementFindTest.test_findall_different_nsmapscCs�t�d�}|�t�d��|�t|�d��gd��|�t|�d��dg�|�t|�d��dg�|�t|�d	��d
g�|�t|�d��ddg�|�t|�d
��dg�|�t|�d
��t|�d���|�t|�d��gd��|�t|�d�|dg�t|�d���|�t|�d��gd��|�t|�d��ddg�|�t|�d��ddg�|�t|�d��d
g�|�t|�d��gd��|�t|�d��ddg�|�t|�d��t|�d���dS)Nr/rz{*}b)�{X}br��{Y}bz{*}cr�z{X}*r4z{Y}*r5r�r�z{}br�)r4r�r�r5rdr�z.//{*}b)r4r�r4r�r5z.//{*}cz.//{X}*z.//{Y}*z.//{}*)r�r�r�r�z.//{}br1)r.r�r�r-rdrIr�r�rrr�test_findall_wildcard�sd
����������������z%ElementFindTest.test_findall_wildcardcCsDt�t�}|�td��|�d�Wd�n1s60YdS)Nzcannot use absolute pathz/tag)r.r�r�rpr*r�r�rrr�
test_bad_find�s
zElementFindTest.test_bad_findcCs�t�t�}|�t�|��d�jd�|�t�|��d�d�|�tt�|��	d��dgd�d}|�
t|�� t�|��	d�}Wd�n1s�0Y|�t|�dgd�dS)NrCr`r�z�This search is broken in 1.3 and earlier, and will be fixed in a future version.  If you rely on the current behaviour, change it to '.+'z//tagrM)r.r�r�rdr$r�rCr�rIr��assertWarnsRegex�
FutureWarning)r*r�rtr�rrr�test_find_through_ElementTree�s
�.z-ElementFindTest.test_find_through_ElementTreeN)r1r2r3r(r+r-r.r3r6r7r:rrrrr"sM
,r"c@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�ElementIterTestNcCst|�|��SrK)rIr�)r*r<rCrrr�_ilist�szElementIterTest._ilistcCs4t�d�}|�|�|�gd��|�|�|�d��ddg�|�t|���jd�|�d�|�	��d�|�d�|�d��	��d�|�t|�	��d	�t
|d
d�}|�tt�|��dd
�t
|d
d�}tjt�
�d�}|�ttj||d��dd
�t�d�}|�t|j�t�d�}|�d�|�	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>)r�r�r�r�r�r�ruzthis is a paragraph...zthis is a paragraph.z
this is a F)r=rr�r�)r�z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)r.r�rdr<r�rr�rCr�r�rArr�r�r$r�r�)r*r�Z
sourcefiler�r@rrr�
test_basic�s(
��

zElementIterTest.test_basiccCs�t�d�}|�|�|�dg�t�|d�}|�|�|�ddg�t�|d�}|�|�|�gd��t�|d�}|�|�|�gd��|d|d<|d=|�|�|�ddg�dS)	Nr�r�r�)r�r�r�r�)r�r�r�r�rrr)r.rcrdr<r,r�rrr�test_cornerss
zElementIterTest.test_cornerscCs�t�d�}|�|�|d�dgd�|�|�|d�dgd�|�t|jdd��dgd�gd�}|�t|���|�|�|�|�|�|�|�|d�|�dS)	NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>�roomrM�houser�rB)rr@r?r?Zshedr@r?r�)r.r�rdr<rIr�)r*r�Zall_tagsrrr�test_iter_by_tag's

�z ElementIterTest.test_iter_by_tagcCsJt�d�}|��}|�t��t�|�Wd�n1s<0YdS)Nr�)r.rcr�r�rgr�)r*r�r�rrrr�Ds
zElementIterTest.test_copyc	Csft�d�}|��}ttjd�D]@}|�ttjf��t�	||�Wd�q 1sV0Yq dS)Nr�rr)
r.rcr�r�rQr�r�rgrTrR)r*r�r�r[rrrr�Js

zElementIterTest.test_pickle)N)	r1r2r3r<r=r>rAr�r�rrrrr;�s
r;c@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�TreeBuilderTestz�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text<div>subtext</div>tail</html>z<toplevel>sometext</toplevel>cCs�|�|jd�|�|jd�|�|jd�|�|ji�t|�}|�t|�d�|d}|�|jd�|�|jd�|�|jd�|�|ji�dS)Nr�r`rrrZdivr*r_)rdrCr`r_rarfre)r*r��childrenr�rrr�_check_sample1_elementZsz&TreeBuilderTest._check_sample1_elementcCs�Gdd�d�}Gdd�d|�}tj|�d�}|�|j�|�|��d�tj|�d�}|�|j�|�|��d�tjt�d�}|�|j�|�|���dS)Nc@seZdZdd�ZdS)z<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuildercSsdS)Nr�rryrrrr�iszBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeNr~rrrr�BaseDummyBuilderhsrEc@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdSrKr)r�rrr�<lambda>mrGzATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)r1r2r3r!rr�rrrr�DummyBuilderlsrGr�r�)r.r�r��sample1rdr��objectr�)r*rErGr�rrr�test_dummy_buildergsz"TreeBuilderTest.test_dummy_buildercCs�t��}|�|�d�jtj�|�|�d�jd�tjtjd�}|�|�d�jtj�|�|�d�jd�tjtd�}|�|�d�td��dS)NZctext)�comment_factory)r.r�rdr+rCr-r`re�r*r�rrr�test_treebuilder_comment{sz(TreeBuilderTest.test_treebuilder_commentcCs�t��}|�|�dd�jtj�|�|�dd�jd�tjtjd�}|�|�d�jtj�|�|�d�jd�|�|�dd�jtj�|�|�dd�jd�tjdd�d�}|�|�d�td�df�|�|�dd�td�df�dS)Nr�)�
pi_factoryr4z text zpitarget  text cSst|�|fSrK)re)r�r`rrrrF�rGz5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>)r.r�rdr;rCr�r`rerLrrr�test_treebuilder_pi�sz#TreeBuilderTest.test_treebuilder_picCs�Gdd�dtj�}d}t�|�}|�|jd�tj|�d�}|�|�|��}|�|jd�d}t�|�}|�|jd�d}tj|�d�}|�|�|��}|�|jd�dS)Nc@seZdZdS)z;TreeBuilderTest.test_late_tail.<locals>.TreeBuilderSubclassNr�rrrr�TreeBuilderSubclass�srPz<a>text<!-- comment -->tail</a>Ztexttailr�z<a>text<?pi data?>tail</a>)r.r�r�rdr`r�r�r�)r*rPr�r�r�rrr�test_late_tail�s 



zTreeBuilderTest.test_late_tailcCszGdd�dtj�}d}tjtjdd�d�}|�|�|��}|�|djd�|�|djd	�|�|jd
�tj|dd�d�}|�|�|��}|�|djd�|�|djd	�|�|jd
�d}tjtjdd�d�}|�|�|��}|�|djd
�|�|djd�|�|jd�tj|dd�d�}|�|�|��}|�|djd
�|�|djd�|�|jd�dS)Nc@seZdZdS)zKTreeBuilderTest.test_late_tail_mix_pi_comments.<locals>.TreeBuilderSubclassNr�rrrrrP�srPz/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)Zinsert_commentsr�rrBz
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)Z
insert_piszpi datar_ztext
)r.r�r�r�r�rdr`r_)r*rPr�r�r�rrr�test_late_tail_mix_pi_comments�s6



z.TreeBuilderTest.test_late_tail_mix_pi_commentscCs6tjtjdd�d�}|�|j�|��}|�|�dS�Nr�r�)r.r�r�r�rHr�rD�r*r�r�rrr�$test_treebuilder_elementfactory_none�sz4TreeBuilderTest.test_treebuilder_elementfactory_nonecCsXGdd�dtj�}|�}|�|�d�d�tj|d�}|�|j�|��}|�|�dS)Nc@seZdZdd�ZdS)z4TreeBuilderTest.test_subclass.<locals>.MyTreeBuildercSs|dS�Nr�rrrrrrrn�sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN�r1r2r3rnrrrr�
MyTreeBuilder�srXr�r�r�)	r.r�rdrnr�r�rHr�rD�r*rX�tbr�r�rrr�
test_subclass�szTreeBuilderTest.test_subclasscCslGdd�dtj�}|tjtjd�}|�|�d�d�tj|d�}|�|j�|�d�|�	�}|�
|�dS)Nc@seZdZdd�ZdS)z?TreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuildercSs|dSrVrrrrrrrn�szFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobarNrWrrrrrX�srX)rKrNr�r�r�z<!-- a comment--><?and a pi?>)r.r�r-r�rdrnr�r�rHr�rDrYrrr�test_subclass_comment_pi�s
z(TreeBuilderTest.test_subclass_comment_picsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�SrK)r�r.rc)rCra�Zlstrr�	myfactory�s
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryr�r�Ztoplevel)r.r�r�r��sample2r�rd)r*r^rZr�rr]r�test_element_factory�sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dSrS)r.r�r�r�rHr�rbrD)r*rNrZr�r�rrr�_check_element_factory_class
sz,TreeBuilderTest._check_element_factory_classcCs Gdd�dtj�}|�|�dS)Nc@seZdZdS)z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementNr�rrrrr

sr)r.rcra)r*rrrr�test_element_factory_subclass
sz-TreeBuilderTest.test_element_factory_subclasscCs4tj}|�|jd�Gdd�d|t�}|�|�dS)Nr,c@seZdZdS)zLTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementNr�rrrrr
sr)r.Z_Element_Pyrdr2r�ra)r*�baserrrr�)test_element_factory_pure_python_subclass
sz9TreeBuilderTest.test_element_factory_pure_python_subclasscCs<Gdd�d�}tj|�d�}|�|j�|�|��d�dS)Nc@s eZdZdZdd�Zdd�ZdS)z3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNcSs|||f|_dSrK��_doctype�r*rXZpubid�systemrrr�doctype"
sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jSrKreryrrrr�%
sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r1r2r3rfrir�rrrr�
DoctypeParser
srjr��r�z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r.r�r�rHrdr�)r*rjr�rrr�test_doctype
s	
�zTreeBuilderTest.test_doctypec	Cs�Gdd�d�}tj|�d�dD]@}|�t|�� tj||�d�Wd�q 1sV0Yq tj|td�d�dD]2}tj||td�d�}|�|j�|�|���qxdS)Nc@s"eZdZdefdd�Zdd�ZdS)zBTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNcSs||_||_dSrK��raise_in�what)r*rnrorrrr61
szKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWsdSrKr)rrrr�handle8
sz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handlerm)r*rXrprrr�__getattr__5
s
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r1r2r3r�r6rqrrrr�RaisingBuilder0
srrr�)rr!r�r+r;)ro)	r.r�rpr�r�r�rHr�r�)r*rrr�r�rrr�test_builder_lookup_errors/
s0z*TreeBuilderTest.test_builder_lookup_errorsN)r1r2r3rHr_rDrJrMrOrQrRrUr[r\r`rarbrdrlrsrrrrrBRs"
$	
rBc@sPeZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�
XMLParserTests<file><line>22</line></file>s�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>uX<?xml version="1.0" encoding="iso-8859-1"?>
<money value="$£€𐅻">$£€𐅻</money>cCs6|�|jd�|�|djd�|�|djd�dS)Nr?r�lineZ22)rdrCr`r�rrr�_check_sample_elementR
sz#XMLParserTest._check_sample_elementcCs0tjdt��d�}|�|j�|�|���dS)Nr)r5r�)r.r�r�r�rHrvr�)r*rJrrr�test_constructor_argsW
s
�z#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|�|j�|�|���dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserNr�rrrr�MyParser^
srx)r.r�r�rHrvr�)r*rxr�rrrr[]
szXMLParserTest.test_subclasscCsTt���8t�dt�t��}|�|j�|��Wd�n1sF0YdS)N�error)	�warnings�catch_warnings�simplefilterr�r.r�r�r_r�rrrr�test_doctype_warningd
s

z"XMLParserTest.test_doctype_warningcs�d�G�fdd�dtj�}|�}|�td��|�|j�Wd�n1sN0Y|��|���d��t�	��pt�
dt�t�
dt�G�fdd�d�}||�d�}|�|j�|��|���|��d�Wd�n1s�0YdS)	NcseZdZ�fdd�ZdS)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs||f�dSrKr)r*rrrerrrin
szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN�r1r2r3rirrerr�MyParserWithDoctypem
srrirycseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dSrKrrg��	_doctype2rrri}
szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeNr~rr�rrrj|
srjr�rk)
r.r�r8�RuntimeWarningr�r_r�r�rzr{r|r�rd)r*rr�rjr)rfr�r�test_subclass_doctypek
s&*


�z#XMLParserTest.test_subclass_doctypecCspt���Tt�dt�t�dt�Gdd�dtj�}|�}|�|j�|�	�Wd�n1sb0YdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)ryc@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr�rrrr�MyParserWithoutDoctype�
sr�N)
rzr{r|r�r�r.r�r�r_r�)r*r�r�rrr�test_inherited_doctype�
s
z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)Nr�Zmoneyr{u
$£€𐅻)
r.r�r�r��sample3r�rdrCrar`rTrrr�test_parse_string�
szXMLParserTest.test_parse_stringN)
r1r2r3rHr_r�rvrwr[r}r�r�r�rrrrrtI
srtc@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	NZhellor�)�hr�z{hello}tablerrz.//{hello}tdr�z.//{foo}name)r.r��SAMPLE_XML_NS_ELEMSrdrer�)r*r2r�rrr�test_find_with_namespace�
s


z+NamespaceParseTest.test_find_with_namespaceN)r1r2r3r�rrrrr��
sr�c@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ElementSlicingTestcCsdd�|D�S)NcSsg|]
}|j�qSrrB)rEr�rrrrF�
rGz1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)r*Zelemlistrrr�
_elem_tags�
szElementSlicingTest._elem_tagscCs|�t|��SrK)r�rfr.rrr�
_subelem_tags�
sz ElementSlicingTest._subelem_tagscCs,t�d�}t|�D]}t�|d|�q|S)zxCreate an Element with a tag 'a', with the given amount of children
           named 'a0', 'a1' ... and so on.

        r�za%s)r.rcr�r,)r*Znumchildrenr�r�rrr�_make_elem_with_children�
s
z+ElementSlicingTest._make_elem_with_childrencsZ|�d��|��djd�|��djd�|�t�fdd��|�t�fdd��dS)	Nr�rr�a1����a8cs�dS)N�rrr�rrrF�
rGz?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Ni�rrr�rrrF�
rG)r�rdrCr��
IndexErrorryrr�r�test_getslice_single_index�
s

z-ElementSlicingTest.test_getslice_single_indexcCs�|�d�}|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��ddg�|�|�|dd��ddg�|�|�|dd	��d
dg�dS)Nr<rM)�a3�a4�a5�rr�r�rdr��a0r�)r�rdr�r�rrr�test_getslice_range�
s
z&ElementSlicingTest.test_getslice_rangec	Cs�|�d�}|�|�|ddd��ddg�|�|�|ddd��gd��|�|�|ddd��ddg�|�|�|ddd��d	dg�|�|�|ddtj��d
g�|�|�|ddtjd>��d
g�dS)Nr��rrr��a9rM)r�r�Za6r�r�r�r��@�r�rdr�rP�maxsizer�rrr�test_getslice_steps�
s
     z&ElementSlicingTest.test_getslice_stepsc	Cs�|�d�}|�|�|ddd��gd��|�|�|ddd��ddg�|�|�|ddtj��dg�|�|�|ddtjd��dg�|�|�|ddtjd	>��dg�dS)
Nrrd)r��a2r�r�r�r�r�rMrrr�r�r�rrr�test_getslice_negative_steps�
s
  "&z/ElementSlicingTest.test_getslice_negative_stepscCs�|�d�}|dd�=|�|�|�ddg�|�d�}|dd�=|�|�|�g�|�d�}|ddd�=|�|�|�g�|�d�}|ddd�=|�|�|�ddg�|�d�}|d	dd�=|�|�|�ddg�|�d�}|ddd�=|�|�|�d
g�dS)Nrrr�r�r�rdr�r�rrr�)r�rdr�r�rrr�
test_delslice�
s$







z ElementSlicingTest.test_delslicecCs�|�d�}t�d�|d<|�|�|�gd��t�d�|d<|�|�|�gd��|�t��t�d�|d	<Wd�n1s�0Y|�t��t�d�|d
<Wd�n1s�0Y|�|�|�gd��dS)Nrr�rr�r�r�r�r�r�r�)r�r�r�r�r�r���)r�r.rcrdr�r�r�r�rrr�test_setslice_single_index�
s
,,z-ElementSlicingTest.test_setslice_single_indexcCs�|�d�}dd�td�D�|dd�<|�|�|�gd��|�d�}t�d�g|dd�<|�|�|�gd	��|�d�}d
d�td�D�|dd�<|�|�|�gd��dS)NrcSsg|]}t�d|��qS�zb%sr}�rEr�rrrrFrGz:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rrrM)r��b0�b1r�r�)r�r�r�cSsg|]}t�d|��qSr�r}r�rrrrFrG)r�r�r��b2r�)r�r�rdr�r.rcr�rrr�test_setslice_ranges


z&ElementSlicingTest.test_setslice_rangecCs�|�d�}dd�td�D�|ddd�<|�|�|�gd��|�d�}|�t��&t�d�g|ddd�<Wd�n1s|0Y|�t��,d	d�td
�D�|ddd�<Wd�n1s�0Y|�t��g|ddd�<Wd�n1s�0Y|�|�|�gd��|�d�}t�d�g|ddtj	�<|�|�|�gd
��t�d�g|ddtj	d>�<|�|�|�gd��dS)Nr<cSsg|]}t�d|��qSr�r}r�rrrrFrGz:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rrr)r�r�r�r�r�r�r�cSsg|]}t�d|��qSr�r}r�rrrrFrGrM)r�r�r�r�r�r�rr�r�r��r�r�r�r��
r�r�rdr�r�r�r.rcrPr�r�rrr�test_setslice_stepss 

4:,
z&ElementSlicingTest.test_setslice_stepscCs�|�d�}dd�td�D�|ddd�<|�|�|�gd��|�d�}|�t��&t�d�g|ddd�<Wd�n1s|0Y|�t��,d	d�td
�D�|ddd�<Wd�n1s�0Y|�t��g|ddd�<Wd�n1s�0Y|�|�|�gd��|�d�}t�d�g|ddtj	�<|�|�|�gd
��t�d�g|ddtj	d�<|�|�|�gd��t�d�g|ddtj	d>�<|�|�|�gd��dS)NrcSsg|]}t�d|��qSr�r}r�rrrrF(rGzCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rrd)r�r�r�r�r�cSsg|]}t�d|��qSr�r}r�rrrrF/rGrM)r�r�r�r�rrr�r�r�r�r�)r�r�r�r�r�r�rrr�test_setslice_negative_steps&s$

4:,
z/ElementSlicingTest.test_setslice_negative_stepsN)r1r2r3r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��
s
	

	
r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZGdd�d�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�IOTestc	Cs�t�d�}d|_|�t|�d�dD]Z}|�|��<|�t||d�d�|�t||��d�d�Wd�q$1st0Yq$dD]r}|�|��T|�t||d�d|�|��|��}|�t||d�d|�|��Wd�q�1s�0Yq�t�d�}d	|_|�t|�d
�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���qDt�d�}d	|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���q�t�d�}d|_|�t|�d�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���q,t�d�}d|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���q�dS)NrCrz<tag>abc</tag>)rr�r�s<tag>abc</tag>)r�r��utf-32z2<?xml version='1.0' encoding='%s'?>
<tag>abc</tag>z<&"'>z<tag>&lt;&amp;"'&gt;</tag>rs<tag>&lt;&amp;"'&gt;</tag>r�z><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>r|z"<tag key="&lt;&amp;&quot;'&gt;" />s"<tag key="&lt;&amp;&quot;'&gt;" />zF<?xml version='1.0' encoding='%s'?>
<tag key="&lt;&amp;&quot;'&gt;" />uåöö<>u<tag>åöö&lt;&gt;</tag>s<tag>åöö&lt;&gt;</tag>s%<tag>&#229;&#246;&#246;&lt;&gt;</tag>u=<?xml version='1.0' encoding='%s'?>
<tag>åöö&lt;&gt;</tag>u<tag key="åöö&lt;&gt;" />s<tag key="åöö&lt;&gt;" />s(<tag key="&#229;&#246;&#246;&lt;&gt;" />)r�r�r�r�r�u@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	r.rcr`rdrAr��upperr ra)r*r<�encr�rrrr�>s�
��$������$
�����

�����
�����

�����zIOTest.test_encodingcCsf|�tjt�t�t�d��}|�t�ttd�� }|�	|�
�d�Wd�n1sX0YdS)N�<site>ø</site>r�<site>&#248;</site>)r#rr$rr.r$r�r9r�rdr��r*r@r�rrr�test_write_to_filename�s

zIOTest.test_write_to_filenamecCs�|�tjt�t�t�d��}|jtdd�ttd�� }|�	|�
�d�Wd�n1s\0Y|jtdd�ttd��$}|�	|�
�td��Wd�n1s�0YdS)Nr�rr�r�<site>ø</site>r�:<?xml version='1.0' encoding='ISO-8859-1'?>
<site>�</site>)r#rr$rr.r$r�r9r�rdr�r"r�rrr�$test_write_to_filename_with_encoding�s.�z+IOTest.test_write_to_filename_with_encodingcCs�|�tjt�ttd��}|j}Wd�n1s40Yt�t�t�t�d��}|j	tdd�ttd�� }|�
|��d�Wd�n1s�0YdS)Nr�r�r4r�rr�)r#rr$rr�r5r.r$r�r9rdr�)r*r�r5r@rrr�!test_write_to_filename_as_unicode�s$
z(IOTest.test_write_to_filename_as_unicodecCs�|�tjt�t�t�d��}ttddd��*}|j|dd�|�	|j
�Wd�n1s\0Yttd�� }|�|��d�Wd�n1s�0Yttddd	d
��*}|j|dd�|�	|j
�Wd�n1s�0Yttd�� }|�|��d�Wd�n1�s0Yttddd��*}|j|dd�|�	|j
�Wd�n1�sf0Yttd�� }|�|��d
�Wd�n1�s�0YdS)Nr�r�rr�r4rr�r��xmlcharrefreplace)r5�errorsr�rs<site>�</site>�
r#rr$rr.r$r�r�r9r r!rdr�r�rrr�test_write_to_text_file�s"*.*0,zIOTest.test_write_to_text_filecCs�|�tjt�t�t�d��}ttd��&}|�|�|�	|j
�Wd�n1sT0Yttd�� }|�|��d�Wd�n1s�0YdS)Nr�rrr�r�r�rrr�test_write_to_binary_file�s
*z IOTest.test_write_to_binary_filecCs |�tjt�t�t�d��}ttd��*}|j|dd�|�	|j
�Wd�n1sX0Yttd�� }|�|��d�Wd�n1s�0Yttd��*}|j|dd�|�	|j
�Wd�n1s�0Yttd�� }|�|��d�Wd�n1�s0YdS)	Nr�rrr�rr�rr�r�r�rrr�'test_write_to_binary_file_with_encoding�s*.*
�z.IOTest.test_write_to_binary_file_with_encodingcCs0|�tjt�t�t�d��}ttd��*}|j|dd�|�	|j
�Wd�n1sX0Yttd��&}|�|��d�
d��Wd�n1s�0Yttddd��*}|j|dd�|�	|j
�Wd�n1s�0Yttd��&}|�|��d�
d��Wd�n1�s"0YdS)	Nr�rr�r�ru7<?xml version='1.0' encoding='utf-16'?>
<site>ø</site>r)�	buffering)r#rr$rr.r$r�r�r9r r!rdr�r r�rrr�"test_write_to_binary_file_with_bom�s(*
��"*
��z)IOTest.test_write_to_binary_file_with_bomcCs2t��}t�d�}|�|�|�|��jd�dS�Nz"<?xml version="1.0"?><site></site>�site)r.r$r6r8r�rdr�rC�r*r@r�rrr�test_read_from_stringio�s

zIOTest.test_read_from_stringiocCs:t�t�d��}t��}|j|dd�|�|��d�dS�Nr�r4r�)r.r$r�r6r8r9rdr:r�rrr�test_write_to_stringio�szIOTest.test_write_to_stringiocCs2t��}t�d�}|�|�|�|��jd�dS�Ns"<?xml version="1.0"?><site></site>r�)r.r$r6r7r�rdr�rC�r*r@r�rrr�test_read_from_bytesio�s

zIOTest.test_read_from_bytesiocCs6t�t�d��}t��}|�|�|�|��d�dS�Nr�r�)r.r$r�r6r7r9rdr:r�rrr�test_write_to_bytesio�s
zIOTest.test_write_to_bytesioc@seZdZdS)zIOTest.dummyNr�rrrr�dummy�sr�cCsBt�d�}|��}|j|_t��}|�|�|�|��j	d�dSr�)
r6r8r�r�r.r$r�rdr�rC)r*r��readerr@rrr�test_read_from_user_text_readers

z&IOTest.test_read_from_user_text_readercCsJt�t�d��}t��}|��}|j|_|j|dd�|�|��d�dSr�)	r.r$r�r6r8r�r9rdr:)r*r@r��writerrrr�test_write_to_user_text_writersz%IOTest.test_write_to_user_text_writercCsJt�d�}|��}|j|_t��}|�|�|�|��j	d�t��}dSr�)
r6r7r�r�r.r$r�rdr�rC)r*r�r�r@rrr�!test_read_from_user_binary_readers

z(IOTest.test_read_from_user_binary_readercCsFt�t�d��}t��}|��}|j|_|�|�|�|��d�dSr�)	r.r$r�r6r7r�r9rdr:�r*r@r�r�rrr� test_write_to_user_binary_writers
z'IOTest.test_write_to_user_binary_writercCsbt�t�d��}t��}|��}|j|_dd�|_|j|_|j|dd�|�	|�
�d�d��dS)Nz<site />cSsdSr�rrrrrrF&rGzBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>r�r�z0<?xml version='1.0' encoding='utf-16'?>
<site />)r.r$r�r6r7r�r9�seekable�tellrdr:r r�rrr�)test_write_to_user_binary_writer_with_bom!s

��z0IOTest.test_write_to_user_binary_writer_with_bomc	CsRt�d�}|�t�|d�d�t�|d���|�t�|d�d�t�|d���dS)Nz<tag>foo</tag>r4rur�rG)r.r�rdr�r�r�r�rrr�test_tostringlist_invariant-s

�
�z"IOTest.test_tostringlist_invariantcCsRt�d�}|�t�|d�d�|�tj|ddd�d�|�tj|ddd�d�dS)Nz<tag>a<x />b<y></y>c</tag>r4z<tag>a<x />b<y />c</tag>T)Zshort_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)r.r�rdr�r�rrr�test_short_empty_elements6s

���z IOTest.test_short_empty_elementsN)r1r2r3r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�=s(E
			r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|�t��t�dSrK)rbr.r"r*ryrrrr[DszParseErrorTest.test_subclassc
Cs>zt�|�Wn*tjy8}z|WYd}~Sd}~00dSrK)r.r�r")r*r�r�rrr�
_get_errorGszParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)rrrz<tag>&foo;</tag>)rrrzfoobar<)rrr<)rdr�Zpositionryrrr�test_error_positionMsz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errors�parsersZexpatr�rdr��codeZcodesZXML_ERROR_SYNTAX)r*ZERRORSrrr�test_error_codeRs
�zParseErrorTest.test_error_codeN)r1r2r3r[r�r�r�rrrrr�Csr�c@seZdZdd�ZdS)�KeywordArgsTestc
Cs�t�d�}|�|�dd�|jddd��|�|�ddd�|jdddd��|�|�dd�|jddd��|�t|�dd��t|jddd���|�t�d�j	i�t�dt
ddd��tjdt
ddd�d�tjdt
dd	�dd
�tjdddd�tjdt
ddd�ddd�g}|D]*}|�|jd�|�|j	t
ddd���q
tj|ddd
did�}|�|j	d
d�|�
td��t�dd�Wd�n1�s�0Y|�
td��tjddd�Wd�n1�s�0YdS)Nz
<a>foo</a>r�)�pathr�)r�r�r��#r�)r[rb)ra)r[)rbrrnZkey1Zvalue1zmust be dict, not strzI'm not a dict)r.r�rdr�r�r�rfr�rcrarUrCr,rprg)r*rl�elementsr�r�rrr�test_issue14818[s:
�����,zKeywordArgsTest.test_issue14818N)r1r2r3r�rrrrr�Xsr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)rLrJr�ryrrrr}szNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dSrK)rbrLrcr6�types�FunctionTyper�ryrrr�test_correct_import_pyET�sz*NoAcceleratorTest.test_correct_import_pyETN)r1r2r3rr�rrrrr�|sr�cKstj|fi|��SrK)rL�canonicalize)r�r>rrr�c14n_roundtrip�sr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)�C14NTestNcCs|�td�d�|�td�d�|�td�d�|�td�d�|�td	�d
�|�td�d�|�td
�d�|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�d}|�t|�|�d}|�t|�|�d}|�t|�|�dS)Nz<doc/>z<doc></doc>z<doc xmlns='uri'/>z<doc xmlns="uri"></doc>z <prefix:doc xmlns:prefix='uri'/>z,<prefix:doc xmlns:prefix="uri"></prefix:doc>z+<doc xmlns:prefix='uri'><prefix:bar/></doc>z7<doc><prefix:bar xmlns:prefix="uri"></prefix:bar></doc>z�<elem xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' />z
<elem></elem>z*<doc>Hello, world!<!-- Comment 1 --></doc>z<doc>Hello, world!</doc>z<value>&#x32;</value>z<value>2</value>zG<compute><![CDATA[value>"0" && value<"10" ?"valid":"error"]]></compute>zI<compute>value&gt;"0" &amp;&amp; value&lt;"10" ?"valid":"error"</compute>zS<compute expr='value>"0" &amp;&amp; value&lt;"10" ?"valid":"error"'>valid</compute>z{<compute expr="value>&quot;0&quot; &amp;&amp; value&lt;&quot;10&quot; ?&quot;valid&quot;:&quot;error&quot;">valid</compute>z7<norm attr=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>z/<norm attr=" '    &#xD;&#xA;&#x9;   ' "></norm>z6<normNames attr='   A   &#x20;&#13;&#xa;&#9;   B   '/>z=<normNames attr="   A    &#xD;&#xA;&#x9;   B   "></normNames>z7<normId id=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>z1<normId id=" '    &#xD;&#xA;&#x9;   ' "></normId>z5<X xmlns="http://nps/a"><Y targets="abc,xyz"></Y></X>zJ<X xmlns="http://nps/a"><Y xmlns="http://nsp/b" targets="abc,xyz"></Y></X>zN<X xmlns="http://nps/a"><Y xmlns:b="http://nsp/b" b:targets="abc,xyz"></Y></X>)rdr�r�rrr�test_simple_roundtrip�sP
�
�
�
�
�
�
�
�
�
�
�zC14NTest.test_simple_roundtripcCs�t�d�}|�t|dd�d�|�t|ddgd�d�|�t|ddgd	�d
�|�t|ddgdgd�d�|�t|dd
dgd	�d�|�t|d
dgd�d�|�t|dddgd	�d�|�t|ddgd�d�dS)Nz�        <root xmlns:x="http://example.com/x">
            <a x:attr="attrx">
                <b>abtext</b>
            </a>
            <b>btext</b>
            <c>
                <x:d>dtext</x:d>
            </c>
        </root>
        T)�
strip_textz�<root><a xmlns:x="http://example.com/x" x:attr="attrx"><b>abtext</b></a><b>btext</b><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>z{http://example.com/x}attr)r��
exclude_attrszc<root><a><b>abtext</b></a><b>btext</b><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>z{http://example.com/x}d)r��exclude_tagszb<root><a xmlns:x="http://example.com/x" x:attr="attrx"><b>abtext</b></a><b>btext</b><c></c></root>)r�r�r�z4<root><a><b>abtext</b></a><b>btext</b><c></c></root>r�r�zC<root><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>)r�za<root>
    
    
    <c>
        <x:d xmlns:x="http://example.com/x">dtext</x:d>
    </c>
</root>zI<root><a xmlns:x="http://example.com/x" x:attr="attrx"></a><c></c></root>zu<root>
    <a xmlns:x="http://example.com/x" x:attr="attrx">
        
    </a>
    
    <c>
        
    </c>
</root>)rGrHrdr�r�rrr�test_c14n_exclusion�sF

���
����	��zC14NTest.test_c14n_exclusioncstddd�}ttjj|��dd�tt�|��D��dd��D�}�fdd��D����fd	d�|D�}|�d
tdd�|�	�D���d/dd
�}|�
�D�]f\}}|D�]V\}}||d�dk}	||d�dk}
||d�dk}d|v�rdd�|dd�d�D�}dd�|dd�d�D�}
nd}
}d�dd�t|�
��D��}|�|�d|�d�����|dk�rz|�sz|�
d|���|d k�r�|�s�|�
d|���d|v�r�|dd�d!�du�r�|�
d"|����|d#�}|d$k�rXt�d%�d&��V}t|d&��*}t�|���d'|����}Wd�n1�s.0YWd�n1�sN0Ytj||	|
||
|d(�}t�|d#�d)d*d+��:}|��}|d,k�r�|�d-d.�}|�d-d.�}Wd�n1�s�0Y|�||�Wd�q�1�s�0Yq�q�dS)0Nzc14n-20rr
cSs"g|]}|�d�r|dd��qS)�.xmlNr�)�endswith�rE�filenamerrrrFs
�z+C14NTest.test_xml_c14n2.<locals>.<listcomp>cSsg|]}|�d�r|�qS)�in)�
startswithr�rrrrFs
�cs8i|]0}|�d�r|dd�t��|�d���D��qS)Zc14ncSs,i|]$}|j�d�d|jpd��|f�qS)�}rdru)rC�splitr`r�)rE�optionrrr�
<dictcomp>s�z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<dictcomp>r�)r�r.r�r�r�)�	full_pathrrr�s

��z+C14NTest.test_xml_c14n2.<locals>.<dictcomp>cs"i|]����fdd��D��qS)csJg|]B}|�d��d��r|�dd�d�vr|�|�dd�df�qS)Zout_r�rrrd)r��rsplitr�)�configs�
input_filerrrF#s�z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<listcomp>r)rE)r�files)rrr�"s���cSsg|]}|D]}|�qqSrr)rE�output_files�output_filerrrrF-s�cSs|�||df�dS)Nrr�rV)�configZoption_namer�rrr�
get_option1sz+C14NTest.test_xml_c14n2.<locals>.get_optionZIgnoreComments�trueZ
TrimTextNodesZ
PrefixRewriteZ
sequentialZ
QNameAwarecSs(g|] }d|�d��d|�d����qS��{ZNSr��Namerr[rrrrF=s�rrz/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrcSs(g|] }d|�d��d|�d����qSrrr[rrrrFBs�z){http://www.w3.org/2010/xml-c14n2}Element�,css8|]0\}\}}|�d|p*d�dd�|D����VqdS)�=rcss|]}|j�d�dVqdS)r�rdN)rCr�)rEr�rrr�	<genexpr>LrGz4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>N)r�)rErXr{rCrrrrKs
�z*C14NTest.test_xml_c14n2.<locals>.<genexpr>�(�)Z
inNsRedeclz2Redeclared namespace handling is not supported in ZinNsSuperfluousz.{http://www.w3.org/2010/xml-c14n2}XPathElementz2QName rewriting in XPath text is not supported in r�ZinC14N5z	world.txtrs&ent2;)Z	from_fileZ
with_commentsr��rewrite_prefixesZqname_aware_tagsZqname_aware_attrs�rrsr�ZinC14N3z attr="default"ru)N)rrrr�r�r��listdirrdre�valuesr~r�r�rHr�r�r6r7r�rr.r�)r*ZdatadirZinput_filesZtestsr	rrrrZ
keep_commentsr�rZqattrsZqtagsZconfig_descrr�Zentity_filer`rpr)rrr�r�test_xml_c14n2s��
�
��

������
����

������
Z�
,zC14NTest.test_xml_c14n2)r1r2r3ZmaxDiffr�r�rrrrrr��s(Pr�cCs:tddgd�a|durt}|attttttt	t
ttt
tttttttg}tturZ|�tg�ddlm}tjj}|��}|j}|��|_ttd�r�t�tjtj �}nd}zLt!j"|�Wddlm}|�#�|�$|�||_|dur�tj|�daanBddlm}|�#�|�$|�||_|du�r,tj|�daa0dS)Nr,r-)Zblockedrr'�_set_factories)%rrLr.r#r�r�r�rror�r�rVrr"r;rBrtr�rfr�r�r�r�r)r(r�Z_namespace_mapr�r�r�rr-r�rZrun_unittestr�ru)�moduleZtest_classesr(r2Z
nsmap_copyrZ
old_factoriesrrr�	test_mainusj���




�


r�__main__)Tr4)N)Nr�rr�r6r�rirrQrFrPrGr�rJrzr�rrrrrZtest.supportrrrr	r
rrLr.r�r �UnicodeEncodeErrorr�r�r�r�r'r�r�r�r�rr"ZTestCaser#rArIrJror�rX�format�escaperdrVrfr�r�r�r��__hash__rrrr"r;rBrtr�r�r�r�r�r�r�r�rr1rrrr�<module>s� 


	

 .3	

�	7fd48W`xT
$f
E


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