Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_xml_etree.cpython-38.pyc
U

>��gV�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZddlmZmZddlmZddlmZmZmZmZmZdadaeddd�Zze�d	�Wn ek
�re
� d
��YnXeddd�Z!eddd�Z"d
Z#dZ$dZ%dZ&dZ'dZ(dd�dd�Z)Gdd�de
j*�Z+dfdd�Z,dd�Z-Gdd �d �Z.Gd!d"�d"e
j*�Z/Gd#d$�d$e
j*�Z0iZ1d%e1d&<d'e1d(<d)e1d*<d+e1d,<d-e1d.<d/e1d0<d1e1d2<d3e1d4<d5�2e�3ed��e1d6<iZ4d7e4d8<d9e4d:<Gd;d<�d<e
j*�Z5Gd=d>�d>e
j*�Z6Gd?d@�d@e.e
j*�Z7GdAdB�dBe.e
j*�Z8GdCdD�dDe9�Z:e9j;e:_;GdEdF�dFe9�Z<e9j;e<_;GdGdH�dHe.e
j*�Z=GdIdJ�dJe
j*�Z>GdKdL�dLe
j*�Z?GdMdN�dNe
j*�Z@GdOdP�dPe
j*�ZAGdQdR�dRe
j*�ZBGdSdT�dTe
j*�ZCGdUdV�dVe
j*�ZDGdWdX�dXe
j*�ZEGdYdZ�dZe
j*�ZFGd[d\�d\e
j*�ZGGd]d^�d^e
j*�ZHd_d`�ZIGdadb�dbe
j*�ZJdgdcdd�ZKeLdek�r�eK�dS)h�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)Nc	s*tj�d�i���||�W5QRXdS)Nr)rZcheck_warnings)�args�kwargs)�filtersr�test��2/opt/cppython/lib/python3.8/test/test_xml_etree.py�newtestnsz1checkwarnings.<locals>.decorator.<locals>.newtest)�	functools�update_wrapper)rr�rr)rr�	decoratormsz checkwarnings.<locals>.decoratorr)rrrrrr�
checkwarningslsrc@seZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree��ElementInclude��ElementPath)�	xml.etreerrr )�selfrrr rrr�test_sanityws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(rrrrrvsrT�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>�sz"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_list�sr@c@s(eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS�N)�pyETr&�modules)�clsrrr�
setUpClass�szElementTestCase.setUpClasscCs�tj|}z�z.|tj|<t�||�}|tj|<t�|�}Wn^tjk
r�}	z>ttdftdfg�}
t	�
d||
�||�|
�||�f�|	�W5d}	~	XYnXW5|tj|<X|S)NZcETrCz%Failed to round-trip %r from %r to %r)�sysrD�pickle�dumps�loads�
PicklingError�dictr&rCrZ
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&�ElementrC�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)r"Zalice�bob�x�yZ
propertiesrrrr_�sz#ElementTestCase.assertEqualElementsN)r)r*r+�classmethodrFrUr_rrrrrA�s
rAc@sPeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zed!ef�d"d#��Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Z d:d;�Z!d<d=�Z"d>d?�Z#d@dA�Z$dBdC�Z%dDdE�Z&dFdG�Z'dHdI�Z(dJdK�Z)dLdM�Z*dNdO�Z+dPS)Q�ElementTreeTestcCs|�t|�|�dSrB)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��|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 %rrj)r\�keys�itemsr[)�mappingrtrurs�itemrprr�
check_mapping�s

�z5ElementTreeTest.test_interface.<locals>.check_mappingcs��jt�|�dd�t|�}dD]0}�jt||�d|d��j||d|d�q �|j��|j�|jdk	rz�|j�|j	dk	r��|j	�|D]}�|�q�dS)Nznot an elementrj)r;rXrWrVzno %s memberzno %s visible by dir)
�
assertTruer&Z	iselement�dir�hasattr�assertInr;rXrWrV)�elementZdirelem�attrr4)�
check_elementrxrqr"rrr�s"��





z5ElementTreeTest.test_interface.<locals>.check_elementr;�tägrr�rsz^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callablerj)ryr{��methodrprr�check_method�s�z4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dSrB)�__next__)�it)r�rr�
check_itersz2ElementTreeTest.test_interface.<locals>.check_iter�*)r&rZr�getroot�assertRegex�repr�append�extend�insert�remove�getchildren�find�iterfind�findall�findtext�clearrM�setrtru�iter�itertext�getiteratorr[�XML�
fromstring�PI�ProcessingInstruction)r"r}r8r�r)rrxr�rqr"r�test_interface�sH	




















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&rZr[r;�assertIsNonerWrVrX)r"r}rrr�test_set_attributes*
z"ElementTreeTest.test_set_attributec	Cs�t�d�}|�|d�t�d�}|�|�|�|d�|�|�|�|d�|�d|�|�|d�|�|�|�|g�|�|d�|�|�|�t|g��|�|d�|�|�tjddd	�}|�|d
�t�d�}|�|�|�|d�|�d|�|�|d
�|�|�|�|d�|�|�|�|d
�|�	t
��}|�|�W5QRX|�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;rrr�z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listriz
<subtag />�	�)r&r�rhrZr�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>)rhr&r�rprrr�
test_cdata[s���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_inites�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_cacheps

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;rh)r"r��e1�e2�e3rrr�	test_copys


zElementTreeTest.test_copycCs"t�d�}|�d�|�|�dd�d�|�dd�|�|�d�d�tjddd�}|�|�d�d�|�|jddi�ddi}t�d|�}|��|�|�d�d�|�|jddi�ddi}tjd|�}|��|�|�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;rs�defaultrrr��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="&#10;" b="&#10;" c="&#09;&#10;&#10; " d="&#10;&#10;" />)r;)r&rZrMr[r�rXr�rW�tostring�sortedrtru)r"r4rXrrr�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;rsrrr�zattrib aliasingrjz!<tag><subtag key="value" /></tag>�<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r&rZZmakeelement�assertIsNotrXr�rhr�r��tuple)r"r4rX�subelemrrr�test_makeelement�s$


�z ElementTreeTest.test_makeelementc	Cs�t�t�}t��}|j|dd�|�|��d�t�t�}t��}|j|dd�|�|��d�t	t��}|�
�}W5QRXt��}|�|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�feedrh�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�dddg}t�|�}|�t�|�d�|�d�t�|��d�|�t�|d	�d
�t�d�\}}|�t	|�d�t�d�\}}|�t	|�d
�|�|dj
d�dS)N�<html><body>text</body></html>r,r�z<html><body>ztext</boz
dy></html>�<html><body>text</body></html>��asciisE<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>rz(<html><body id='body'>text</body></html>ri�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�dddg�|�|jjd�|t�}|�dd�|D�ddd	d
g�d}|t|�}|�dd�|D�g�d}|t|d
�}|�dd�|D�g�d}|t|�}|�dd�|D�ddddddddg�d}|t|�}|�dd�|D�dddddddd	d
dg
�d}|t�	d�|�}dd�|D�}|�|ddg�d }t
td!��2}|�t��}|||�W5QRX|�
|j�W5QRX|�t|j�d"�t�|��:|�t��}|t|�W5QRX|�t|j�d"�~W5QRXt�d#�}	d$}||	|�}|�d%d�|D�d&d'g�t�	d(�}	||	�}
t|
�\}}|�||jfd)�|�tj��}t|
�W5QRX|�t|j�d*�|�tjt�t
td+��}|�d,�W5QRX|t�}
t|
�\}}|�||jfd)�t�|��<|�tj��}t|
�W5QRX|�t|j�d*�~~
W5QRXdS)-N��endr}cSsg|]\}}||jf�qSrr:�r=�actionr4rrrr>!sz2ElementTreeTest.test_iterparse.<locals>.<listcomp>�r�r��r��rootr�cSsg|]\}}||jf�qSrr:r�rrrr>)s�r��{namespace}element�r��{namespace}empty-element�r��{namespace}rootrcSsg|]\}}||jf�qSrr:r�rrrr>2s��eventscSsg|]\}}||jf�qSrr:r�rrrr>6s��startr�cSsg|]\}}||jf�qSrr:r�rrrr>:s�rr��rr}�rr�)rr��start-ns�end-nscSs*g|]"\}}|dkr||jfn||f�qS)rr:r�rrrr>Gs��r)rl�	namespace�rr�rr�rr�r
N�rr
z<root xmlns=''/>cSsg|]\}}|�qSrrr�rrrr>Xsr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>ns)r)rluhttp://é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;rWz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>rsrrz)text<?key value?><subtag>subtext</subtag>)	r&rZrWrh�
SubElementr;r��Commentr��r"r4rrr�test_writefile�s
�zElementTreeTest.test_writefilecCs�tt��}|��}W5QRXGdd�dt�}|�}tj|d�}|�|�|�|dddddddd	g�tt��}|��}W5QRXGd
d�dt�}|�}tj|d�}|�|�|�|ddd
dddddddddg�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)�4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|�d|f�dS�Nr�r��r"r;rXrrrr�s�:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|�d|f�dS�Nr�r-�r"r;rrrr��s�8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdSrBr�r"rWrrrr��s�9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r)r*r+rr�r�rrrr�Builder�sr5r�r	r
r�rr�r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)r+cSs|�d|f�dSr,r-r.rrrr�sr/cSs|�d|f�dSr0r-r1rrrr��sr2cSsdSrBrr3rrrr��sr4cSs|�d||f�dS)N�pir-)r"r�r�rrrr6�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�Nr
r-�r"r7rrr�end_ns�sz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_nsN)
r)r*r+rr�r�r6r&r9r<rrrrr5�s)r6r6r�)r&�	 comment )rrlrrrr�rrr�r
rl)	r�r�r�r]r&r�r�r[r�)r"r�r�r5�builderr�rrr�test_custom_builder�sH

�

�z#ElementTreeTest.test_custom_buildercCsHGdd�dt�}|�}tj|d�}|�t�d��|�|dddg�dS)Nc@seZdZdd�ZdS)z@ElementTreeTest.test_custom_builder_only_end_ns.<locals>.BuildercSs|�d|f�dSr:r-r;rrrr<�szGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_nsN)r)r*r+r<rrrrr5�sr5r�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>
            )r
r�)r
�pr>)r]r&r�r��textwrap�dedentr[)r"r5r?r�rrr�test_custom_builder_only_end_ns�s	�z/ElementTreeTest.test_custom_builder_only_end_ns�@This method will be removed in future versions.  Use .+ instead.c	Cslttd��}t�|�}W5QRX|�dd�|����D�dddggggg�|�dd�|��D�dddggggg�t�t	�}|�t
|���d�|�t
|d���d	�|�|dd�|���|d
}|d}|d	d�=|�t
|���d�|�||d
�|�||d	�||g|d
d�<|�||d
�|�||d	�|�||d
�|�
�|�|��g�dS)NrcSsg|]}t|����qSr�r@r�r<rrrr>�s�z4ElementTreeTest.test_getchildren.<locals>.<listcomp>r}r�cSsg|]}t|����qSrrFr<rrrr>�s��r�rir)r�r�r&r�r[r�r�r�r�r�r\r��assertNotEqualr�)r"r�r8r4�child1�child2rrr�test_getchildren�sH

���
���

z ElementTreeTest.test_getchildrencCs<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�}|�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_namespaces
��z/ElementTreeTest.test_tostring_default_namespacecCs&t�d�}|�tj|ddd�d�dS)NrMr,�foobarrOzP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>rRr)rrr�3test_tostring_default_namespace_different_namespace's

�zCElementTreeTest.test_tostring_default_namespace_different_namespacec	Cs:t�d�}d}|�t|��tj|ddd�W5QRXdS)Nr�z>^cannot use non-qualified names with default_namespace option$r,rTrO)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�rRr)rrr� test_tostring_no_xml_declaration4s

�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>rRr)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,TrZ)r&r��locale�getpreferredencodingr[r�)r"r4�preferredencodingrrr�.test_tostring_xml_declaration_unicode_encodingBs

�z>ElementTreeTest.test_tostring_xml_declaration_unicode_encodingcCs�t�d�}t��}dddddddd	d
ddd
ddd|�d�ddfg}|D]D\}}}|�d|�d|����|�tj|||d�|�W5QRXqFdS)N�<body><tag>ø</tag></body>)�<body><tag>&#248;</tag></body>NN)�<body><tag>ø</tag></body>�UTF-8N)rd�US-ASCIIN)�E<?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag>�</tag></body>�
ISO-8859-1N)rcr,N)rdNF)rerfF)rdrgF)s<body><tag>�</tag></body>riF)rcr,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>rfT)sH<?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>rgT)rhriTr]u'?>
<body><tag>ø</tag></body>r,Tz	encoding=z xml_declaration=rZ)r&r�r_r`�subTestr[r�)r"r4raZ	TESTCASESZexpected_retvalr-r[rrr�#test_tostring_xml_declaration_casesJs>

����z3ElementTreeTest.test_tostring_xml_declaration_casesc	CsHt�d�}|�d�tj|dd��d�|�d�tj|ddd��d�dS)	NrMrlr,r�rNrrOrQ)r&r�r[r�r�r)rrr�#test_tostringlist_default_namespacews
��z3ElementTreeTest.test_tostringlist_default_namespacecCs�t�d�}|�d�tj|dd��d�|�d�tj|dd��d	�t��}tj|ddd
�}|�d�|�d|�d��|�|d
d�|�dddddg|dd��dS)Nr�rlr,r�r�r�T)r[s><?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>rZr]r^rz%^<\?xml version='1.0' encoding='.+'?>z<body�>z<tagz />z</body>ri)r&r�r[r�r�r_r`r�)r"r4raZ
stringlistrrr�!test_tostringlist_xml_declaration�s"
��
�z1ElementTreeTest.test_tostringlist_xml_declarationcCs�dr�fdd�	}|dd�|dd�|dd�|d	d
�|dd�|d
d�dd���fdd�}ddddddddddddddd d!d"d#d$d%dd&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEd
dFdGdHdIdJdKdLdMdNdOdPdQdRgC}|D] }��t�t�||���dS�q�dTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddeg}|D]}��ttj||���q:dfdgdhdidjdkdldmdndog
}|D]}��tjtj||���qr��ttj�dp��d����ttj�dq��d��dS)sNrlcs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)r[r&r�r�rW)r-r��xmlrprr�check�s
�z,ElementTreeTest.test_encoding.<locals>.checkr�r��us-ascii�
iso-8859-1�½ziso-8859-15u€�cp437u√z	mac-romanu˚cSsd|S)Nz*<?xml version='1.0' encoding='%s'?><xml />rr�rrrro�sz*ElementTreeTest.test_encoding.<locals>.xmlcs�|��|�SrB)r�r�)rorr�bxml�sz+ElementTreeTest.test_encoding.<locals>.bxmlr
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-16Zcp720Zcp737�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-latin2zmac-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)rl)	r[r&r�r�r�r�rr��LookupError)r"rpruZsupported_encodingsr-Z&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr�r"ror�
test_encoding�s�





��	�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>�
z/<html><link /><script>1 &lt; 2</script></html>
r�ro�htmlz*<html><link><script>1 < 2</script></html>
rWz1 < 2
)r&r�rVr[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_issue18347�s

��zElementTreeTest.test_issue18347c	Cs�t�d�}|�t|dd�d�|�|d�|�tj��}t�d�W5QRX|�t|j�d�|�tj��}t�t	�W5QRX|�t|j�d�t�
�}d	|jd
<|�t	�|�
�}|�|d�|�tj��}t�t�W5QRX|�t|j�d�dS)
Nz*<document title='&#x8230;'>test</document>rqr�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 10rW�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r&r�r[r9rhr�rr�r��
ENTITY_XMLr�r�r�r��EXTERNAL_ENTITY_XML)r"r�r�r�r�rrr�test_entity�s2
���

�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�rh�
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" />r8r;Ztag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>rrz{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&rZrh�QNamer'r�rXr�r[r�rH)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_publicnsz#ElementTreeTest.test_doctype_publiccs<ddlm�dD��fdd�	}|ddg�|dddg�|d	d
dg�|dd
dg�|d
ddddg�|ddddddg�|ddddg�|dddddddddddddg�|ddddg�|dddg�|ddd dd!g�|d"d"g�|d#d"ddg�|d$d$g�|d%d$dd
d&g�|d'ddd(dg�|d)d*dd
d+d,d-d,d
d.dg
�|d/d
d0g�|d1d1g�|d2d"dd3g�|d4d"dd1g�|d5d5g�|d6d6g�|d7d7g�|d8d8g�|d9d"dd7g�|d:d"dd;gd<d=i�|d>d;gd,d=i�|d?d
d;gd<d=i�|d@d
d>gd,d=i�|dAd
dBgd,d=i�|d/d
d0gd=d=dC��dS)ENrrcs"��dd���||�D�|�dS)NcSsg|]\}}|p|�qSrr)r=�opr;rrrr>zs�zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)r[Zxpath_tokenizer)rArg�
namespaces�r r"rrrpys


��z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkr�ztext()rWz()z@name�@rOz@*zpara[1]Zpara�[�1�]zpara[last()]Zlastz*/para�/z/doc/chapter[5]/section[2]�docZchapter�5�section�2z
chapter//paraz//z//paraz//olist/itemZolistrw�.z.//paraz..z../@lang�langzchapter[title]�titlez#employee[@secretary and @assistant]ZemployeeZ	secretaryrl�andZ	assistantz	@{ns}attrz{ns}attrz{http://spam}eggz
./spam.eggzspam.eggz.//{http://spam}eggz{ns}*�{}*z{*}tag�{*}*z	.//{*}tagz
./xsd:typez&{http://www.w3.org/2001/XMLSchema}typeZxsdz http://www.w3.org/2001/XMLSchema�typez	@xsd:typez@typez@{*}typez{*}type)rlr�)N)r!r )r"rprr�r�test_xpath_tokenizervs������
�
�
�
��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�rprrr�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>)�lowerr9r&r�r[)r"r}r4rgZ
serializedrrr�#test_html_empty_elems_serialization�s�z3ElementTreeTest.test_html_empty_elems_serializationc	CsBtjdddd�}t���}t�|�W5QRX|�|��d�dS)N�
cirriculum�public�example��statusZcompanyz1<cirriculum status="public" company="example" />
)r&rZr�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&rZr[r9�r"r�rrr�test_tree_write_attribute_order�s
��z/ElementTreeTest.test_tree_write_attribute_orderN),r)r*r+rhr�r�r�r�r�r�r�r�r�r�r�r$r*r@rDr�DeprecationWarningrKrLrSrUrWrXr\rbrkrlrnr�r�r�r�r�r�r�r�r�r�r�r�rrrrrf�sTX,
5-p=�
%-;%!A:
rfc@s�eZdZd+dd�Zd,dd�Zd-dd�Zd.d	d
�Zd/dd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�ZdS)0�XMLPullParserTestNFcCsP|dkr|�|�n,tdt|�|�D]}|�||||��q$|rL|��dS�Nr)r�r�r\�flush)r"r�r��
chunk_sizer�r�rrr�_feed�szXMLPullParserTest._feedcCs$|�dd�t|��|�D�|�dS)NcSs g|]\}}||j|jff�qSr)r;rW)r=�eventr4rrrr>�s�z3XMLPullParserTest.assert_events.<locals>.<listcomp>)r[r�read_events�r"r�rg�
max_eventsrrr�
assert_events�s��zXMLPullParserTest.assert_eventscCs|�tt|��|��|�dSrB)r[r]rr�r�rrr�assert_event_tuples�s�z%XMLPullParserTest.assert_event_tuplescCs(t|��|�}|�dd�|D�|�dS)NcSsg|]\}}||jf�qSrr:r�rrrr>�sz7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)rr�r[)r"r�rgr�rrrr�assert_event_tags�s�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&�
XMLPullParserr�r�r�r�)r"r�r�r�rrr�test_simple_xml�s*��z!XMLPullParserTest.test_simple_xmlcCs|jddd�dS)NriT�r�r��r�rprrr�test_simple_xml_chunk_1sz)XMLPullParserTest.test_simple_xml_chunk_1cCs|jddd�dS)N�Tr�r�rprrr�test_simple_xml_chunk_5sz)XMLPullParserTest.test_simple_xml_chunk_5cCs|jdd�dS)N�)r�r�rprrr�test_simple_xml_chunk_22sz*XMLPullParserTest.test_simple_xml_chunk_22c	Cs�t��}|��}|�|d�t|�\}}|�||jfd�|�|d�t|�\}}|�||jfd�|�t��t|�W5QRXdS)Nz-<root>
  <element key='value'>text</element>
r�r�r�)	r&r�r�r�rr[r;r��
StopIteration)r"r�r�r�r4rrr�test_feed_while_iteratings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</elementr�r�r�r�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)Nrrr�r�rr�r�r�r�r�r)r&r�r�r[r]r�r�r�r�rrr�test_ns_events8s
�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)rl�abc�r)rAZxyzr��r��r�{abc}tagri�
<child />
�r�
{abc}child�r�r�</tag>
�r�r�r&r�r�r�r�r�r�rrr�test_ns_events_startGs.������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�r
rr�r�rr�rrrirrrr	r
rrr�rrr�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�|�|d
dddg�|�|d�|�|���|�|dg�tjdd�}|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|g�|�|d�|�|d
dg�|�|d�|�|���dS)Nrrz<root/>
r�<!-- text here -->
z<root>
r	r�r
r�r�z8<element xmlns='foo'>text<empty-element/></element>tail
)r�{foo}element)r�{foo}empty-element)r�r)r�rz</root>r�)rr�)r&r�r�r�r�r�r�r�rrr�test_eventsysV����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�rz<!-- outer comment -->
z outer comment )r&)r&r�r�r�r(r�r�rrr�test_events_comment�s z%XMLPullParserTest.test_events_commentcCsdtjdd�}|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)	N)rr6r�rz
<?pitarget?>
r6�pitarget)r6z<?pitarget some text ?>
zpitarget some text )r&r�r�r�r�r�rrr�test_events_pi�s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>.DummyItercSstdddg�|_dS)Nrr�r)r�rrprrr�__init__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|SrBrrprrr�__iter__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�SrB)rrrprrrr��szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r)r*r+rrr�rrrr�	DummyIter�sr)r&r�r�r�)r"Zeventsetr�rrrr�test_events_sequence�sz&XMLPullParserTest.test_events_sequencec	Cs&|�t��tjdd�W5QRXdS)Nrr)r�r�r&r�rprrr�test_unknown_event�sz$XMLPullParserTest.test_unknown_eventcCs�tjdkr|�dtj�d��tjdd�}dD]}|�|�q.|�|g�ttkrd|�|j	j	�
��|��|�|dg�ttkr�|�|j	j	�
��|�d�|��|�|d	g�dS)
N�r��rzExpat z" does not support reparse deferralrr�z<docrm�rr��</doc>�r�r�)
�pyexpat�version_info�skipTestr&r�r�r�rCry�_parser�GetReparseDeferralEnabledr�r��r"r��chunkrrr�#test_flush_reparse_deferral_enabled�s

z5XMLPullParserTest.test_flush_reparse_deferral_enabledcCs�tjdd�}dD]}|�|�qtjdkrJttk	r<|�d�|jj�d�|�	|g�ttkrp|�
|jj���|��|�	|dg�ttkr�|�
|jj���|�d�|�
�|�	|d	g�dS)
NrrrrzDXMLParser.(Get|Set)ReparseDeferralEnabled methods not available in CFrrr )r&r�r�r!r"rCr#r$ZSetReparseDeferralEnabledr�rr%r�r�r&rrr�$test_flush_reparse_deferral_disabled�s"


z6XMLPullParserTest.test_flush_reparse_deferral_disabled)NF)N)N)N)NF)r)r*r+r�r�r�r�r�r�r�r�r�r�r�rr
rrrrrr(r)rrrrr��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.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.xmlc@s@eZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)�XIncludeTestroNcCs@zt|}Wntk
r(td��YnX|dkr<t�|�}|S)N�resource not foundro)�XINCLUDE�KeyError�OSErrorr&r�)r"�hrefr�r-r�rrr�xinclude_loaderos
zXIncludeTest.xinclude_loadercCsdSrBr)r"r7r�r-rrr�none_loaderxszXIncludeTest.none_loaderc
Cs>|dkr6t|d��}t�|���W5QR�SQRXndSdS)Nror)r�r&r�r�)r"r7r�r�rrr�
_my_loader{s"zXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nrrr/z�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r!rr8�includer:r[r9)r"rr�rrr�test_xinclude_default�s

�z"XIncludeTest.test_xinclude_defaultc	Csddlm}|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d	�}|�||j�|�t|�d
�|�d�}|�t��}|�||j�W5QRX|�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>r-z�<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>r.r3aI<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!rr8r;r[r9r�r6r�r��r"rrr�rrr�
test_xinclude�s8

�

�

�

�

�zXIncludeTest.test_xincludec	Cs0ddlm}t�td�}|�|j��}|j||jd�W5QRX|�	t
|j�d�t�td�}|�|j��}|j||jd�W5QRX|�	t
|j�d�t�td�}|�|j��}|j||jd�W5QRX|�	t
|j�d	�t�td
�}|�|j��}|j||jd�W5QRX|�	t
|j�d�dS)Nrrr*)rQz%cannot load 'disclaimer.xml' as 'xml'r+z!cannot load 'count.txt' as 'text'r0z1unknown parse type in xi:include tag ('BAD_TYPE')r1zYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback'))
r!rr&r�r4r�ZFatalIncludeErrorr;r9r[r�r��XINCLUDE_BADr=rrr�test_xinclude_failures�s2����z#XIncludeTest.test_xinclude_failures)roN)N)	r)r*r+r8r9r:r<r>r@rrrrr2ms
	
	@r2c@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!d8S)9�BugsTestcs��fdd�}t�d�}||�t�d�}d|_||�t�d�}d|_||�t�d�}|�dd�||�t�d�}|�dd�||�dS)Nc	s4��t��}t|�W5QRX��t|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorr9r[r�r�)r4r�rprrrp�s
�z-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r4Z123)r&rZrWrVr�)r"rpr4rrpr�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)Nr;rWr�r%)r&r�r�rr[r�)r"r4r8rrr�test_bug_xmltoolkit25s

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[r@r��r"r8rrr�test_bug_xmltoolkit28s
zBugsTest.test_bug_xmltoolkit28c	Cs<t�d�}t��� }t�|�|�|��d�W5QRXdS)NrFz$<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�rXrZr�rGrrr�test_bug_xmltoolkit39*s$

�
�

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

�zBugsTest.test_bug_xmltoolkit54c	Cs8|�tj��}t�d�W5QRX|�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_xmltoolkit55Ls
�zBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|�ttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�dSrB)r6�r"rcrrrr�Ysz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r)r*r+r�rrrr�
ExceptionFileXsrN)r�r6r&r�)r"rNrrr�test_bug_xmltoolkit60UszBugsTest.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�rW)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;rW)r&r�rr�r�)r8rrr�xmltoolkit63rs
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)rG�getrefcountr�r[)r"rS�countr�rrr�test_bug_xmltoolkit63os
zBugsTest.test_bug_xmltoolkit63c	Cs`tjddd�}|�t�|�d�|�t�t�|���d�d�|�t�t�t�|���d�dS)NZSomeTagzdef _f():
  return 3
�rWs0<SomeTag text="def _f():&#10;  return 3&#10;" />rW)r&rZr[r�r�rMr�rrr�test_bug_200708_newline~s���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&rZrprrrr��sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN�r)r*r+r�rrrr�
EchoTarget�sr[r�)r&r�r�r[r�r;)r"r�r[rrr�test_bug_200708_close�s

zBugsTest.test_bug_200708_closec	Cs�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�W5QRX|�t|j�d�dS)	Nz
{default}elemr�)rPz%<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&rZr'r[r9r�r�r�r�)r"r��sr�rrr�!test_bug_200709_default_namespace�s&
�
�
�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&rZr[r��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&rZr�r(r[r;r�)r"r�rrr�test_bug_200709_element_comment�s

z(BugsTest.test_bug_200709_element_commentcCsvt�d�}t�|d�}t�|d�}t�d�}|�d|�|�t|�dddg�|�d|�|�t|�ddddg�dS)Nr�r�r�r�r���)r&rZr'r�r[r@�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&rZr'r(r�r[r@r�)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�r;r�)r&r�r�rr�r�r[r9)r"rbr�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>rRr�rrr�test_issue6233�s
�
�zBugsTest.test_issue6233cCsTt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�dddg�dS)Nr�r;r�)r&r�r[r@r�)r"r4Znewelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)NZ	test10777z
http://myuri/)r&r_rprrr�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�changedTrWrp�r�rr�__bool__sz.BugsTest.test_lost_text.<locals>.Text.__bool__N�r)r*r+rlrrkrrr�sr�r;rj)r&rZrWr�rrYr�r[�r"r�r�rQrrkr�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�NrjrT)rVrprkrrrls
z.BugsTest.test_lost_tail.<locals>.Text.__bool__Nrmrrkrrr�sr�r�r;rrj)	r&rZr�rVr�rrYr�r[rnrrkr�test_lost_tails
zBugsTest.test_lost_tailcs�G��fdd�d�}t�d����t�|�����t�d����d��zt��}Wntk
rt|�d�YnX|�|j|�|��djt	�|�
�djd�dS)NcseZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcst�d��d<t��dSrp)r&rZr)r"r��r�r�rr�__eq__!sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N�r)r*r+rsrrrrrr� sr�r�r;zgenerators are not reentrantrrj)r&rZr�r�rr�r#rYr;r�r[)r"r�rQrrrr�test_lost_elems

zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�r
)r&r�r[rM�decode)r"rWror�rrr�check_expat224_utf8_bug2s
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)rwr3rrr�test_expat224_utf8_bug7s
zBugsTest.test_expat224_utf8_bugc	Csnttd��}|��}W5QRXt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nrr�r
r�rmr���)
r��UTF8_BUG_XMLFILEr�r&r�rMrv�strip�replacer[)r"�fp�rawr�ZxmlattrrWrrr�test_expat224_utf8_bug_fileCs

z$BugsTest.test_expat224_utf8_bug_fileN)"r)r*r+rDrErHrIrJrKrLrOrR�unittestZskipIfrG�gettracerVrXr\r^r`rardrerfrgrhrirorqrurwrxrrrrrrA�s8			


rAc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�BasicElementTestcCs�d}ddi}t�||�}|�|tj�|�dt|��|�dt|��|�dt|��|�dt|��|�|j|�|�|j�|�|j	�|�
|j|�|�|j|�d|d	<|�
|j|�|�|j|�dS)
Nr��zix�wypr;rXrWrV�bazr�)
r&rZrYr|rzr[r;r�rWrVr�rXrH)r"r;rX�element_foorrr�
test___init__Ws zBasicElementTest.test___init__cCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j|j�|�t	|�t	|��t
�||�D]\}}|�||�q�|�|j
|j
�dS�Nr�r�r�r�r�Zqix)r&rZr�r�r�r[r;rWrVr\�	itertools�zip_longestZassertIsrX�r"r�Zelement_foo2rIrJrrr�
test___copy__rs
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&rZr�r�r�r�r[r;rWrVr\r�r�rXrHr�rrr�test___deepcopy__�s

z"BasicElementTest.test___deepcopy__c	Cst�d�}|�t|jd�|�t|jt�d�dg�|�t|jdd�t�d�g|dd�<|�t��d|d<W5QRX|�t��t�d�dg|dd�<W5QRXt|d�r�ddgdd	d
d�}|�t|j|�t|d��rGd
d�dtj�}|d�g|dd�<|�tt	j
|�dS)N�joer�r�r�r�__setstate__r;r~rVrW)r;�	_childrenrXrVrW�__deepcopy__c@seZdZdd�ZdS)z9BasicElementTest.test_augmentation_type_errors.<locals>.EcSsdSrBr)r"�memorrrr��szFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__N)r)r*r+r�rrrr�E�sr�)r&rZr�rBr�r�r�r{r�r�r�)r"r��stater�rrr�test_augmentation_type_errors�s*
 
�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�Dummy�sr�r�)r~r�r�r�r�)	r&rZZdummyref�weakref�refr	r�r'r�)r"r�r��wrefr�r�r�r�rrr�test_cyclic_gc�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&rZr�r�r[r;)r"r�r�r�rr�r�test_weakref�s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�rir�rG)rcrd�zrc�)r�r�)r&rZr[rM)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�ri��repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrr~zother valuer$r�)r�rH�HIGHEST_PROTOCOLrrDrZrWrVr'r�r�r�rUr[r;rXr\r_)r"rRrPrQr�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�rir�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r;�groupr$rZdogs)r�rHr�rrDr�r{r[r�rUr;)r"rRrPrQZXMLTEXTr�r�rrr�test_pickle_issue18997	s

�z'BasicElementTest.test_pickle_issue18997N)r)r*r+r�r�r�r�r�r�r�r�r�rrrrr�Us#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|���Wntk
rFYnXGdd�d|tj�}|d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcst�d�g�dd�<tjS)Nr�rYrp��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�rc�r&rZr�rB�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|���Wntk
rNYnXGdd�d|tj�}|d�t�d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjSrBrYrpr�rrr�0	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"�orkrrrsC	s
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__Nrtrrkrrr�B	sr�r�r�r�)r&rZr�r�r�r��r"r�rrkr�test_remove_with_mutatingA	s

z(BadElementTest.test_remove_with_mutatingc
CsDt�d�}t|d|��$|�t��t|�W5QRXW5QRXdS)Nr�r;)r&rZr
r��RuntimeErrorr�r�rrr�test_recursive_reprN	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
�jWntk
rYnXdSrB)rW�	NameErrorrp�r4rr�__del__X	s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N�r)r*r+r�rr�rrr�W	sr�r;�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�r&r�rr�r�r�r[rW�r"r�r�rr�r�test_element_get_textU	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�djWntk
r"YnXdSr�)rVr�rpr�rrr�k	sz7BadElementTest.test_element_get_tail.<locals>.X.__del__Nr�rr�rrr�j	sr�r�r;r�r�r�rr�)	r�r&r�rr�r�r�r[rVr�rr�r�test_element_get_tailh	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�Nrirrprkrr�	__index__�	s
z/BadElementTest.test_subscr.<locals>.X.__index__N�r)r*r+r�rrkrrr�	sr�r4r�rr�)r&rZr�r�rrkr�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�rrprkrrr��	sz3BadElementTest.test_ass_subscr.<locals>.X.__index__Nr�rrkrrr��	sr�r4r�rr�)r&rZr�r�)r"r�r�rrkr�test_ass_subscr�	s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcSsgSrBr�rcrdrrr�element_factory�	sz>BadElementTest.test_treebuilder_start.<locals>.element_factory�r�r;r�r�)r&r�rr�r��AttributeErrorr	�r"r�r�rrr�test_treebuilder_start�	s
z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|�di�|�d�|�t|jd�~t�dS)NcSsgSrBrr�rrrr��	sz<BadElementTest.test_treebuilder_end.<locals>.element_factoryr�r;r�)r&r�rr�r�r�r�r	r�rrr�test_treebuilder_end�	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|f|��}||_|SrB)r��__new__r4)rEr4rr"rrrr��	szMutatingElementPath.__new__cCs|jdd�=dSr�r�r�rrrrs�	szMutatingElementPath.__eq__N)r)r*r+r�rsrrrrr��	sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)Nrirrr�rrrrs�	szBadElementPath.__eq__Nrtrrrrr��	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��	s
zBadElementPathTest.setUpcs"ddlm}|j|_t���dSr�)r!r r�r�r��tearDownr�r�rrr��	szBadElementPathTest.tearDowncCs0t�d�}|�t�d�g�|�t|d��dS�Nr�r�rc)r&rZr�r�r�r�rrr�test_find_with_mutating�	s
z*BadElementPathTest.test_find_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rZr�r�r��ZeroDivisionErrorr�rrr�test_find_with_error�	s
z'BadElementPathTest.test_find_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&rZr�r�r�r�rrr�test_findtext_with_mutating�	s
z.BadElementPathTest.test_findtext_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rZr�r�r�r�r�rrr�test_findtext_with_error�	s
z+BadElementPathTest.test_findtext_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&rZr�r�r�r�rrr�test_findall_with_mutating�	s
z-BadElementPathTest.test_findall_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rZr�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��	sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�dSrB)	rYr&rr�r�rrZr�r�rprrr�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&rZrYr[r;rW�r"r��myerrr�test_Element_subclass_trivial�	sz1ElementTreeTypeTest.test_Element_subclass_trivialcsZG�fdd�dtj���dddd�ddd	�}|�|jd
�|�t|���ddd
dg�dS)Ncs"eZdZif��fdd�	Z�ZS)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcst�|�j|d|f|�dS)N�__)r�r)r"r;rX�extra)r�r�rrr
szQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r)r*r+rr�r�r�r�rr�
sr�r�rir�)r�r�rG�)r�r�Zfoo__)r�ri)r�r�)r�rG)r�r�)r&rZr[r;r�ru)r"r�rr�r�!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|jSrBr:rprrr�	newmethod
szQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r)r*r+r�rrrrr�
sr�r�)r&rZr[r�r�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�rWr�r%rir)r&rZrWr�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�r�r�r�rrrrr��	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�nexttagrWr%rlr��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�rXrV�SyntaxError)r"Z
LINEAR_XMLr�rrr�test_find_xpathD
s
zElementFindTest.test_find_xpathcCst�t�}t�t�|d<|�t|�d��dg�|�t|�d��ddg�|�t|�d��g�|�t|�d��g�|�t|�d��dddg�|�t|�d	��dgd
�|�t|�d��dg�|�t|�d��dgd�|�t|�d
��dddg�|�t|�d��ddddg�|�t|�d��ddddg�|�t|�d��dddg�|�t|�d��ddddg�|�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)/Nr�r�r�r;r�ztog/foor�r�z.//tagr�r�zsection//tagz	section/*r�Znextsectionz
section//*zsection/.//*z*/*z*//*z*/tagz*/./tagr�z././tagz.//tag[@class]rGz.//tag[@class="a"]z.//tag[@class="b"]z.//tag[@id]z.//section[tag]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']ri)r&r�r�rr[r@r�r�rrr�test_findallZ
s�
���
�
��
���������������������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}tagrG)r&r�r�r[r@r�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�ri)rrl)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��dddg�|�t|�d��dg�|�t|�d	��dg�|�t|�d
��dg�|�t|�d��ddg�|�t|�d��dg�|�t|�d��t|�d���|�t|�d
��ddddg�|�t|�d
�|dg�t|�d���|�t|�d��dddddg�|�t|�d��ddg�|�t|�d��ddg�|�t|�d��dg�|�t|�d��ddddg�|�t|�d��ddg�|�t|�d��t|�d���dS)Nrrz{*}bz{X}br�z{Y}bz{*}cr�z{X}*z{Y}*r�z{}br�rbr�z.//{*}bz.//{*}cz.//{X}*z.//{Y}*z.//{}*z.//{}br	)r&r�r�r(r[r@r�r�rrr�test_findall_wildcard�
sd
�������
������
���z%ElementFindTest.test_findall_wildcardc	Cs0t�t�}|�td��|�d�W5QRXdS)Nzcannot use absolute pathz/tag)r&r�r�rVrr�r�rrr�
test_bad_find�
s
zElementFindTest.test_bad_findc	Cs�t�t�}|�t�|��d�jd�|�t�|��d�d�|�tt�|��	d��dgd�d}|�
t|��t�|��	d�}W5QRX|�t|�dgd�dS)Nr;rWr�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//tagrG)r&r�r�r[rr�r;r�r@r��assertWarnsRegex�
FutureWarning)r"r�rkr�rrr�test_find_through_ElementTree�
s
�z-ElementFindTest.test_find_through_ElementTreeN)r)r*r+rrrrrrr
rrrrrr�,
sM
,r�c@sReZdZddd�Zdd�Zdd�Zdd	�Zed
ef�dd��Z	d
d�Z
dd�ZdS)�ElementIterTestNcCst|�|��SrB)r@r�)r"r4r;rrr�_ilistszElementIterTest._ilistcCs6t�d�}|�|�|�dddg�|�|�|�d��ddg�|�t|���jd�|�d�|�	��d�|�d�|�d��	��d�|�t|�	��d�t
|d	d
�}|�tt�|��dd�t
|d	d
�}tjt�
�d
�}|�ttj||d��dd�t�d�}|�t|j�t�d�}|�d�|�	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>r�r�r�rlzthis 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[rr�rr�r;r�r�r9rr�r�rr�r�)r"r�Z
sourcefiler�r8rrr�
test_basics(
��

zElementIterTest.test_basiccCs�t�d�}|�|�|�dg�t�|d�}|�|�|�ddg�t�|d�}|�|�|�dddg�t�|d�}|�|�|�ddddg�|d|d<|d=|�|�|�ddg�dS)Nr�r�r�r�rir)r&rZr[rr'rcrrr�test_corners!s
zElementIterTest.test_cornerscCs�t�d�}|�|�|d�dgd�|�|�|d�dgd�|�t|jdd��dgd�dddddddg}|�t|���|�|�|�|�|�|�|�|d	�|�dS�
NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>ZroomrGZhouser�r:rZshedr�)r&r�r[rr@r��r"r�Zall_tagsrrr�test_iter_by_tag7s

��z ElementIterTest.test_iter_by_tagrEcCs�t�d�}|�t|�d��dgd�|�t|�d��dgd�|�t|jdd��dgd�dddddddg}|�t|���|�|�t|�d��|�|�t|�d	��|�dSr)r&r�r[r@r�rrrr�test_getiteratorUs&

����z ElementIterTest.test_getiteratorc	Cs6t�d�}|��}|�t��t�|�W5QRXdS)Nr�)r&rZr�r�rBr�)r"r�r�rrrr�vs
zElementIterTest.test_copyc
CsRt�d�}|��}ttjd�D],}|�ttjf��t�	||�W5QRXq dS)Nr�ri)
r&rZr�r�rHr�r�rBrKrI)r"r�r�rRrrrr�|s

zElementIterTest.test_pickle)N)r)r*r+rrrrrr�rr�r�rrrrrs
�
rc@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�rWrirZdivr%rV)r[r;rWrVrXr]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�rrprrrr��szBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeNrZrrrr�BaseDummyBuilder�src@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdSrBr)r�rrr�<lambda>�r�zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)r)r*r+r�rr�rrrr�DummyBuilder�srr�r�)r&r�r��sample1r[r��objectr�)r"rrr�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(rWr\�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_factoryrz text zpitarget  text cSst|�|fSrB)r\)r�rWrrrr�r�z5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>)r&r�r[r6r;r�rWr\r#rrr�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�sr'z<a>text<!-- comment -->tail</a>Ztexttailr�z<a>text<?pi data?>tail</a>)r&r�r�r[rWr�r�r�)r"r'ror�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�rrrrr'�sr'z/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)Zinsert_commentsr�rr=z
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)Z
insert_piszpi datarVztext
)r&r�r�r�r�r[rWrV)r"r'ror�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�rr�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�rrMrrrrTsz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN�r)r*r+rTrrrr�
MyTreeBuildersr/r�r�r�)	r&r�r[rTr�r�rr�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-rrMrrrrTszFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobarNr.rrrrr/sr/)r"r%r�r�r�z<!-- a comment--><?and a pi?>)r&r�r(r�r[rTr�r�rr�rr0rrr�test_subclass_comment_pis
z(TreeBuilderTest.test_subclass_comment_picsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�SrB)r�r&rZ)r;rX�Zlstrr�	myfactory)s
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryr�r�Ztoplevel)r&r�r�r��sample2r�r[)r"r5r1r�rr4r�test_element_factory'sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dSr*)r&r�r�r�rr�rYr)r"rEr1r�r�rrr�_check_element_factory_class5sz,TreeBuilderTest._check_element_factory_classcCs Gdd�dtj�}|�|�dS)Nc@seZdZdS)z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementNr�rrrrr�?sr�)r&rZr8)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�Lsr�)r&Z_Element_Pyr[r*r�r8)r"�baser�rrr�)test_element_factory_pure_python_subclassC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|_dSrB��_doctype�r"rOZpubid�systemrrr�doctypeTsz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jSrBr<rprrrr�Wsz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r)r*r+r=r@r�rrrr�
DoctypeParserQsrAr��r�z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r&r�r�rr[r�)r"rAr�rrr�test_doctypePs	
�zTreeBuilderTest.test_doctypec
Cs�Gdd�d�}tj|�d�dD],}|�t|��tj||�d�W5QRXq tj|td�d�dD]2}tj||td�d�}|�|j�|�|���qddS)Nc@s"eZdZdefdd�Zdd�ZdS)zBTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNcSs||_||_dSrB��raise_in�what)r"rErFrrrrcszKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWsdSrBr)rrrr�handlejsz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handlerD)r"rOrGrrr�__getattr__gs
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r)r*r+r�rrHrrrr�RaisingBuilderbsrIr�)rr�r�r&r6)rF)	r&r�rVr�r�r�rr�r�)r"rIr�r�rrr�test_builder_lookup_errorsasz*TreeBuilderTest.test_builder_lookup_errorsN)r)r*r+rr6rr!r$r&r(r)r,r2r3r7r8r9r;rCrJrrrrr�s"
$	
rc@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;rWr�rrr�_check_sample_element�sz#XMLParserTest._check_sample_elementcCs0tjdt��d�}|�|j�|�|���dS)Nr
)r-r�)r&r�r�r�rrMr�)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�srO)r&r�r�rrMr�)r"rOr�rrrr2�szXMLParserTest.test_subclassc	Cs@t���.t�dt�t��}|�|j�|��W5QRXdS)N�error)	�warnings�catch_warnings�simplefilterr�r&r�r�r6r�r�rrr�test_doctype_warning�s

z"XMLParserTest.test_doctype_warningc	s�d�G�fdd�dtj�}|�}|�td��|�|j�W5QRX|��|���d��t�	��ft�
dt�t�
dt�G�fdd�d�}||�d�}|�|j�|��|���|��d�W5QRXdS)	NcseZdZ�fdd�ZdS)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs||f�dSrBr)r"rrr<rrr@�szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN�r)r*r+r@rr<rr�MyParserWithDoctype�srVr@rPcseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dSrBrr>��	_doctype2rrr@�szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeNrUrrWrrrA�srAr�rB)
r&r�r�RuntimeWarningr�r6r�r�rQrRrSr�r[)r"rVr�rAr)r=rXr�test_subclass_doctype�s&


�z#XMLParserTest.test_subclass_doctypec	Cs\t���Jt�dt�t�dt�Gdd�dtj�}|�}|�|j�|�	�W5QRXdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)rPc@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr�rrrr�MyParserWithoutDoctype�sr[N)
rQrRrSr�rYr&r�r�r6r�)r"r[r�rrr�test_inherited_doctype�s
z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)Nr�Zmoneyrru
$£€𐅻)
r&r�r�r��sample3r�r[r;rXrWr+rrr�test_parse_string�szXMLParserTest.test_parse_stringN)
r)r*r+rr6r]rMrNr2rTrZr\r^rrrrrK{srKc@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	NZhellor�)�hr�z{hello}tableriz.//{hello}tdr�z.//{foo}name)r&r��SAMPLE_XML_NS_ELEMSr[r\r�)r"r
r�rrr�test_find_with_namespace�s


z+NamespaceParseTest.test_find_with_namespaceN)r)r*r+rbrrrrr_�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�qSrr:)r=r�rrrr>�sz1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)r"Zelemlistrrr�
_elem_tags�szElementSlicingTest._elem_tagscCs|�t|��SrB)rdr]r)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&rZr�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�ri�a1����a8cs�dS)N�rrrkrrr�r�z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Ni�rrrkrrr�r�)rfr[r;r��
IndexErrorrprrkr�test_getslice_single_index�s

z-ElementSlicingTest.test_getslice_single_indexcCs�|�d�}|�|�|dd��dddg�|�|�|dd��dddg�|�|�|dd��dddg�|�|�|dd��ddg�|�|�|dd��ddg�|�|�|dd	��d
dg�dS)NrrG�a3�a4�a5�r�rbr��a0rg)rfr[rdr�rrr�test_getslice_range�s
   z&ElementSlicingTest.test_getslice_rangec	Cs�|�d�}|�|�|ddd��ddg�|�|�|ddd��ddd	dg�|�|�|ddd��ddg�|�|�|ddd��d
dg�|�|�|ddtj��dg�|�|�|ddtjd>��dg�dS)Nr��ririZa9rGrqrmZa6rg�@�rfr[rdrG�maxsizer�rrr�test_getslice_steps�s
 $   z&ElementSlicingTest.test_getslice_stepsc	Cs�|�d�}|�|�|ddd��ddddg�|�|�|ddd��ddg�|�|�|ddtj��dg�|�|�|ddtjd	��dg�|�|�|ddtjd
>��dg�dS)Nr�rbrm�a2rgrqrhrGrirtrur�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)Nr�rr�rxrmrbrhrqrirg)rfr[rer�rrr�
test_delslice
s$







z ElementSlicingTest.test_delslicec	Cs�|�d�}t�d�|d<|�|�|�ddddg�t�d�|d<|�|�|�ddddg�|�t��t�d	�|d
<W5QRX|�t��t�d	�|d<W5QRX|�|�|�ddddg�dS)Nr�r�rirqrxrmr�rhr�r����)rfr&rZr[rer�rkr�rrr�test_setslice_single_index)
s
z-ElementSlicingTest.test_setslice_single_indexcCs�|�d�}dd�td�D�|dd�<|�|�|�ddd	d
g�|�d�}t�d�g|dd�<|�|�|�ddd
g�|�d�}dd�td�D�|dd�<|�|�|�ddd	d
d
g�dS)Nr�cSsg|]}t�d|��qS�zb%srY�r=r�rrrr>9
sz:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rirGrq�b0�b1rmr�cSsg|]}t�d|��qSr}rYr~rrrr>A
sZb2)rfr�r[rer&rZr�rrr�test_setslice_range7
s


z&ElementSlicingTest.test_setslice_rangec	Csd|�d�}dd�td�D�|ddd�<|�|�|�ddd	d
ddg�|�d�}|�t��t�d
�g|ddd�<W5QRX|�t��"dd�td�D�|ddd�<W5QRX|�t��g|ddd�<W5QRX|�|�|�ddd	dddg�|�d�}t�d
�g|ddtj	�<|�|�|�dd
d	dg�t�d�g|ddtj	d>�<|�|�|�ddd	dg�dS)NrcSsg|]}t�d|��qSr}rYr~rrrr>F
sz:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rir�rqrrxr�rnror�cSsg|]}t�d|��qSr}rYr~rrrr>M
srGrgrmr�r�rt�
rfr�r[rer�r�r&rZrGrvr�rrr�test_setslice_stepsD
s 

 &
z&ElementSlicingTest.test_setslice_stepsc	Cs�|�d�}dd�td�D�|ddd�<|�|�|�ddd	d
g�|�d�}|�t��t�d�g|ddd�<W5QRX|�t��"dd�td
�D�|ddd�<W5QRX|�t��g|ddd�<W5QRX|�|�|�dddd
g�|�d�}t�d�g|ddtj	�<|�|�|�dddd
g�t�d�g|ddtj	d�<|�|�|�dddd
g�t�d�g|ddtj	d>�<|�|�|�dddd
g�dS)Nr�cSsg|]}t�d|��qSr}rYr~rrrr>Z
szCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rrbrqr�rrmr�cSsg|]}t�d|��qSr}rYr~rrrr>a
srGrgrxrir�r�rtr�r�rrr�test_setslice_negative_stepsX
s$

 &
z/ElementSlicingTest.test_setslice_negative_stepsN)r)r*r+rdrerfrlrrrwryrzr|r�r�r�rrrrrc�s
	

	
rcc@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]F}|�|��2|�t||d�d�|�t||��d�d�W5QRXq$dD]^}|�|��J|�t||d�d|�|��|��}|�t||d�d|�|��W5QRXqpt�d�}d	|_|�t|�d
�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���qt�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|�|���qt�d�}d|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�dD]$}|�t||d�d|�|���qzdS)Nr;rz<tag>abc</tag>)r
rqr�s<tag>abc</tag>)rrrv�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>rqz><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>rsz"<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;" />)rrrvrxrwr�u@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	r&rZrWr[r9rj�upperr�rX)r"r4�encr�rrrr�p
s�
��������
�����

�����
�����

�����zIOTest.test_encodingc	CsR|�tjt�t�t�d��}|�t�ttd��}|�	|�
�d�W5QRXdS)N�<site />r�<site />)rrr rr&rr�r1r�r[r��r"r8r�rrr�test_write_to_filename�
s

zIOTest.test_write_to_filenamec	Cs||�tjt�t�t�d��}ttddd�� }|j|dd�|�	|j
�W5QRXttd��}|�|��d�W5QRXdS)Nr�r�r
r�r,rr��
rrr rr&rr�r�r1rrr[r�r�rrr�test_write_to_text_file�
szIOTest.test_write_to_text_filec	Cst|�tjt�t�t�d��}ttd��}|�|�|�	|j
�W5QRXttd��}|�|��d�W5QRXdS)Nr�rrr�r�r�rrr�test_write_to_binary_file�
s
z IOTest.test_write_to_binary_filec	Cs�|�tjt�t�t�d��}ttd�� }|j|dd�|�	|j
�W5QRXttd��}|�|��d�
d��W5QRXttddd�� }|j|dd�|�	|j
�W5QRXttd��}|�|��d�
d��W5QRXdS)	Nr�rrvr�r�0<?xml version='1.0' encoding='utf-16'?>
<site />r)�	buffering)rrr rr&rr�r�r1rrr[r�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&rr.r0r�r[r�r;�r"r8r�rrr�test_read_from_stringio�
s

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_stringio�
szIOTest.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_bytesio�
s

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_writers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_writers
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>rvr�r�)r&rr�r.r/r�r1�seekable�tellr[r2r�r�rrr�)test_write_to_user_binary_writer_with_boms

��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,rlrvr�)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_elements3s

���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�o
s"E				r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|�t��t�dSrB)rYr&rrrprrrr2AszParseErrorTest.test_subclassc
Cs@zt�|�Wn,tjk
r:}z|WY�Sd}~XYnXdSrB)r&r�r)r"r]r�rrr�
_get_errorDszParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)rirz<tag>&foo;</tag>)rir�zfoobar<)rir)r[r�Zpositionrprrr�test_error_positionJsz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errors�parsersZexpat�errorsr[r��codeZcodesZXML_ERROR_SYNTAX)r"ZERRORSrrr�test_error_codeOs
�zParseErrorTest.test_error_codeN)r)r*r+r2r�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�W5QRX|�
td��tjddd�W5QRXdS)Nz
<a>foo</a>r�)�pathr�)r�r�r��#r�)r7�id)rX)r7)r�rrTZkey1Zvalue1zmust be dict, not strzI'm not a dict)r&r�r[r�r�r�r]r�rZrXrLr;r'rVrB)r"rc�elementsr�r�rrr�test_issue14818Xs:
�����zKeywordArgsTest.test_issue14818N)r)r*r+r�rrrrr�Usr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)rCr��SkipTestrprrrr�zszNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dSrB)rYrCrZr�types�FunctionTyper�rprrr�test_correct_import_pyETsz*NoAcceleratorTest.test_correct_import_pyETN)r)r*r+r�r�rrrrr�ysr�cKstj|f|�SrB)rC�canonicalize)ror6rrr�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>)r[r�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>)rBrCr[r�r�rrr�test_c14n_exclusion�sF

���
����	��zC14NTest.test_c14n_exclusionc
s�tddd�}ttjj|��dd�tt�|��D��dd��D�}�fdd��D����fd	d�|D�}|�d
tdd�|�	�D���d/dd
�}|�
�D�]\}}|D�]�\}}||d�dk}	||d�dk}
||d�dk}d|k�rdd�|dd�d�D�}dd�|dd�d�D�}
nd}
}d�dd�t|�
��D��}|�|�d|�d����F|dk�rz|�sz|�
d|���|d k�r�|�s�|�
d|���d|k�r�|dd�d!�dk	�r�|�
d"|����|d#�}|d$k�r,t�d%�d&��6}t|d&�� }t�|���d'|����}W5QRXW5QRXtj||	|
||
|d(�}t�|d#�d)d*d+��0}|��}|d,k�r�|�d-d.�}|�d-d.�}W5QRX|�||�W5QRXq�q�dS)0Nzc14n-20rrcSs"g|]}|�d�r|dd��qS)�.xmlNry)�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)�}rbrl)r;�splitrWr{)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�kr|�|�dd�df�qS)Zout_r�rirb)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�rM)�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��r=�elrrrr>:s�riz/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrcSs(g|] }d|�d��d|�d����qSr�r�r�rrrr>?s�z){http://www.w3.org/2010/xml-c14n2}Element�,css8|]0\}\}}|�d|p*d�dd�|D����VqdS)�=r�css|]}|j�d�dVqdS)r�rbN)r;r�)r=r�rrr�	<genexpr>Isz4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>N)r�)r=rOrrrrrrr�Hs
�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�rrYr�ZinC14N3z attr="default"rl)N)rr�osr�r�r��listdirr[r\�valuesrur�rjr#r�r�r.r/r�r|r&r�)r"ZdatadirZinput_filesZtestsr�r�r�r�r�Z
keep_commentsr�r�ZqattrsZqtagsZconfig_descrr�Zentity_filerWrgr)r�r�r�r�test_xml_c14n2s��
�
��

������
����

������
.�
zC14NTest.test_xml_c14n2)r)r*r+ZmaxDiffr�r�r�rrrrr��s(Pr�cCs�tddgd�a|dkrt}|attttttt	t
ttt
tttttttg}ttk	rZ|�tg�ddlm}tjj}|��}|j}|��|_ttd�r�t�tjtj �}nd}zt#j$|�W5ddlm}|�!�|�"|�||_|dk	r�tj|�daaXdS)Nr$r%)Zblockedrr�_set_factories)%rrCr&rrcr�r�r�rfr�r�r2r�r�rrrKr�rAr�r�r�r�r!r r_Z_namespace_mapr�r�r{r�r(r�r�rPrZrun_unittest)�moduleZtest_classesr r
Z
nsmap_copyr�Z
old_factoriesrrr�	test_mainrs\���



r��__main__)Tr,)N)Mr�rr�r.r�r_r`r�rHr!rGrBr�r�rQr�rrrrrZtest.supportrrrr	r
rCr&r�r��UnicodeEncodeErrorr�r�rzr�rr�rar�r�rZTestCaserr9r@rArfr�r4�format�escaper?r2rAr�r�r�r��__hash__r�r�r�r�rrrKr_rcr�r�r�r�r�r�r�r)rrrr�<module>s�





#/4	

�	bF48WxT
R$f
E


F1le Man4ger