Your IP : 216.73.217.129


Current Path : /opt/alt/python38/lib64/python3.8/test/__pycache__/
Upload File :
Current File : //opt/alt/python38/lib64/python3.8/test/__pycache__/test_xml_etree.cpython-38.pyc

U

�M�f�Q�@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��8/opt/alt/python38/lib64/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�resultZpeZhumanrrr�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+�classmethodrFrTr^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)rZr9)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[rZ)�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 %rri)r[�keys�itemsrZ)�mappingrsrtrr�itemrorr�
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 elementri)r;rWrVrUzno %s memberzno %s visible by dir)
�
assertTruer&Z	iselement�dir�hasattr�assertInr;rWrVrU)�elementZdirelem�attrr4)�
check_elementrwrpr"rrr~�s"��





z5ElementTreeTest.test_interface.<locals>.check_elementr;�tägrq�rrz^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callableri)rxrz��methodrorr�check_method�s�z4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dSrB)�__next__)�it)r�rr�
check_itersz2ElementTreeTest.test_interface.<locals>.check_iter�*)r&rYr�getroot�assertRegex�repr�append�extend�insert�remove�getchildren�find�iterfind�findall�findtext�clearrM�setrsrt�iter�itertext�getiteratorrZ�XML�
fromstring�PI�ProcessingInstruction)r"r|r8r�r)r~rwr�rpr"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&rYrZr;�assertIsNonerVrUrW)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;rqr�z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listrhz
<subtag />�	�)r&r�rgrYr�r�r�r�r��assertRaises�
ValueErrorrZ�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>)rgr&r�rorrr�
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&rrZr�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[�_cacherZZ
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;rg)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;rr�defaultrqr��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&rYrMrZr�rWr�rV�tostring�sortedrsrt)r"r4rWrrr�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;rrrqr�zattrib aliasingriz!<tag><subtag key="value" /></tag>�<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r&rYZmakeelement�assertIsNotrWr�rgr�r��tuple)r"r4rW�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.r0r1rZr2�SIMPLE_NS_XMLFILE�open�read�	XMLParserr��version�feedrg�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>rh�body)r&r�rZr�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)rk�	namespace�rr�rr��rr�rN�rrz<root xmlns=''/>cSsg|]\}}|�qSrrr�rrrr>Xsrr�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>
)rcSsg|]\}}||f�qSrrr�rrrr>ns)r)rkuhttp://é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��nextrZr;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;rVz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>rrrqz)text<?key value?><subtag>subtext</subtag>)	r&rYrVrg�
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;rWrrrr�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"rVrrrr��s�9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r)r*r+rr�r�rrrr�Builder�sr4r�rr	r�r
r�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�dSr/r,r0rrrr��sr1cSsdSrBrr2rrrr��sr3cSs|�d||f�dS)N�pir,)r"r�r�rrrr5�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)Nrr,)r"�prefix�urirrr�start_ns�sz=ElementTreeTest.test_custom_builder.<locals>.Builder.start_nscSs|�d|f�dS�Nrr,�r"r6rrr�end_ns�sz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_nsN)
r)r*r+rr�r�r5r%r8r;rrrrr4�s)r5r5r�)r%�	 comment )rrkrrrr�rrr�rrk)	r�r�r�r\r&r�r�rZr�)r"r�r�r4�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�dSr9r,r:rrrr;�szGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_nsN)r)r*r+r;rrrrr4�sr4r�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�dedentrZ)r"r4r>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|����qSrrEr<rrrr>�s��r�rhr)r�r�r&r�rZr�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�rZr�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�rZr�r(rrr�test_tostring_default_namespaces
��z/ElementTreeTest.test_tostring_default_namespacecCs&t�d�}|�tj|ddd�d�dS)NrLr,�foobarrNzP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>rQr(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,rSrN)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�rQr(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>rQr(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,TrY)r&r��locale�getpreferredencodingrZr�)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)rc�US-ASCIIN)�E<?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag>�</tag></body>�
ISO-8859-1N)rbr,N)rcNF)rdreF)rcrfF)s<body><tag>�</tag></body>rhF)rbr,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>reT)sH<?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>rfT)rgrhTr\u'?>
<body><tag>ø</tag></body>r,Tz	encoding=z xml_declaration=rY)r&r�r^r_�subTestrZr�)r"r4r`Z	TESTCASESZexpected_retvalr-rZrrr�#test_tostring_xml_declaration_casesJs>

����z3ElementTreeTest.test_tostring_xml_declaration_casesc	CsHt�d�}|�d�tj|dd��d�|�d�tj|ddd��d�dS)	NrLrkr,r�rMrrNrP)r&r�rZr�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�rkr,r�r�r�T)rZs><?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>rYr\r]rz%^<\?xml version='1.0' encoding='.+'?>z<body�>z<tagz />z</body>rh)r&r�rZr�r�r^r_r�)r"r4r`Z
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)sNrkcs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)rZr&r�r�rV)r-r��xmlrorr�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�rrrrn�sz*ElementTreeTest.test_encoding.<locals>.xmlcs�|��|�SrB)r�r�)rnrr�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)rk)	rZr&r�r�r�r�rr��LookupError)r"rortZsupported_encodingsr-Z&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr�r"rnr�
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�rn�htmlz*<html><link><script>1 < 2</script></html>
rVz1 < 2
)r&r�rUrZr9�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�rZr9r�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>rpr�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 10rV�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r&r�rZr9rgr�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�rg�
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" />r7r;Ztag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>rqz{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&rYrg�QNamer&r�rWr�rZr�rG)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>)rZZxpath_tokenizer)r@rf�
namespaces�r r"rrroys


��z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkr�ztext()rVz()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/itemZolistrv�.z.//paraz..z../@langZlangzchapter[title]�titlez#employee[@secretary and @assistant]ZemployeeZ	secretaryrk�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)rkr�)N)r!r )r"rorr�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&>�?>)rZr&r�r�r�rorrr�test_processinginstruction�s����z*ElementTreeTest.test_processinginstructioncCspdD]f}||��fD]T}d|}tt�d|�dd�}|�||�tt�d||f�dd�}|�||�qqdS)N)
ZAREAZBASEZBASEFONTZBRZCOLZFRAMEZHRZIMGZINPUTZISINDEXZLINKZMETAZPARAMz<%s>z<%s />r�r�z	<%s></%s>)�lowerr9r&r�rZ)r"r|r4rfZ
serializedrrr�#test_html_empty_elems_serialization�s�z3ElementTreeTest.test_html_empty_elems_serializationc	CsBtjdddd�}t���}t�|�W5QRX|�|��d�dS)N�
cirriculum�public�example�ZstatusZcompanyz1<cirriculum status="public" company="example" />
)r&rYr�captured_stdout�dumprZr2)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&rYrZr9�r"r�rrr�test_tree_write_attribute_order�s
��z/ElementTreeTest.test_tree_write_attribute_orderN),r)r*r+rgr�r�r�r�r�r�r�r�r�r�r�r#r)r?rCr�DeprecationWarningrJrKrRrTrVrWr[rarjrkrmr�r�r�r�r�r�r�r�r�r�r�r�rrrrre�sTX,
5-p=�
%-;%!A:
rec@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"�Ze�ejd#kd$ej�d%��d&d'��ZdS)-�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;rV)r=�eventr4rrrr>�s�z3XMLPullParserTest.assert_events.<locals>.<listcomp>)rZr�read_events�r"r�rf�
max_eventsrrr�
assert_events�s��zXMLPullParserTest.assert_eventscCs|�tt|��|��|�dSrB)rZr\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�rZ)r"r�rfr�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|jdd�dS)N�)r�)r�rorrr�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�rrZr;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_nss&�z)XMLPullParserTest.test_simple_xml_with_nscCs�tjdd�}|�|d�|�|d�|�t|���dg�|�|d�|�|d�|�|d�|�|d	�|�|d
�|�t|���dg�|�|���dS)Nrrr�r�r
r�r�r�r�r�r)r&r�r�rZr\r�r�r�r�rrr�test_ns_events2s
�z XMLPullParserTest.test_ns_eventscCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|�|dg�dS)N)rrr�r� <tag xmlns='abc' xmlns:p='xyz'>
�r)rk�abc�r)r@Zxyzr��r��r�{abc}tagrh�
<child />
�r�
{abc}child�r�r��</tag>
�r�r��r&r�r�r�r�r�r�rrr�test_ns_events_startAs.������z&XMLPullParserTest.test_ns_events_startcCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|j|dgd	d�|�|ddg�dS)N)rrr�rrr�r�r�r�r�r�rhr�r�r�rrrrr�rrr�test_ns_events_start_endXs:��������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>
rr�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_eventsssV����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&r�r�r�r'r�r�rrr�test_events_comment�s z%XMLPullParserTest.test_events_commentcCsdtjdd�}|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)	N)rr5r�rz
<?pitarget?>
r5�pitarget)r5z<?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�rrorrr�__init__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|SrBrrorrr�__iter__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�SrB)rrrorrrr��szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r)r*r+r
rr�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�rorrr�test_unknown_event�sz$XMLPullParserTest.test_unknown_event)r��rzExpat z" does not support reparse deferralcCs�tjdd�}dD]}|�|�q|�|g�ttkrF|�|jj���|��|�|dg�ttkrv|�|jj���|�d�|�	�|�|dg�dS)Nrr)z<docrl)rr�z</doc>)r�r�)
r&r�r�r�rCrxZ_parserZGetReparseDeferralEnabledr�r�)r"r��chunkrrr�#test_flush_reparse_deferral_enabled�s
z5XMLPullParserTest.test_flush_reparse_deferral_enabled)NF)N)N)N)NF)r)r*r+r�r�r�r�r�r�r�r�r�rrrr
rrr�unittest�skipIf�pyexpat�version_inforrrrrr��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)�XIncludeTestrnNcCs@zt|}Wntk
r(td��YnX|dkr<t�|�}|S)N�resource not foundrn)�XINCLUDE�KeyError�OSErrorr&r�)r"�hrefr�r-r�rrr�xinclude_loaderMs
zXIncludeTest.xinclude_loadercCsdSrBr)r"r&r�r-rrr�none_loaderVszXIncludeTest.none_loaderc
Cs>|dkr6t|d��}t�|���W5QR�SQRXndSdS)Nrnr)r�r&r�r�)r"r&r�r�rrr�
_my_loaderYs"zXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nrrrz�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r!rr'�includer)rZr9)r"rr�rrr�test_xinclude_defaultbs

�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)Nrrra<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>rzO<document>
  <p>This document has been accessed
  324387 times.</p>
</document>rzX<document>
  <p>This document has been <em>accessed</em>
  324387 times.</p>
</document>rz�<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>rr"aI<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*rZr9r�r%r�r��r"rrr�rrr�
test_xincludeps8

�

�

�

�

�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'rz!cannot load 'count.txt' as 'text'rz1unknown parse type in xi:include tag ('BAD_TYPE')r zYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback'))
r!rr&r�r#r�ZFatalIncludeErrorr*r(rZr�r��XINCLUDE_BADr,rrr�test_xinclude_failures�s2����z#XIncludeTest.test_xinclude_failures)rnN)N)	r)r*r+r'r(r)r+r-r/rrrrr!Ks
	
	@r!c@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��	TypeErrorr9rZr�r�)r4r�rorrro�s
�z-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r4Z123)r&rYrVrUr�)r"ror4rror�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)Nr;rVr�r$)r&r�r�rrZr�)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�rZr@r��r"r8rrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28c	Cs<t�d�}t��� }t�|�|�|��d�W5QRXdS)Nr5z$<doc><table><tbody /></table></doc>
)r&r�rr�r�rZr2)r"r8r�rrr�test_bug_xmltoolkitX1s


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>rr;)r&r�rZr�rWrYr�r6rrr�test_bug_xmltoolkit39s$

�
�

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

�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�rZr�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�dSrB)r%�r"rbrrrr�7sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r)r*r+r�rrrr�
ExceptionFile6sr=)r�r%r&r�)r"r=rrr�test_bug_xmltoolkit603szBugsTest.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�rZr�rV)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;rV)r&r�rr�r�)r8rrr�xmltoolkit63Ps
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)rG�getrefcountr�rZ)r"rB�countr�rrr�test_bug_xmltoolkit63Ms
zBugsTest.test_bug_xmltoolkit63c	Cs`tjddd�}|�t�|�d�|�t�t�|���d�d�|�t�t�t�|���d�dS)NZSomeTagzdef _f():
  return 3
�rVs0<SomeTag text="def _f():&#10;  return 3&#10;" />rV)r&rYrZr�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&rYrorrrr�osz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN�r)r*r+r�rrrr�
EchoTargetnsrJr�)r&r�r�rZr�r;)r"r�rJrrr�test_bug_200708_closegs

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�)rOz%<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&rYr&rZr9r�r�r�r�)r"r��sr�rrr�!test_bug_200709_default_namespaceus&
�
�
�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&rYrZr��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&rYr�r'rZr;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&rYr&r�rZr@�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&rYr&r'r�rZr@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�rZr9)r"rar�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>rQr�rrr�test_issue6233�s
�
�zBugsTest.test_issue6233cCsTt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�dddg�dS)Nr�r;r�)r&r�rZr@r�)r"r4Znewelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)NZ	test10777z
http://myuri/)r&rNrorrr�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�changedTrFro�r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N�r)r*r+r[rrZrrr��sr�r;rY)r&rYrVr�rrXr�rZ�r"r�r�r@rrZr�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�NrYrT)rUrorZrrr[�s
z.BugsTest.test_lost_tail.<locals>.Text.__bool__Nr\rrZrrr��sr�r�r;rrY)	r&rYr�rUr�rrXr�rZr]rrZr�test_lost_tail�s
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��dSr_)r&rYr)r"r��r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N�r)r*r+rbrrarrr��sr�r�r;zgenerators are not reentrantrrY)r&rYr�r�rr��skipTestrXr;r�rZ)r"r�r@rrar�test_lost_elem�s

zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�r
)r&r�rZrM�decode)r"rVrnr�rrr�check_expat224_utf8_bugs
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)rgr2rrr�test_expat224_utf8_bugs
zBugsTest.test_expat224_utf8_bugc	Csnttd��}|��}W5QRXt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nrr�r
r�rlr���)
r��UTF8_BUG_XMLFILEr�r&r�rMrf�strip�replacerZ)r"�fp�rawr�ZxmlattrrVrrr�test_expat224_utf8_bug_file!s

z$BugsTest.test_expat224_utf8_bug_fileN)"r)r*r+r3r4r7r8r9r:r;r>rArrrG�gettracerErGrKrMrOrPrSrTrUrVrWrXr^r`rergrhrorrrrr0�s8			


r0c@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;rWrVrU�bazr�)
r&rYrXr{ryrZr;r�rVrUr�rWrG)r"r;rW�element_foorrr�
test___init__5s zBasicElementTest.test___init__cCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j|j�|�t	|�t	|��t
�||�D]\}}|�||�q�|�|j
|j
�dS�Nr�rrrsr�rtZqix)r&rYr�r�r�rZr;rVrUr[�	itertools�zip_longestZassertIsrW�r"ruZelement_foo2rHrIrrr�
test___copy__Ps
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
�dSrw)r&rYr�r�r�r�rZr;rVrUr[rxryrWrGrzrrr�test___deepcopy__hs

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}rUrV)r;Z	_childrenrWrUrV�__deepcopy__c@seZdZdd�ZdS)z9BasicElementTest.test_augmentation_type_errors.<locals>.EcSsdSrBr)r"Zmemorrrr�szFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__N)r)r*r+rrrrr�E�sr�)r&rYr�r1r�r�r�rzr~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&rYZdummyref�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&rYr�r�rZr;)r"r�r�r�rr�r�test_weakref�s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�rhr�rF)rbrc�zrb�)r�r�)r&rYrZrM)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�rh��repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrr}zother valuer$r�)r�rH�HIGHEST_PROTOCOLrrDrYrVrUr&r�r�r�rTrZr;rWr[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�rhr�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r;�groupr$rZdogs)r�rHr�rrDr�rzrZr�rTr;)r"rRrPrQZXMLTEXTr�r�rrr�test_pickle_issue18997�s

�z'BasicElementTest.test_pickle_issue18997N)r)r*r+rvr{r|r�r�r�r�r�r�rrrrrq3s#rqc@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)NrtrHro��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�rb�r&rYr�r1�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�=tjSrBrHror�rrr�	s
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__Nr�rr�rrr�
	sr�rtr�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"�orZrrrb!	s
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__NrcrrZrrr� 	sr�r�r�rt)r&rYr�r�r�r��r"r�rrZr�test_remove_with_mutating	s

z(BadElementTest.test_remove_with_mutatingc
CsDt�d�}t|d|��$|�t��t|�W5QRXW5QRXdS)Nr�r;)r&rYr
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
�jWntk
rYnXdSrB)rV�	NameErrorro�r4rr�__del__6	s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N�r)r*r+r�rr�rrr�5	sr�r;�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�r&r�rr�r�r�rZrV�r"r�r�rr�r�test_element_get_text3	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�)rUr�ror�rrr�I	sz7BadElementTest.test_element_get_tail.<locals>.X.__del__Nr�rr�rrr�H	sr�r�r;r�r�r�rr�)	r�r&r�rr�r�r�rZrUr�rr�r�test_element_get_tailF	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�NrhrrorZrr�	__index__^	s
z/BadElementTest.test_subscr.<locals>.X.__index__N�r)r*r+r�rrZrrr�]	sr�r4r�rr�)r&rYr�r�rrZr�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�rrorZrrr�l	sz3BadElementTest.test_ass_subscr.<locals>.X.__index__Nr�rrZrrr�k	sr�r4r�rr�)r&rYr�r�)r"r�r�rrZr�test_ass_subscri	s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcSsgSrBr�rbrcrrr�element_factoryx	sz>BadElementTest.test_treebuilder_start.<locals>.element_factory�r�r;r�r�)r&r�rr�r��AttributeErrorr	�r"r�r�rrr�test_treebuilder_startv	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�rrrrb�	szMutatingElementPath.__eq__N)r)r*r+r�rbrrrrr��	sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)Nrhrrr�rrrrb�	szBadElementPath.__eq__Nrcrrrrr��	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�rb)r&rYr�r�r�r�rrr�test_find_with_mutating�	s
z*BadElementPathTest.test_find_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rYr�r�r��ZeroDivisionErrorr�rrr�test_find_with_error�	s
z'BadElementPathTest.test_find_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&rYr�r�r�r�rrr�test_findtext_with_mutating�	s
z.BadElementPathTest.test_findtext_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rYr�r�r�r�r�rrr�test_findtext_with_error�	s
z+BadElementPathTest.test_findtext_with_errorcCs0t�d�}|�t�d�g�|�t|d��dSr�)r&rYr�r�r�r�rrr�test_findall_with_mutating�	s
z-BadElementPathTest.test_findall_with_mutatingcCsHt�d�}|�t�d�g�z|�td��Wntk
rBYnXdSr�)r&rYr�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)	rXr&rr�r�rrYr�r�rorrr�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&rYrXrZr;rV�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;rWZextra)r�r�rrr
�	szQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r)r*r+r
r�r�r�r�rr��	sr�r�rhr�)r�r�rF�)r�r�Zfoo__)r�rh)r�r�)r�rF)r�r�)r&rYrZr;r�rt)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:rorrr�	newmethod�	szQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r)r*r+r�rrrrr��	sr�r})r&rYrZr�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�rVr�r$rhr)r&rYrVr�rZr�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�nexttagrVr$rkr��togz<tag><empty /></tag>�empty)	r&r�r�rZr�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�rZr�rWrU�SyntaxError)r"Z
LINEAR_XMLr�rrr�test_find_xpath"
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]rFz.//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']rh)r&r�r�r�rZr@r�r�rrr�test_findall8
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}tagrF)r&r�r�rZr@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�rh)r�rk)r&r�rZr[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)Nr�rz{*}bz{X}br�z{Y}bz{*}cr�z{X}*z{Y}*r�z{}br�rQr�z.//{*}bz.//{*}cz.//{X}*z.//{Y}*z.//{}*z.//{}br�)r&r�r�r'rZr@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�rUr�r�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;rVr�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//tagrF)r&r�r�rZrr�r;r�r@r��assertWarnsRegex�
FutureWarning)r"r�rjr�rrr�test_find_through_ElementTree�
s
�z-ElementFindTest.test_find_through_ElementTreeN)r)r*r+r�r�r�r�r�r�r�r�rrrrr�

sM
,r�c@sReZdZddd�Zdd�Zdd�Zdd	�Zed
ef�dd��Z	d
d�Z
dd�ZdS)�ElementIterTestNcCst|�|��SrB)r@r�)r"r4r;rrr�_ilist�
szElementIterTest._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�rkzthis 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�rZr�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�}|�|�|�dddg�t�|d�}|�|�|�ddddg�|d|d<|d=|�|�|�ddg�dS)Nr�r�r�r�rhr)r&rYrZr�r&rRrrr�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>ZroomrFZhouser�r:rZshedr�)r&r�rZr�r@r��r"r�Zall_tagsrrr�test_iter_by_tags

��z ElementIterTest.test_iter_by_tagrDcCs�t�d�}|�t|�d��dgd�|�t|�d��dgd�|�t|jdd��dgd�dddddddg}|�t|���|�|�t|�d��|�|�t|�d	��|�dSr)r&r�rZr@r�rrrr�test_getiterator3s&

����z ElementIterTest.test_getiteratorc	Cs6t�d�}|��}|�t��t�|�W5QRXdS)Nr�)r&rYr�r�r1r�)r"r�r�rrrr�Ts
zElementIterTest.test_copyc
CsRt�d�}|��}ttjd�D],}|�ttjf��t�	||�W5QRXq dS)Nr�rh)
r&rYr�r�rHr�r�r1rKrI)r"r�r�rRrrrr�Zs

zElementIterTest.test_pickle)N)r)r*r+r�r�rrrr�rr�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�rVrhrZdivr$rU)rZr;rVrUrWr\r[)r"r��childrenr�rrr�_check_sample1_elementjsz&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�rrorrrr�yszBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeNrIrrrr�BaseDummyBuilderxsrc@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|sr
r�r�)r&r�r��sample1rZr��objectr�)r"rr
r�rrr�test_dummy_builderwsz"TreeBuilderTest.test_dummy_buildercCs�t��}|�|�d�jtj�|�|�d�jd�tjtjd�}|�|�d�jtj�|�|�d�jd�tjtd�}|�|�d�td��dS)NZctext)�comment_factory)r&r�rZr%r;r'rVr[�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�rVrrrr	�r�z5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>)r&r�rZr5r;r�rVr[rrrr�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�srz<a>text<!-- comment -->tail</a>Ztexttailr�z<a>text<?pi data?>tail</a>)r&r�r�rZrVr�r�r�)r"rrnr�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�srz/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)Zinsert_commentsr�rr<z
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)Z
insert_piszpi datarUztext
)r&r�r�r�r�rZrVrU)r"rrnr�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�rr<rrrrS�sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN�r)r*r+rSrrrr�
MyTreeBuilder�srr�r�r�)	r&r�rZrSr�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|dSrrr<rrrrS�szFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobarNrrrrrr�sr)rrr�r�r�z<!-- a comment--><?and a pi?>)r&r�r'r�rZrSr�r�rr�rrrrr�test_subclass_comment_pi�s
z(TreeBuilderTest.test_subclass_comment_picsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�SrB)r�r&rY)r;rW�Zlstrr�	myfactorys
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryr�r�Ztoplevel)r&r�r�r��sample2r�rZ)r"r!rr�rr r�test_element_factorysz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dSr)r&r�r�r�rr�rXr)r"rErr�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&rYr$)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_PyrZr*r�r$)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|_dSrB��_doctype�r"rOZpubid�systemrrr�doctype2sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jSrBr(rorrrr�5sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r)r*r+r)r,r�rrrr�
DoctypeParser/sr-r��r�z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r&r�r�rrZr�)r"r-r�rrr�test_doctype.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"r1r2rrrr
AszKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWsdSrBr)rrrr�handleHsz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handler0)r"rOr3rrr�__getattr__Es
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r)r*r+r�r
r4rrrr�RaisingBuilder@sr5r�)rr�r�r%r5)r2)	r&r�rUr�r�r�rr�r�)r"r5r�r�rrr�test_builder_lookup_errors?sz*TreeBuilderTest.test_builder_lookup_errorsN)r)r*r+rr"rr
rrrrrrrr#r$r%r'r/r6rrrrrbs"
$	
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)rZr;rVr�rrr�_check_sample_elementbsz#XMLParserTest._check_sample_elementcCs0tjdt��d�}|�|j�|�|���dS)Nr
)r-r�)r&r�r�r�rr9r�)r"Zparser2rrr�test_constructor_argsgs
�z#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|�|j�|�|���dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserNr�rrrr�MyParsernsr;)r&r�r�rr9r�)r"r;r�rrrrmszXMLParserTest.test_subclassc	Cs@t���.t�dt�t��}|�|j�|��W5QRXdS)N�error)	�warnings�catch_warnings�simplefilterr�r&r�r�r"r�r�rrr�test_doctype_warningt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}srBr,r<cseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dSrBrr*��	_doctype2rrr,�szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeNrArrCrrr-�sr-r�r.)
r&r�r��RuntimeWarningr�r"r�r�r=r>r?r�rZ)r"rBr�r-r)r)rDr�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)r<c@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr�rrrr�MyParserWithoutDoctype�srGN)
r=r>r?r�rEr&r�r�r"r�)r"rGr�rrr�test_inherited_doctype�s
z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)Nr�Zmoneyrqu
$£€𐅻)
r&r�r�r��sample3r�rZr;rWrVrrrr�test_parse_string�szXMLParserTest.test_parse_stringN)
r)r*r+rr"rIr9r:rr@rFrHrJrrrrr7Ysr7c@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	NZhellor�)�hr�z{hello}tablerhz.//{hello}tdr�z.//{foo}name)r&r��SAMPLE_XML_NS_ELEMSrZr[r�)r"r�r�rrr�test_find_with_namespace�s


z+NamespaceParseTest.test_find_with_namespaceN)r)r*r+rNrrrrrK�srKc@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)rPr\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&rYr�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�rh�a1����a8cs�dS)N�rrrZrrr	�r�z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Ni�rrrZrrr	�r�)rRrZr;r��
IndexErrorrorrZr�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)NrrF�a3�a4�a5��rQr��a0rS)rRrZrPr�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��rhrUZa9rFr^rYZa6rS�@�rRrZrPrG�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�rQrY�a2rSr^rTrFrhrarbr�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�rerYrQrTr^rhrS)rRrZrQr�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�rhr^rerYr�rTr�r]���)rRr&rYrZrQr�rWr�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%srH�r=r�rrrr>
sz:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rhrFr^�b0�b1rYr�cSsg|]}t�d|��qSrjrHrkrrrr>
sZb2)rRr�rZrQr&rYr�rrr�test_setslice_range
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|��qSrjrHrkrrrr>$
sz:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rhr]r^rlrermrZr[r�cSsg|]}t�d|��qSrjrHrkrrrr>+
srFrSrYr�r�ra�
rRr�rZrQr�r�r&rYrGrcr�rrr�test_setslice_steps"
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|��qSrjrHrkrrrr>8
szCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rrQr^rmrlrYr�cSsg|]}t�d|��qSrjrHrkrrrr>?
srFrSrerhr�r�raror�rrr�test_setslice_negative_steps6
s$

 &
z/ElementSlicingTest.test_setslice_negative_stepsN)r)r*r+rPrQrRrXr_rdrfrgrirnrprqrrrrrO�s
	

	
rOc@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;r�z<tag>abc</tag>)r
rpr�s<tag>abc</tag>)rqru�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>rpz><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>rrz"<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;" />)rqrurwrvrsu@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	r&rYrVrZr9ri�upperr�rW)r"r4�encrtrrrr�N
s�
��������
�����

�����
�����

�����zIOTest.test_encodingc	CsR|�tjt�t�t�d��}|�t�ttd��}|�	|�
�d�W5QRXdS)N�<site />r�<site />)rrrrr&rr�r1r�rZr��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)Nrvr�r
r�r,rrw�
rrrrr&rr�r�r1rrrZr�rxrrr�test_write_to_text_file�
szIOTest.test_write_to_text_filec	Cst|�tjt�t�t�d��}ttd��}|�|�|�	|j
�W5QRXttd��}|�|��d�W5QRXdS)Nrvrrrwrzrxrrr�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)	Nrvrrur�r�0<?xml version='1.0' encoding='utf-16'?>
<site />r)�	buffering)rrrrr&rr�r�r1rrrZr�r�rxrrr�"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�rZr�r;�r"r8r�rrr�test_read_from_stringio�
s

zIOTest.test_read_from_stringiocCs:t�t�d��}t��}|j|dd�|�|��d�dS�Nrvr,r�)r&rr�r.r0r1rZr2r�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�rZr�r;�r"r8rnrrr�test_read_from_bytesio�
s

zIOTest.test_read_from_bytesiocCs6t�t�d��}t��}|�|�|�|��d�dS�Nrvrw)r&rr�r.r/r1rZr2r�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�rZr�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�r1rZr2)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�rZr�r;)r"rnr�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�r1rZr2�r"r8rnr�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)NrvcSsdSr�rrrrrr	r�zBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>rur�r})r&rr�r.r/r�r1�seekable�tellrZr2r�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,rkrur�)r&r�rZr�r�r�r�rrr�test_tostringlist_invariants

�
�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�rZr�r�rrr�test_short_empty_elementss

���z IOTest.test_short_empty_elementsN)r)r*r+r�ryr{r|rr�r�r�r�r�r�r�r�r�r�r�r�rrrrrrM
s"E				rrc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|�t��t�dSrB)rXr&rr�rorrrrszParseErrorTest.test_subclassc
Cs@zt�|�Wn,tjk
r:}z|WY�Sd}~XYnXdSrB)r&r�r)r"rLr�rrr�
_get_error"szParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)rhrz<tag>&foo;</tag>)rhr]zfoobar<)rhr)rZr�Zpositionrorrr�test_error_position(sz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errorsZparsersZexpat�errorsrZr��codeZcodesZXML_ERROR_SYNTAX)r"ZERRORSrrr�test_error_code-s
�zParseErrorTest.test_error_codeN)r)r*r+rr�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�)r&�id)rW)r&)r�rrSZkey1Zvalue1zmust be dict, not strzI'm not a dict)r&r�rZr�r�r�r\r�rYrWrLr;r&rUr1)r"rb�elementsr�r�rrr�test_issue148186s:
�����zKeywordArgsTest.test_issue14818N)r)r*r+r�rrrrr�3sr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)rCr�SkipTestrorrrr�XszNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dSrB)rXrCrYr
�types�FunctionTyper�rorrr�test_correct_import_pyET]sz*NoAcceleratorTest.test_correct_import_pyETN)r)r*r+r�r�rrrrr�Wsr�cKstj|f|�SrB)rC�canonicalize)rnr6rrr�c14n_roundtripgsr�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>)rZr�r�rrr�test_simple_roundtripqsP
�
�
�
�
�
�
�
�
�
�
�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>)rArBrZr�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)�.xmlNri)�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)�}rQrk)r;�splitrVrk)r=Zoptionrrr�
<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�rhrQ)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=Zelrrrr>s�rhz/{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�rQN)r;r�)r=r�rrr�	<genexpr>'sz4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>N)r�)r=rOrqrrrrr�&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�rrXr�ZinC14N3z attr="default"rk)N)rr�osr�r�r��listdirrZr[�valuesrtr�rirdr�r�r.r/r�rlr&r�)r"ZdatadirZinput_filesZtestsr�r�r�r�r�Z
keep_commentsr�r�ZqattrsZqtagsZconfig_descrr�Zentity_filerVrfr)r�r�r�r�test_xml_c14n2�s��
�
��

������
����

������
.�
zC14NTest.test_xml_c14n2)r)r*r+ZmaxDiffr�r�r�rrrrr�ks(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&rrOrqr�r�rerrr�r!r�r�r�rr7r�r0r�r�r�r�r!r rNZ_namespace_mapr�r�rzr�r'r�r�r?rZrun_unittest)�moduleZtest_classesr r�Z
nsmap_copyr�Z
old_factoriesrrr�	test_mainPs\���



r��__main__)Tr,)N)Mr�rr�r.rxr^r_r�rHrrGrAr�rr=r�rrrrrZtest.supportrrrr	r
rCr&r�r��UnicodeEncodeErrorr�r�rjr�r�r�rMr�r�rZTestCaserr9r@rArer�r#�format�escaper.r!r0rqr�r�r��__hash__r�r�r�r�r�rr7rKrOrrr�r�r�r�r�r�r)rrrr�<module>s�





#/	

�	bF48WxT
R$f
E