%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream

nadelinn - rinduu

Command :

ikan Uploader :
Directory :  /vddos/python/lib/python3.9/test/__pycache__/
Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 
Current File : //vddos/python/lib/python3.9/test/__pycache__/test_xml_etree.cpython-39.pyc
a

�_g�i�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlmZddlmZmZddlmZddlmZmZmZmZmZdadaeddd�Zze�d	�Wney�e�d
��Yn0eddd�Z eddd�Z!d
Z"dZ#dZ$dZ%dZ&dZ'dd�dd�Z(Gdd�dej)�Z*dndd�Z+dd�Z,Gdd �d �Z-Gd!d"�d"ej)�Z.Gd#d$�d$ej)�Z/iZ0d%e0d&<d'e0d(<d)e0d*<d+e0d,<d-e0d.<d/e0d0<d1e0d2<d3e0d4<d5�1e�2ed��e0d6<d7e0d8<iZ3d9e3d:<d;e3d<<d=e0d><d?e0d@<dAe0dB<GdCdD�dDej)�Z4GdEdF�dFej)�Z5GdGdH�dHe-ej)�Z6GdIdJ�dJe-ej)�Z7GdKdL�dLe8�Z9e8j:e9_:GdMdN�dNe8�Z;e8j:e;_:GdOdP�dPe-ej)�Z<GdQdR�dRej)�Z=GdSdT�dTej)�Z>GdUdV�dVej)�Z?GdWdX�dXej)�Z@GdYdZ�dZej)�ZAGd[d\�d\ej)�ZBGd]d^�d^ej)�ZCGd_d`�d`ej)�ZDGdadb�dbej)�ZEGdcdd�ddej)�ZFGdedf�dfej)�ZGdgdh�ZHGdidj�djej)�ZIdodkdl�ZJeKdmk�r�eJ�dS)p�N)�partial)�product�islice)�support)�TESTFN�findfile�import_fresh_module�
gc_collect�	swap_attrz
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��2/vddos/python/lib/python3.9/test/test_xml_etree.py�newtestlsz1checkwarnings.<locals>.decorator.<locals>.newtest)�	functools�update_wrapper)rr�rr)rr�	decoratorksz checkwarnings.<locals>.decoratorr)rrrrrr�
checkwarningsjsrc@seZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree��ElementInclude��ElementPath)�	xml.etreerrr )�selfrrr rrr�test_sanityus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#r(rrrrrtsrT�unicodecKsX|dkrt��}nt��}t�|�}|j|fd|i|��|rF|��S|�d�|SdS)Nr,�encodingr)�io�BytesIO�StringIOr&r�write�getvalue�seek)�elem�	to_stringr-�options�file�treerrr�	serialize�s


r9cCsdd�|D�S)NcSsg|]
}|j�qSr��tag��.0r4rrr�
<listcomp>��z"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_list�srAc@s(eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS�N)�pyETr&�modules)�clsrrr�
setUpClass�szElementTestCase.setUpClasscCs�tj|}z�z.|tj|<t�||�}|tj|<t�|�}Wn`tjy�}	zFttdftdfg�}
t	�
d||
�||�|
�||�f�|	�WYd}	~	n
d}	~	00W|tj|<n|tj|<0|S)NZcETrDz%Failed to round-trip %r from %r to %r)�sysrE�pickle�dumps�loads�
PicklingError�dictr&rDrZ
TestFailed�get)r"�obj�name�dumper�loader�protoZsave_mZtemp�result�peZhumanrrr�pickleRoundTrip�s$




���zElementTestCase.pickleRoundTripcCs�|�|tjtjf�|�|tjtjf�|�tt|��tt|���t||�D]\}}|�||�qNt	�
dddd�}|�||�||��dS)Nr;�tail�text�attrib)�assertIsInstancer&�ElementrD�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)r"Zalice�bob�x�yZ
propertiesrrrr`�sz#ElementTestCase.assertEqualElementsN)r)r*r+�classmethodrGrVr`rrrrrB�s
rBc@sdeZdZdd�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-dWS)X�ElementTreeTestcCs|�t|�|�dSrC)r\r9)r"r4�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)r]r\)�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 %rrk)r]�keys�itemsr\)�mappingrurvrt�itemrqrr�
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 elementrk)r;rYrXrWzno %s memberzno %s visible by dir)
�
assertTruer&Z	iselement�dir�hasattr�assertInr;rYrXrW)�elementZdirelem�attrr4)�
check_elementryrrr"rrr��s"��





z5ElementTreeTest.test_interface.<locals>.check_elementr;�tägrs�rtz^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callablerk)rzr|��methodrqrr�check_method�s�z4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dSrC)�__next__)�it)r�rr�
check_itersz2ElementTreeTest.test_interface.<locals>.check_iter�*)r&r[r�getroot�assertRegex�repr�append�extend�insert�remove�find�iterfind�findall�findtext�clearrN�setrurv�iter�itertextr\�XML�
fromstring�PI�ProcessingInstruction)r"r~r8r�r)r�ryr�rrr"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)Nr;�TagZTAG�TextZTEXTZTailZTAIL�b�d)�a�c�B�D)�A�C)r&r[r\r;�assertIsNonerXrWrY)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>r;rsr�z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listrjz
<subtag />�	�)r&r�rir[r�r�r�r�r��assertRaises�
ValueErrorr\�str�	exception)r"r4�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>)rir&r�rqrrr�
test_cdataWs���zElementTreeTest.test_cdatacCs|t�t�d��}tj|d�}|�|�d�jd�|�|�d�jd�tjt	d�}|�|�d�jd�|�|�d�jd�dS)Nr
)r7r;�section/tagr~zelement/../empty-element�
empty-element)
r.r/�
SAMPLE_XML�encoder&rr\r�r;�SIMPLE_XMLFILE)r"Z
stringfiler8rrr�test_file_initas�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��rangerr�r�r]�_cacher\Z
assertGreaterZ
assertLess)r"r r4�iZcache_len_10rrr�test_path_cachels
&
&&&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�r;ri)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)Nr;rt�defaultrsr��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;  " />)r;)r&r[rNr\r�rYr�rX�tostring�sortedrurv)r"r4rYrrr�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)
Nr;rtrsr�zattrib aliasingrkz!<tag><subtag key="value" /></tag>�<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r&r[Zmakeelement�assertIsNotrYr�rir�r��tuple)r"r4rY�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)Nr,�r-zi<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�r.r0r1r\r2�SIMPLE_NS_XMLFILE�open�read�	XMLParserr��version�feedri�close�TreeBuilder)r"r8�stream�f�data�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>r,r�)z<html><body>ztext</boz
dy></html>�<html><body>text</body></html>r?�asciisE<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>rz(<html><body id='body'>text</body></html>rj�body)r&r�r\r�r�Zfromstringlist�join�tostringlistZXMLIDr]r;)r"r~Zsequence�_Zidsrrr�test_parseliterals0
�
�
���z!ElementTreeTest.test_parseliteralc	Cs�tj}|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�0YdS)$N��endr~cSsg|]\}}||jf�qSrr:�r=�actionr4rrrr>r?z2ElementTreeTest.test_iterparse.<locals>.<listcomp>)r��r�r��r��rootr�cSsg|]\}}||jf�qSrr:r�rrrr>&r?)�r��{namespace}elementr��r��{namespace}empty-element�r��{namespace}rootrcSsg|]\}}||jf�qSrr:r�rrrr>/r?��eventscSsg|]\}}||jf�qSrr:r�rrrr>3r?��startr�cSsg|]\}}||jf�qSrr:r�rrrr>7r?��rr��rr~r�r	r�)rr�r�r�)rr��start-ns�end-nscSs*g|]"\}}|dvr||jfn||f�qS)rr:r�rrrr>Ds�)
�r
)rm�	namespace�rr�rr�r�rr��rrr�r�rN�r
rz<root xmlns=''/>cSsg|]\}}|�qSrrr�rrrr>Ur?r
r�rr�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>
)r
cSsg|]\}}||f�qSrrr�rrrr>kr?)r
)rmuhttp://éffbot.org/ns)r
)uclé�http://effbot.org/nsz<document />junk)r��documentz.junk after document element: line 1, column 12�wbs<document />junk)r&�	iterparser��nextr\r;r�r�r.r0r�r�r��assertFalse�closedr�r�rZcheck_no_resource_warningr/�
ParseError�
addCleanup�unlinkrr1)r"r�contextr�r4r�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)Nr;rXz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>rtrsz)text<?key value?><subtag>subtext</subtag>)	r&r[rXri�
SubElementr;r��Commentr��r"r4rrr�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"r;rYrrrr�s�:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|�d|f�dS�Nr�r+�r"r;rrrr��s�8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdSrCr�r"rXrrrr��s�9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r)r*r+rr�r�rrrr�Builder�sr3r�rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r)cSs|�d|f�dSr*r+r,rrrr�sr-cSs|�d|f�dSr.r+r/rrrr��sr0cSsdSrCrr1rrrr��sr2cSs|�d||f�dS)N�pir+)r"r�r�rrrr4�sz7ElementTreeTest.test_custom_builder.<locals>.Builder.picSs|�d|f�dS)Nr$r+)r"r�rrrr$�sz<ElementTreeTest.test_custom_builder.<locals>.Builder.commentcSs|�d||f�dS)Nr
r+)r"�prefix�urirrr�start_ns�sz=ElementTreeTest.test_custom_builder.<locals>.Builder.start_nscSs|�d|f�dS�Nrr+�r"r5rrr�end_ns�sz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_nsN)
r)r*r+rr�r�r4r$r7r:rrrrr3�s))r4r4r�)r$�	 comment )r
rmr
rrr�rr�rr�r�rrm)	r�r�r�r^r&r�r�r\r�)r"r�r�r3�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�dSr8r+r9rrrr:�szGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_nsN)r)r*r+r:rrrrr3�sr3r�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�pr<)r^r&r�r��textwrap�dedentr\)r"r3r=r�rrr�test_custom_builder_only_end_ns�s
	z/ElementTreeTest.test_custom_builder_only_end_nscCs|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�rAr<rrrr>�s�z1ElementTreeTest.test_children.<locals>.<listcomp>)r~r~r�cSsg|]}t|��qSrrCr<rrrr>�s��r�rjr)
r�r�r&r�r\r�r�r�r�r]r^�assertNotEqualr�)r"r�r8r4�child1�child2rrr�
test_children�sH(

���
���

zElementTreeTest.test_childrencCs<t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nr�r�)r&r�r\r�r�r'rrr�test_writestrings

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��indentr\r�r'rrr�test_indents0









�

�zElementTreeTest.test_indentcCsXt�d�}tj|dd�|�t�|�d�t�d�}tj|dd�|�t�|�d�dS)NrJ�	)�spacesD<html>
	<body>
		<p>pre<br />post</p>
		<p>text</p>
	</body>
</html>rms><html>
<body>
<p>pre<br />post</p>
<p>text</p>
</body>
</html>rKr'rrr�test_indent_spaceAs
�

�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�rW�r=�elrrr�	<setcomp>^r?z<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>>�
�
  N�
    cSsh|]
}|j�qSr�rXrRrrrrTbr?>ZparrXNrWrVz
      cSsh|]
}|j�qSrrQrRrrrrTfr?cSsh|]}t|j��qSr)�idrWrRrrrrTgr?)r&r�rLr\r�r]r'rrr�test_indent_space_cachingZs

���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)NrJ���)�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>rjrn)r\rOsI<html>
  <body>
   <p>pre<br />post</p>
   <p>text</p>
  </body>
 </html>)r&r�r�r�rLr\r�r'rrr�test_indent_leveljs$
,��

�z!ElementTreeTest.test_indent_levelcCs<t�d�}|�tj|dd�d�|�tj|ddd�d�dS)N�0<body xmlns="http://effbot.org/ns"><tag/></body>r,r��A<ns0:body xmlns:ns0="http://effbot.org/ns"><ns0:tag /></ns0:body>r�r-�default_namespace�1<body xmlns="http://effbot.org/ns"><tag /></body>�r&r�r\r�r'rrr�test_tostring_default_namespace�s
��z/ElementTreeTest.test_tostring_default_namespacecCs&t�d�}|�tj|ddd�d�dS)Nr^r,�foobarr`zP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>rcr'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$r,rer`)r&r��assertRaisesRegexr�r�)r"r4Z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�r,r�r�rcr'rrr� test_tostring_no_xml_declaration�s

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

�z-ElementTreeTest.test_tostring_xml_declarationcCs6t�d�}t��}|�d|�d�tj|ddd��dS)Nr��<?xml version='1.0' encoding='�'?>
<body><tag /></body>r,Trk)r&r��locale�getpreferredencodingr\r�)r"r4�preferredencodingrrr�.test_tostring_xml_declaration_unicode_encoding�s

�z>ElementTreeTest.test_tostring_xml_declaration_unicode_encodingcCs�t�d�}t��}dddddddd	d
ddd
ddd|�d�ddfg}|D]X\}}}|�d|�d|����(|�tj|||d�|�Wd�qF1s�0YqFdS)N�<body><tag>ø</tag></body>)�<body><tag>&#248;</tag></body>NN)�<body><tag>ø</tag></body>�UTF-8N)ru�US-ASCIIN)�E<?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag>�</tag></body>�
ISO-8859-1N)rtr,N)ruNF)rvrwF)rurxF)s<body><tag>�</tag></body>rzF)rtr,F)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>rwT)sH<?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>rxT)ryrzTrnu'?>
<body><tag>ø</tag></body>r,Tz	encoding=z xml_declaration=rk)r&r�rprq�subTestr\r�)r"r4rrZ	TESTCASESZexpected_retvalr-rlrrr�#test_tostring_xml_declaration_cases�s@

���
��z3ElementTreeTest.test_tostring_xml_declaration_casesc	CsHt�d�}|�d�tj|dd��d�|�d�tj|ddd��d�dS)	Nr^rmr,r�r_rr`rb)r&r�r\r�r�r'rrr�#test_tostringlist_default_namespace�s
��z3ElementTreeTest.test_tostringlist_default_namespacecCs�t�d�}|�d�tj|dd��d�|�d�tj|dd��d	�t��}tj|ddd
�}|�d�|�d|�d��|�|d
d�|�gd�|dd��dS)Nr�rmr,r�r�r?T)rls><?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>rkrnrorz%^<\?xml version='1.0' encoding='.+'?>)z<body�>z<tagz />z</body>rj)r&r�r\r�r�rprqr�)r"r4rrZ
stringlistrrr�!test_tostringlist_xml_declaration�s"
��
�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)Nrmcs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)r\r&r�r�rX)r-r��xmlrqrr�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�|��|�SrC)r�r�)r�rr�bxmlsz+ElementTreeTest.test_encoding.<locals>.bxml)Cr�r
z	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)rm)	r\r&r�r�r�r�rr��LookupError)r"r�r�Zsupported_encodingsr-Z&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>rUz/<html><link /><script>1 &lt; 2</script></html>
r�r��htmlz*<html><link><script>1 < 2</script></html>
rXz1 < 2
)r&r�rWr\r9�r"r�rrr�test_methods?s

����zElementTreeTest.test_methodscCs2t�d�}|�t|�d�|�t|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>r�r��r&r�r\r9r�rrr�test_issue18347Ns

��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 10rX�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r&r�r\r9rir�rr�r��
ENTITY_XMLr�r�r�r��EXTERNAL_ENTITY_XML)r"r�r�r�r�rrr�test_entityUs2
�(�(�

*�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�ri�
SAMPLE_XML_NSr'rrr�test_namespacezs$

�
�
�
�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" />r6r;Ztag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>rsz{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&r[ri�QNamer%r�rYr�r\r�rE)r"r4r�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)@Nrrcs"��dd���||�D�|�dS)NcSsg|]\}}|p|�qSrr)r=�opr;rrrr>�s�zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)r\Zxpath_tokenizer)r?rh�
namespaces�r r"rrr��s


��z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkr�ztext()rX�()z@name�@rPz@*zpara[1])�para�[�1�]zpara[last()])r�r�Zlastr�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�rx�.z.//para)r�r�r��..z../@lang)r�r�r��langzchapter[title])r�r��titler�z#employee[@secretary and @assistant])
Zemployeer�r�Z	secretaryrm�andrmr�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�rmz	@xsd:typez@typez@{*}typez{*}type)rmr�)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&>�?>)r\r&r�r�r�rqrrr�test_processinginstructions����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>)�lowerr9r&r�r\)r"r~r4rhZ
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&r[r�captured_stdout�dumpr\r2)r"r��stdoutrrr�test_dump_attribute_order;s
(
�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&r[r\r9�r"r�rrr�test_tree_write_attribute_orderCs
��z/ElementTreeTest.test_tree_write_attribute_orderN).r)r*r+rir�r�r�r�r�r�r�r�r�r�r�r"r(r>rBrHrIrMrPrZr]rdrfrhrirmrsr|r}rr�r�r�r�r�r�r�r�r�r�r�r�rrrrrg�sVV,
6-p=%, -;%!A:
rgc@s�eZdZd dd�Zd!dd�Zd"dd�Zd#dd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)$�XMLPullParserTestNcCsD|dur|�|�n,tdt|�|�D]}|�||||��q$dS�Nr)r�r�r])r"r�r��
chunk_sizer�rrr�_feedNszXMLPullParserTest._feedcCs$|�dd�t|��|�D�|�dS)NcSs g|]\}}||j|jff�qSr)r;rX)r=�eventr4rrrr>Ws�z3XMLPullParserTest.assert_events.<locals>.<listcomp>)r\r�read_events�r"r�rh�
max_eventsrrr�
assert_eventsUs��zXMLPullParserTest.assert_eventscCs|�tt|��|��|�dSrC)r\r^rr�r�rrr�assert_event_tuples[s�z%XMLPullParserTest.assert_event_tuplescCs(t|��|�}|�dd�|D�|�dS)NcSsg|]\}}||jf�qSrr:r�rrrr>br?z7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)rr�r\)r"r�rhr�rrrr�assert_event_tags`s�z#XMLPullParserTest.assert_event_tagsc	Cs�dD]�}|j|d���t��}|�|g�|�|d|�|�|g�|�|d|�|�|g�|�|d|�|�|dg�|�|d|�|�|d|�|�|dd	g�|�|d
|�|�|dg�|�|���Wd�q1s�0YqdS)N)Nrj�)r��<!-- comment -->
z+<root>
  <element key='value'>text</element�>
r��<element>text</element>tail
�<empty-element/>
r��</root>
r�)r{r&�
XMLPullParserr�r�r�r�)r"r�r�rrr�test_simple_xmles,��z!XMLPullParserTest.test_simple_xmlcCs�t��}|��}|�|d�t|�\}}|�||jfd�|�|d�t|�\}}|�||jfd�|�t��t|�Wd�n1s�0YdS)Nz-<root>
  <element key='value'>text</element>
r�rr�)	r&rr�r�rr\r;r��
StopIteration)r"r�r�r�r4rrr�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</elementrr�rrr�rr)r&rr�r�r�r��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)Nrrrr	rr
rrrrr)r&rr�r\r^r�r�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)r
rr�r� <tag xmlns='abc' xmlns:p='xyz'>
�r
)rm�abc�r
)r?Zxyzr��r��r�{abc}tagrj�
<child />
�r�
{abc}child�r�r�</tag>
�r�r�r&rr�r�r�r�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)r
rr�rrrrrr�rrrjrrrrrrrrrrr�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)Nrrz<root/>
r�<!-- text here -->
z<root>
rr
r	rr�z8<element xmlns='foo'>text<empty-element/></element>tail
)�r�{foo}element�r�{foo}empty-element)r�r")r�r z</root>r�)rrrr!)r&rr�r�r�r�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)rr$r�rrr$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�r$z<!-- outer comment -->
z outer comment )r$)r&rr�r�r&r�rrrr�test_events_comments z%XMLPullParserTest.test_events_commentcCsdtjdd�}|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)	N)rr4r�rz
<?pitarget?>
r4�pitarget)r4z<?pitarget some text ?>
zpitarget some text )r&rr�r�r�rrrr�test_events_pisz XMLPullParserTest.test_events_picCslddh}tj|d�}|�|d�|�|ddg�Gdd�d�}tj|�d�}|�|d�|�|ddg�dS)	Nr�rrz<foo>bar</foo>)rr�)r�r�c@s$eZdZdd�Zdd�Zdd�ZdS)z9XMLPullParserTest.test_events_sequence.<locals>.DummyItercSstgd��|_dS)N)rr�r
)r�rrqrrr�__init__/szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|SrCrrqrrr�__iter__1szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�SrC)rrrqrrrr�3szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r)r*r+r(r)r�rrrr�	DummyIter.sr*)r&rr�r�)r"Zeventsetr�r*rrr�test_events_sequence'sz&XMLPullParserTest.test_events_sequencecCs:|�t��tjdd�Wd�n1s,0YdS)Nrr)r�r�r&rrqrrr�test_unknown_event:sz$XMLPullParserTest.test_unknown_event)N)N)N)N)r)r*r+r�r�r�r�rrrr
rrr#r%r'r+r,rrrrr�Ls



.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�r-r�rrr�xinclude_loader�s
zXIncludeTest.xinclude_loadercCsdSrCr)r"r<r�r-rrr�none_loader�szXIncludeTest.none_loadercCsJ|dkrBt|d��}t�|���Wd�S1s60YndSdS)Nr�r)r�r&r�r�)r"r<r�r�rrr�
_my_loader�s.zXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nrrr2z�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r!rr=�includer?r\r9)r"rr�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)Nrrr-a<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>r.zO<document>
  <p>This document has been accessed
  324387 times.</p>
</document>r/zX<document>
  <p>This document has been <em>accessed</em>
  324387 times.</p>
</document>r0z�<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>r1r8aI<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!rr=r@r\r9r�r;r�r��r"rrr�rrr�
test_xinclude�s8

�

�

�

�
,
�zXIncludeTest.test_xincludecCs>ddlm}|�d�}|�||j�|�dt|�d���dS)Nrrr3r�z.//p)r!rr=r@r\r]r�)r"rrrrr�test_xinclude_repeated(s
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)Nrrr-)rRz%cannot load 'disclaimer.xml' as 'xml'r.z!cannot load 'count.txt' as 'text'r4z1unknown parse type in xi:include tag ('BAD_TYPE')r5zYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')r6z#recursive include of Recursive2.xml)Z	max_depthzAmaximum xinclude depth reached when including file Recursive2.xmlrjzAmaximum xinclude depth reached when including file Recursive3.xmlr�zAmaximum xinclude depth reached when including file Recursive1.xmlrD)r!rr&r�r9r�ZFatalIncludeErrorr@r>r\r�r��XINCLUDE_BADr=ZLimitedRecursiveIncludeErrorrBrrr�test_xinclude_failures/sz.�.�0�0�
.�
2�
2�
2�
2�
2�z#XIncludeTest.test_xinclude_failures)r�N)N)
r)r*r+r=r>r?rArCrDrFrrrrr7�s
	
	@r7c@seZdZdd�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:d;�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��	TypeErrorr9r\r�r�)r4r�rqrrr�~s
&�z-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r4Z123)r&r[rXrWr�)r"r�r4rrqr�test_bug_xmltoolkit21{s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)Nr;rXr�r#)r&r�r�rr\r�)r"r4r8rrr�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�r\rAr��r"r8rrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28cCsPt�d�}t���*}t�|�|�|��d�Wd�n1sB0YdS)NrLz$<doc><table><tbody /></table></doc>
)r&r�rr�r�r\r2)r"r8r�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 />r
s<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�r;)r&r�r\r�rYr[r�rMrrr�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_xmltoolkit54�s

�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&rr�r\r�r�)r"r�rrr�test_bug_xmltoolkit55�s
(�zBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|�ttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�dSrC)r;�r"rdrrrr��sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r)r*r+r�rrrr�
ExceptionFile�srT)r�r;r&r�)r"rTrrr�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�r\r�rX)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)Nr;rX)r&r�rr�r�)r8rrr�xmltoolkit63�s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)rH�getrefcountr�r\)r"rY�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
rXs0<SomeTag text="def _f():&#10;  return 3&#10;" />rX)r&r[r\r�r�rNr�rrr�test_bug_200708_newlines���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&r[rqrrrr�sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN�r)r*r+r�rrrr�
EchoTargetsr`r�)r&r�r�r\r�r;)r"r�r`rrr�test_bug_200708_close
s

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�)raz%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>r4z<cannot use non-qualified names with default_namespace option)	r&r[r%r\r9r�r�r�r�)r"r��sr�rrr�!test_bug_200709_default_namespaces&
�
�
*�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&r[r\r��register_namespacer�rrr�"test_bug_200709_register_namespace2s
�
�
�z+BugsTest.test_bug_200709_register_namespacecCs`t�d�}|�t�d��|�|djtj�t�d�}|�t�d��|�|djtj�dS)Nr�r�r)r&r[r�r&r\r;r�)r"r�rrr�test_bug_200709_element_commentAs

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�r[)r�r�r�r�)r&r[r%r�r\rA�r"r�r�r�r�rrr�test_bug_200709_element_insertMs

z'BugsTest.test_bug_200709_element_insertcCsJt�d�}t�|d�}t�d�}|�|�|�t|�tj��tjg�dS)Nr�r�zTEST-b)r&r[r%r&r�r\rAr�)r"r�r�Z	comment_brrr�test_bug_200709_iter_commentWs



z%BugsTest.test_bug_200709_iter_commentcCsDt��}|�d�}|�di�}|�d�}|��}|�t|�d�dS)Nr�r;r�)r&r�r�rr�r�r\r9)r"rcr�rrr�test_bug_1534630as

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>rcr�rrr�test_issue6233is
�
�zBugsTest.test_issue6233cCs8t�d�}|�|jd�t�|�}|�t�|�d�dS)Nz+<prefix:localname xmlns:prefix="${stuff}"/>z{${stuff}}localnames&<ns0:localname xmlns:ns0="${stuff}" />)r&r�r\r;rr�)r"r�rWrrr�test_issue3151us

zBugsTest.test_issue3151cCsRt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�gd��dS)Nr�r;�r;r;r�)r&r�r\rAr�)r"r4Znewelemrrr�test_issue6565{s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)NZ	test10777z
http://myuri/)r&rdrqrrr�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�changedTrXrq�r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N�r)r*r+rrrrqrrr��sr�r;rp)r&r[rXr�rrZr�r\�r"r�r�rWrrqr�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�NrprTrQrqrqrrrr�s
z.BugsTest.test_lost_tail.<locals>.Text.__bool__Nrsrrqrrr��sr�r�r;rrp)	r&r[r�rWr�rrZr�r\rtrrqr�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��dSrv)r&r[r)r"r��r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N�r)r*r+ryrrxrrr��sr�r�r;zgenerators are not reentrantrrp)r&r[r�r�rr��skipTestrZr;r�r\)r"r�rWrrxr�test_lost_elem�s

zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�r
)r&r�r\rN�decode)r"rXr�r�rrr�check_expat224_utf8_bug�s
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r~r1rrr�test_expat224_utf8_bug�s
zBugsTest.test_expat224_utf8_bugcCs�ttd��}|��}Wd�n1s(0Yt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nrr�r
r�rn����)
r��UTF8_BUG_XMLFILEr�r&r�rNr}�strip�replacer\)r"�fp�rawr�ZxmlattrrXrrr�test_expat224_utf8_bug_file�s&

z$BugsTest.test_expat224_utf8_bug_filecCs.|�tt��jd�|�tt��jdd�dS)Nr;)r�rHr&r�rrqrrr�test_39495_treebuilder_start�sz%BugsTest.test_39495_treebuilder_startN)$r)r*r+rJrKrNrOrPrQrRrUrX�unittestZskipIfrH�gettracer\r]rarcrerfrhrirjrkrlrnrorurwr|r~rr�r�rrrrrGys<			



rGc@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�wypr;rYrXrW�bazr�)
r&r[rZr}r{r\r;r�rXrWr�rYrE)r"r;rY�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&r[r��SkipTestr�ZassertWarns�DeprecationWarningr�r�r\r;rXrWr]�	itertools�zip_longest�assertIsrY�r"r�Zelement_foo2rFrGrrrr�	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&r[r�r�r�r\r;rXrWr]r�r�r�rYr�rrr�
test___copy__	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&r[r�r�r�r�r\r;rXrWr]r�r�rYrEr�rrr�test___deepcopy__5	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__r;rrWrX)r;�	_childrenrYrWrX�__deepcopy__c@seZdZdd�ZdS)z9BasicElementTest.test_augmentation_type_errors.<locals>.EcSsdSrCr)r"�memorrrr�j	szFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__N)r)r*r+r�rrrr�Ei	sr�)r&r[r�rHr�r�r�r|r�r�r�)r"r��stater�rrr�test_augmentation_type_errorsS	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�r)r*r+rrrr�Dummyp	sr�r�)rr�r�r�r�)	r&r[Zdummyref�weakref�refr	r�r%r�)r"r�r��wrefr�r�r�r�rrr�test_cyclic_gco	s2









zBasicElementTest.test_cyclic_gccsVd��fdd�}t�d�}t�||�}|�|�jd�~|��d�|�|�d�dS)NFcsd�dS�NTr)�w��flagrr�wref_cb�	sz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)r&r[r�r�r\r;)r"r�r�r�rr�r�test_weakref�	s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�rjr�rD)rdre�zrd�)r�r�)r&r[r\rN)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�rj��repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrrzother valuer$r�)r�rI�HIGHEST_PROTOCOLrrEr[rXrWr%r�r�r�rVr\r;rYr]r`)r"rSrQrRr�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�rjr�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r;�groupr$rZdogs)r�rIr�rrEr�r|r\r�rVr;)r"rSrQrRZXMLTEXTr�r�rrr�test_pickle_issue18997�	s

�z'BasicElementTest.test_pickle_issue18997N)
r)r*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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^rq��Lrr�	__class__�	sz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N�r)r*r+�propertyr�rr�rr�X�	sr�r�c@seZdZdS)z2BadElementTest.test_extend_mutable_list.<locals>.YNr�rrrr�Y�	sr�rd�r&r[r�rH�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�=tjSrCr^rqr�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"�orqrrry�	s
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__Nrzrrqrrr��	sr�r�r�r�)r&r[r�r�r�r��r"r�rrqr�test_remove_with_mutating�	s

z(BadElementTest.test_remove_with_mutatingc	Cslt�d�}t|d|��B|�t��t|�Wd�n1s@0YWd�n1s^0YdS)Nr�r;)r&r[r
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
�jWntyYn0dSrC)rX�	NameErrorrq�r4rr�__del__
s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N�r)r*r+r�rr�rrr�
sr�r;�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�r&r�rr�r�r�r\rX�r"r�r�rr�r�test_element_get_text
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�)rWr�rqr�rrr�
sz7BadElementTest.test_element_get_tail.<locals>.X.__del__Nr�rr�rrr�
sr�r�r;r�r�r�rr�)	r�r&r�rr�r�r�r\rWr�rr�r�test_element_get_tail
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�Nrjrrqrqrr�	__index__+
s
z/BadElementTest.test_subscr.<locals>.X.__index__N�r)r*r+r�rrqrrr�*
sr�r4r�rr�)r&r[r�r�rrqr�test_subscr(
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�rrqrqrrr�9
sz3BadElementTest.test_ass_subscr.<locals>.X.__index__Nr�rrqrrr�8
sr�r4r�rr�)r&r[r�r�)r"r�r�rrqr�test_ass_subscr6
s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcSsgSrCr�rdrerrr�element_factoryE
sz>BadElementTest.test_treebuilder_start.<locals>.element_factory�r�r;r�r�)r&r�rr�r��AttributeErrorr	�r"r�r�rrr�test_treebuilder_startC
s
z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|�di�|�d�|�t|jd�~t�dS)NcSsgSrCrr�rrrr�Q
sz<BadElementTest.test_treebuilder_end.<locals>.element_factoryr�r;r�)r&r�rr�r�r�r�r	r�rrr�test_treebuilder_endO
s
z#BadElementTest.test_treebuilder_endN)
r)r*r+r�r�r�r�r�r�r�r�r�r�rrrrr��	s

r�c@seZdZdd�Zdd�ZdS)�MutatingElementPathcGstj|g|�R�}||_|SrC)r��__new__r4)rFr4rr"rrrr�]
szMutatingElementPath.__new__cCs|jdd�=dSr�r�r�rrrrya
szMutatingElementPath.__eq__N)r)r*r+r�ryrrrrr�\
sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)Nrjrrr�rrrryg
szBadElementPath.__eq__Nrzrrrrr�f
sr�csXeZdZ�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�l
s
zBadElementPathTest.setUpcs"ddlm}|j|_t���dSr�)r!r r�r�r��tearDownr�r�rrr�r
szBadElementPathTest.tearDowncCs0t�d�}|�t�d�g�|�t|d��dS�Nr�r�rd)r&r[r�r�r�r�rrr�test_find_with_mutatingw
s
z*BadElementPathTest.test_find_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr�)r&r[r�r�r��ZeroDivisionErrorr�rrr�test_find_with_error|
s
z'BadElementPathTest.test_find_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&r[r�r�r�r�rrr�test_findtext_with_mutating�
s
z.BadElementPathTest.test_findtext_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr�)r&r[r�r�r�r�r�rrr�test_findtext_with_error�
s
z+BadElementPathTest.test_findtext_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&r[r�r�r�r�rrr�test_findall_with_mutating�
s
z-BadElementPathTest.test_findall_with_mutatingcCsFt�d�}|�t�d�g�z|�td��Wnty@Yn0dSr�)r&r[r�r�r�r�r�rrr�test_findall_with_error�
s
z*BadElementPathTest.test_findall_with_error)r)r*r+r�r�r�r�r�r�r�r��
__classcell__rrr�rr�k
sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�dSrC)	rZr&rr�r�rr[r�r�rqrrr�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�
sr�r�r�)r&r[rZr\r;rX�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�__)r�r()r"r;rY�extra)r�r�rrr(�
szQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r)r*r+r(r�r�r�r�rr��
sr�r�rjr�)r�r�rD�)r�r�Zfoo__))r�rj)r�r�)r�rD)r�r)r&r[r\r;r�rv)r"r�rrr�!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|jSrCr:rqrrr�	newmethod�
szQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r)r*r+rrrrrr��
sr�r�)r&r[r\rr�rrr� test_Element_subclass_new_method�
sz4ElementTreeTypeTest.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��
sr�r�rXr�r#rjr)r&r[rXr�r\r�r�r;r^r�r])r"r�r��sub�foundrrr�test_Element_subclass_find�
s

z.ElementTreeTypeTest.test_Element_subclass_findN)r)r*r+r�r�rrrrrrrr��
s


r�c@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)Nr;r��./tagr�zsection/nexttag�nexttagrXr#rmr��togz<tag><empty /></tag>�empty)	r&r�r�r\r�r;�SAMPLE_SECTIONr�r�r�rrr�test_find_simple�
s
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�r\r�rYrg�SyntaxError)r"Z
LINEAR_XMLr�rrr�test_find_xpath�
s
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�r;rztog/foor�rmz.//tagrr�zsection//tagz	section/*)r;r
�nextsectionz
section//*)r;r
rr;zsection/.//*z*/*z*//*z*/tagz*/./tagr	z././tagz.//tag[@class]rDz.//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']rj)r&r�r�r
r\rAr�r�rrr�test_findalls�
���������������������������zElementFindTest.test_findallcCs\t�t�}|�t|�d��g�|�t|�d��dgd�|�t|�d��dgd�dS)Nr;z{http://effbot.org/ns}tagr�z.//{http://effbot.org/ns}tagrD)r&r�r�r\rAr�r�rrr�test_test_find_with_nsRs
��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�rj)rrm)r&r�r\r]r�)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)Nrrz{*}b)�{X}br��{Y}bz{*}cr�z{X}*rz{Y}*rr�r�z{}br�)rr�r�rr[r�z.//{*}b)rr�rr�rz.//{*}cz.//{X}*z.//{Y}*z.//{}*)r�r�r�r�z.//{}br)r&r�r�r&r\rAr�r�rrr�test_findall_wildcardmsd
����������������z%ElementFindTest.test_findall_wildcardcCsDt�t�}|�td��|�d�Wd�n1s60YdS)Nzcannot use absolute pathz/tag)r&r�r�rgrr�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)Nr;rXr�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//tagrD)r&r�r�r\rr�r;r�rAr��assertWarnsRegex�
FutureWarning)r"r�rlr�rrr�test_find_through_ElementTree�s
�.z-ElementFindTest.test_find_through_ElementTreeN)r)r*r+rrrrrrrr rrrrr�
sM
,rc@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�ElementIterTestNcCst|�|��SrC)rAr�)r"r4r;rrr�_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�rmzthis is a paragraph...zthis is a paragraph.z
this is a F)r5rr�r�)r�z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)r&r�r\r"r�rr�r;r�r�r9rr�r�rr�r�)r"r�Z
sourcefiler�r8rrr�
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�rjr)r&r[r\r"r%rgrrr�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>�roomrD�houser�r:)rr&r%r%Zshedr&r%r�)r&r�r\r"rAr�)r"r�Zall_tagsrrr�test_iter_by_tag�s

�z ElementIterTest.test_iter_by_tagcCsJt�d�}|��}|�t��t�|�Wd�n1s<0YdS)Nr�)r&r[r�r�rHr�)r"r�r�rrrr��s
zElementIterTest.test_copyc	Csft�d�}|��}ttjd�D]@}|�ttjf��t�	||�Wd�q 1sV0Yq dS)Nr�rj)
r&r[r�r�rIr�r�rHrLrJ)r"r�r�rSrrrr�s

zElementIterTest.test_pickle)N)	r)r*r+r"r#r$r'r�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�rXrjrZdivr#rW)r\r;rXrWrYr^r])r"r��childrenr�rrr�_check_sample1_element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�rrqrrrr�$szBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeNr_rrrr�BaseDummyBuilder#sr+c@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdSrCr)r�rrr�<lambda>(r?zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)r)r*r+r�rr�rrrr�DummyBuilder'sr-r�r�)r&r�r��sample1r\r��objectr�)r"r+r-r�rrr�test_dummy_builder"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�r\r$r;r&rXr]�r"r�rrr�test_treebuilder_comment6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_factoryr&z text zpitarget  text cSst|�|fSrC)r])r�rXrrrr,Mr?z5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>)r&r�r\r4r;r�rXr]r2rrr�test_treebuilder_piB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�TreeBuilderSubclassSsr6z<a>text<!-- comment -->tail</a>Ztexttailr�z<a>text<?pi data?>tail</a>)r&r�r�r\rXr�r�r�)r"r6r�r�r�rrr�test_late_tailQ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�rrrrr6lsr6z/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)Zinsert_commentsr�rr;z
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)Z
insert_piszpi datarWztext
)r&r�r�r�r�r\rXrW)r"r6r�r�r�rrr�test_late_tail_mix_pi_commentsis6



z.TreeBuilderTest.test_late_tail_mix_pi_commentscCs6tjtjdd�d�}|�|j�|��}|�|�dS�Nr�r�)r&r�r�r�r.r�r*�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�rrSrrrre�sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN�r)r*r+rerrrr�
MyTreeBuilder�sr>r�r�r�)	r&r�r\rer�r�r.r�r*�r"r>�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|dSr<rrSrrrre�szFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobarNr=rrrrr>�sr>)r1r4r�r�r�z<!-- a comment--><?and a pi?>)r&r�r&r�r\rer�r�r.r�r*r?rrr�test_subclass_comment_pi�s
z(TreeBuilderTest.test_subclass_comment_picsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�SrC)r�r&r[)r;rY�Zlstrr�	myfactory�s
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryr�r�Ztoplevel)r&r�r�r��sample2r�r\)r"rDr@r�rrCr�test_element_factory�sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dSr9)r&r�r�r�r.r�rZr*)r"rFr@r�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&r[rG)r"r�rrr�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_Pyr\r*r�rG)r"�baser�rrr�)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|_dSrC��_doctype�r"rPZpubid�systemrrr�doctype�sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jSrCrKrqrrrr��sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r)r*r+rLrOr�rrrr�
DoctypeParser�srPr��r�z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r&r�r�r.r\r�)r"rPr�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||_||_dSrC��raise_in�what)r"rTrUrrrr(�szKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWsdSrCr)rrrr�handle�sz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handlerS)r"rPrVrrr�__getattr__�s
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r)r*r+r�r(rWrrrr�RaisingBuilder�srXr�)rr�r�r$r4)rU)	r&r�rgr�r�r�r.r�r�)r"rXr�r�rrr�test_builder_lookup_errors�s0z*TreeBuilderTest.test_builder_lookup_errorsN)r)r*r+r.rEr*r0r3r5r7r8r;rArBrFrGrHrJrRrYrrrrr(
s"
$	
r(c@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)Nr7r�lineZ22)r\r;rXr�rrr�_check_sample_element

sz#XMLParserTest._check_sample_elementcCs0tjdt��d�}|�|j�|�|���dS)Nr
)r-r�)r&r�r�r�r.r\r�)r"Zparser2rrr�test_constructor_args
s
�z#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|�|j�|�|���dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserNr�rrrr�MyParser
sr^)r&r�r�r.r\r�)r"r^r�rrrrA
szXMLParserTest.test_subclasscCsTt���8t�dt�t��}|�|j�|��Wd�n1sF0YdS)N�error)	�warnings�catch_warnings�simplefilterr�r&r�r�rEr�rrrr�test_doctype_warning
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�dSrCr)r"rrrKrrrO)
szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN�r)r*r+rOrrKrr�MyParserWithDoctype(
srerOr_cseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dSrCrrM��	_doctype2rrrO8
szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeNrdrrfrrrP7
srPr�rQ)
r&r�r�RuntimeWarningr�rEr�r�r`rarbr�r\)r"rer�rPr)rLrgr�test_subclass_doctype&
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)r_c@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr�rrrr�MyParserWithoutDoctypeI
srjN)
r`rarbr�rhr&r�r�rEr�)r"rjr�rrr�test_inherited_doctypeD
s
z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)Nr�Zmoneyrsu
$£€𐅻)
r&r�r�r��sample3r�r\r;rYrXr:rrr�test_parse_stringO
szXMLParserTest.test_parse_stringN)
r)r*r+r.rErlr\r]rArcrirkrmrrrrrZ
srZc@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	NZhellor�)�hr�z{hello}tablerjz.//{hello}tdr�z.//{foo}name)r&r��SAMPLE_XML_NS_ELEMSr\r]r�)r"rr�rrr�test_find_with_namespaceY
s


z+NamespaceParseTest.test_find_with_namespaceN)r)r*r+rqrrrrrnX
srnc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ElementSlicingTestcCsdd�|D�S)NcSsg|]
}|j�qSrr:)r=r�rrrr>d
r?z1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)r"Zelemlistrrr�
_elem_tagsc
szElementSlicingTest._elem_tagscCs|�t|��SrC)rsr^r'rrr�
_subelem_tagsf
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&r[r�r%)r"Znumchildrenr�r�rrr�_make_elem_with_childreni
s
z+ElementSlicingTest._make_elem_with_childrencsZ|�d��|��djd�|��djd�|�t�fdd��|�t�fdd��dS)	Nr�rj�a1����a8cs�dS)N�rrrqrrr,y
r?z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Ni�rrrqrrr,z
r?)rur\r;r��
IndexErrorrqrrqr�test_getslice_single_indexs
s

z-ElementSlicingTest.test_getslice_single_indexcCs�|�d�}|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��ddg�|�|�|dd��ddg�|�|�|dd	��d
dg�dS)Nr�rD)�a3�a4�a5�r�r|r}r[r��a0rv)rur\rsr�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��rjrx�a9rD)r�r|Za6r�r�rvr|�@�rur\rsrH�maxsizer�rrr�test_getslice_steps�
s
     z&ElementSlicingTest.test_getslice_stepsc	Cs�|�d�}|�|�|ddd��gd��|�|�|ddd��ddg�|�|�|ddtj��dg�|�|�|ddtjd��dg�|�|�|ddtjd	>��dg�dS)
Nrr[)r|�a2rvr�rwr|rvrDrjr�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|r[rwr�rjrv)rur\rtr�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�rj�r�r�r�r|r�rw)r�r�r�r|r�r����)rur&r[r\rtr�rzr�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^�r=r�rrrr>�
r?z:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rjrD)r��b0�b1r|r�)r�r�r|cSsg|]}t�d|��qSr�r^r�rrrr>�
r?)r�r�r��b2r|)rur�r\rtr&r[r�rrr�test_setslice_range�
s


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�rrrr>�
r?z:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rjr�)r�r�r�r�r}r~r�cSsg|]}t�d|��qSr�r^r�rrrr>�
r?rD)r�rvr�r|r}r~rr�r�r��r�r�r�r|�
rur�r\rtr�r�r&r[rHr�r�rrr�test_setslice_steps�
s 

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�rrrr>�
r?zCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rr[)r�r�r�r|r�cSsg|]}t�d|��qSr�r^r�rrrr>�
r?rD)r�rvr�r|rjr�r�r�r�r�)r�r�r�r|r�r�rrr�test_setslice_negative_steps�
s$

4:,
z/ElementSlicingTest.test_setslice_negative_stepsN)r)r*r+rsrtrur{r�r�r�r�r�r�r�r�rrrrrrb
s
	

	
rrc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZGdd�d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �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)Nr;rz<tag>abc</tag>)r
r�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>r
s<tag>&lt;&amp;"'&gt;</tag>r�z><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>rtz"<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&r[rXr\r9r{�upperr�rY)r"r4�encr�rrrr��
s�
��$������$
�����

�����
�����

�����zIOTest.test_encodingcCsf|�tjt�t�t�d��}|�t�ttd�� }|�	|�
�d�Wd�n1sX0YdS)N�<site />r�<site />)rrrrr&rr�r1r�r\r��r"r8r�rrr�test_write_to_filename>s

zIOTest.test_write_to_filenamecCs�|�tjt�t�t�d��}ttddd��*}|j|dd�|�	|j
�Wd�n1s\0Yttd�� }|�|��d�Wd�n1s�0YdS)Nr�r�r
r�r,rr��
rrrrr&rr�r�r1rrr\r�r�rrr�test_write_to_text_fileEs*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_fileNs
*z IOTest.test_write_to_binary_filecCs0|�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�r�0<?xml version='1.0' encoding='utf-16'?>
<site />r)�	buffering)rrrrr&rr�r�r1rrr\r�r�r�rrr�"test_write_to_binary_file_with_bomWs(*
��"*
��z)IOTest.test_write_to_binary_file_with_bomcCs2t��}t�d�}|�|�|�|��jd�dS�Nz"<?xml version="1.0"?><site></site>�site)r&rr.r0r�r\r�r;�r"r8r�rrr�test_read_from_stringioks

zIOTest.test_read_from_stringiocCs:t�t�d��}t��}|j|dd�|�|��d�dS�Nr�r,r�)r&rr�r.r0r1r\r2r�rrr�test_write_to_stringioqszIOTest.test_write_to_stringiocCs2t��}t�d�}|�|�|�|��jd�dS�Ns"<?xml version="1.0"?><site></site>r�)r&rr.r/r�r\r�r;�r"r8r�rrr�test_read_from_bytesiows

zIOTest.test_read_from_bytesiocCs6t�t�d��}t��}|�|�|�|��d�dS�Nr�r�)r&rr�r.r/r1r\r2r�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�)
r.r0r�r�r&rr�r\r�r;)r"r��readerr8rrr�test_read_from_user_text_reader�s

z&IOTest.test_read_from_user_text_readercCsJt�t�d��}t��}|��}|j|_|j|dd�|�|��d�dSr�)	r&rr�r.r0r�r1r\r2)r"r8r��writerrrr�test_write_to_user_text_writer�sz%IOTest.test_write_to_user_text_writercCsJt�d�}|��}|j|_t��}|�|�|�|��j	d�t��}dSr�)
r.r/r�r�r&rr�r\r�r;)r"r�r�r8rrr�!test_read_from_user_binary_reader�s

z(IOTest.test_read_from_user_binary_readercCsFt�t�d��}t��}|��}|j|_|�|�|�|��d�dSr�)	r&rr�r.r/r�r1r\r2�r"r8r�r�rrr� test_write_to_user_binary_writer�s
z'IOTest.test_write_to_user_binary_writercCsbt�t�d��}t��}|��}|j|_dd�|_|j|_|j|dd�|�	|�
�d�d��dS)Nr�cSsdSr�rrrrrr,�r?zBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>r�r�r�)r&rr�r.r/r�r1�seekable�tellr\r2r�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>r,rmr�r?)r&r�r\r�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>r,z<tag>a<x />b<y />c</tag>T)Zshort_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)r&r�r\r�r�rrr�test_short_empty_elements�s

���z IOTest.test_short_empty_elementsN)r)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�dSrC)rZr&rrrqrrrrA�szParseErrorTest.test_subclassc
Cs>zt�|�Wn*tjy8}z|WYd}~Sd}~00dSrC)r&r�r)r"rbr�rrr�
_get_error�szParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)rjrz<tag>&foo;</tag>)rjr�zfoobar<)rjr�)r\r�Zpositionrqrrr�test_error_position�sz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errors�parsersZexpat�errorsr\r��codeZcodesZXML_ERROR_SYNTAX)r"ZERRORSrrr�test_error_code�s
�zParseErrorTest.test_error_codeN)r)r*r+rAr�r�r�rrrrr��sr�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<rY)rY)r<)rYrreZkey1Zvalue1zmust be dict, not strzI'm not a dict)r&r�r\r�r�r�r^r�r[rYrMr;r%rgrH)r"rd�elementsr�r�rrr�test_issue14818�s:
�����,zKeywordArgsTest.test_issue14818N)r)r*r+r�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)rDr�r�rqrrrr�szNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dSrC)rZrDr[r(�types�FunctionTyper�rqrrr�test_correct_import_pyETsz*NoAcceleratorTest.test_correct_import_pyETN)r)r*r+r�r�rrrrr�sr�cKstj|fi|��SrC)rD�canonicalize)r�r6rrr�c14n_roundtripsr�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>)r\r�r�rrr�test_simple_roundtripsP
�
�
�
�
�
�
�
�
�
�
�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>)r@rAr\r�r�rrr�test_c14n_exclusionDsF

���
����	��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-20rrcSs"g|]}|�d�r|dd��qS)�.xmlNr�)�endswith�r=�filenamerrrr>�s
�z+C14NTest.test_xml_c14n2.<locals>.<listcomp>cSsg|]}|�d�r|�qS)�in)�
startswithr�rrrr>�s
�cs8i|]0}|�d�r|dd�t��|�d���D��qS)Zc14ncSs,i|]$}|j�d�d|jpd��|f�qS)�}r[rm)r;�splitrXr�)r=�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�rjr[)r��rsplitr�)�configs�
input_filerrr>�s�z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<listcomp>r)r=)r��files)r�rr��s���cSsg|]}|D]}|�qqSrr)r=�output_files�output_filerrrr>�s�cSs|�||df�dS)Nrr�rN)�configZoption_namer�rrr�
get_option�sz+C14NTest.test_xml_c14n2.<locals>.get_optionZIgnoreComments�trueZ
TrimTextNodesZ
PrefixRewriteZ
sequentialZ
QNameAwarecSs(g|] }d|�d��d|�d����qS��{ZNSr��Namer�rRrrrr>�s�rjz/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrcSs(g|] }d|�d��d|�d����qSr�r�rRrrrr>�s�z){http://www.w3.org/2010/xml-c14n2}Element�,css8|]0\}\}}|�d|p*d�dd�|D����VqdS)�=r�css|]}|j�d�dVqdS)r�r[N)r;r�)r=r�rrr�	<genexpr>�r?z4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>N)r�)r=rPrsr)rrrr��s
�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�rrjr�ZinC14N3z attr="default"rm)N)rr�osr�r�r��listdirr\r]�valuesrvr�r{r{r�r�r.r/r�r�r&r�)r"ZdatadirZinput_filesZtestsr�r�r�r�r�Z
keep_commentsr�r�ZqattrsZqtagsZconfig_descrr�Zentity_filerXrhr)r�r�r�r�test_xml_c14n2�s��
�
��

������
����

������
Z�
,zC14NTest.test_xml_c14n2)r)r*r+ZmaxDiffr�r�r�rrrrr�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)%rrDr&rrrr�r�r�rgr�r�r7r�rr!r(rZr�rGr�r�r�r�r!r rdZ_namespace_mapr�r�r|r�r&r�rZrun_unittestr�rV)�moduleZtest_classesr rZ
nsmap_copyr�Z
old_factoriesrrr�	test_main�sj���




�


r��__main__)Tr,)N)Lr�rr�r.r�rprar�rIrHr@r�r�r`r�rrrrrZtest.supportrrrr	r
rDr&r�r��UnicodeEncodeErrorr�r�r�r�r
r�rpr�r�rZTestCaserr9rArBrgr�r9�format�escaperEr7rGr�r�r�r��__hash__r�r�r�rr!r(rZrnrrr�r�r�r�r�r�r�r)rrrr�<module>s�





# w	

�	7lc48W`xT
R$f
E


Kontol Shell Bypass