Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_xml_etree.cpython-310.pyc
o

�9j�z�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlmZmZddlmZddlmZddlmZddlmZmZmZmZddlmZdd	lmZdadaed
dd�Z ze �!d
�Wne"y�e�#d��weddd�Z$eddd�Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dd�dd�Z-dd�Z.Gdd�dej/�Z0dud"d#�Z1d$d%�Z2Gd&d'�d'�Z3Gd(d)�d)ej/�Z4Gd*d+�d+ej/�Z5iZ6d,e6d-<d.e6d/<d0e6d1<d2e6d3<d4e6d5<d6e6d7<d8e6d9<d:e6d;<d<�7e�8e d ��e6d=<d>e6d?<iZ9d@e9dA<dBe9dC<dDe6dE<dFe6dG<dHe6dI<GdJdK�dKej/�Z:GdLdM�dMej/�Z;GdNdO�dOe3ej/�Z<GdPdQ�dQe3ej/�Z=GdRdS�dSe>�Z?e>j@e?_@GdTdU�dUe>�ZAe>j@eA_@GdVdW�dWe3ej/�ZBGdXdY�dYej/�ZCGdZd[�d[ej/�ZDGd\d]�d]ej/�ZEGd^d_�d_ej/�ZFGd`da�daej/�ZGGdbdc�dcej/�ZHGddde�deej/�ZIGdfdg�dgej/�ZJGdhdi�diej/�ZKGdjdk�dkej/�ZLGdldm�dmej/�ZMdndo�ZNGdpdq�dqej/�ZOdvdrds�ZPeQdtk�r�eP�dSdS)w�N)�partial)�product�islice)�support)�	os_helper)�warnings_helper)�findfile�
gc_collect�	swap_attr�	swap_item)�import_fresh_module)�TESTFNz
simple.xml�xmltestdata��subdir�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>
z�<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Foo [
<!ELEMENT foo (bar*)>
<!ELEMENT bar (#PCDATA)*>
<!ATTLIST bar xml:lang CDATA "eng">
<!ENTITY qux "quux">
]>
<foo>
<bar>&qux;</bar>
</foo>
F)�quietcs��fdd�}|S)Ncs ���fdd�}t�|��|S)NcsDtj�d�i���|i|��Wd�dS1swYdS)Nr)r�check_warnings)�args�kwargs)�filtersr�test��*/usr/lib/python3.10/test/test_xml_etree.py�newtest}s"�z1checkwarnings.<locals>.decorator.<locals>.newtest)�	functools�update_wrapper)rr�rr)rr�	decorator|sz checkwarnings.<locals>.decoratorr)rrrrrr�
checkwarnings{srcCs|�dtj���S)N�
)�replace�os�linesep�encode)�datarrr�convlinesep��r&c@�eZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree��ElementInclude��ElementPath)�	xml.etreer*r,r.)�selfr*r,r.rrr�test_sanity�szModuleTest.test_sanitycCsd}tj|t|dd�dS)N)�xml.etree.ElementTree�_elementtree)�
HTML_EMPTY)�not_exported)r�check__all__�ET)r0�namesrrr�test_all�szModuleTest.test_allN)�__name__�
__module__�__qualname__r1r9rrrrr)�sr)T�unicodecKsT|dkr	t��}nt��}t�|�}|j|fd|i|��|r#|��S|�d�|S)Nr=�encodingr)�io�BytesIO�StringIOr7r*�write�getvalue�seek)�elem�	to_stringr>�options�file�treerrr�	serialize�s


rJcCsdd�|D�S)NcS�g|]}|j�qSr��tag��.0rErrr�
<listcomp>��z"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_list��rSc@s(eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS�N)�pyETr7�modules)�clsrrr�
setUpClass��zElementTestCase.setUpClassc
Cs�z>ttj||��t�||�}Wd�n1swYttj||��t�|�}Wd�W|S1s7wYW|Stjyh}zttdft	dfg�}	t
�d||	�||�|	�||�f�|�d}~ww)N�cETrWz%Failed to round-trip %r from %r to %r)
r�sysrX�pickle�dumps�loads�
PicklingError�dictr7rWr�
TestFailed�get)
r0�obj�name�dumper�loader�proto�temp�result�pe�humanrrr�pickleRoundTrip�s,��	�	�

�����zElementTestCase.pickleRoundTripcCs�|�|tjtjf�|�|tjtjf�|�tt|��tt|���t||�D]
\}}|�||�q't	�
dddd�}|�||�||��dS)NrM�tail�text�attrib)�assertIsInstancer7�ElementrW�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)r0�alice�bob�x�y�
propertiesrrrrx�sz#ElementTestCase.assertEqualElementsN)r:r;r<�classmethodrZrnrxrrrrrU�s

rUc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@�Z"dAdB�Z#dCdD�Z$dEdF�Z%dGdH�Z&dIdJ�Z'dKdL�Z(dMdN�Z)dOdP�Z*dQdR�Z+dSdT�Z,dUdV�Z-dWdX�Z.dYdZ�Z/d[S)\�ElementTreeTestcCs|�t|�|�dSrV)rtrJ)r0rE�expectedrrr�serialize_check��zElementTreeTest.serialize_checkcsv��fdd��t�d�}�|�t�|�}�|���tjddd�}t�|�}��t|�d�tjddd�}�fdd	���|j��|j��|j��|j	��|j
��|j��|j��|j
��|j��|j��|j��|j��|j��|j��|j��fd
d�}||�d��||�d��||�d��||�d����tjtj���tjtj�dS)
Ncs��jt�|�dd�t|�}dD]}�jt||�d|d��j||d|d�q��|jt���|j	t
�|jdurC��|jt�|jdurO��|jt�|D]}�|�qQdS)Nznot an element��msg)rMrqrprozno %s memberzno %s visible by dir)
�
assertTruer7�	iselement�dir�hasattr�assertInrrrM�strrqrbrpro)�element�direlem�attrrE)�
check_elementr0rrr��s$��


�z5ElementTreeTest.test_interface.<locals>.check_elementrM�täg�value��keyz^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callabler�)r�r���method�r0rr�check_method�s
�z4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dSrV)�__next__)�it)r�rr�
check_iterrTz2ElementTreeTest.test_interface.<locals>.check_iter�*)r7rsr*�getroot�assertRegex�repr�append�extend�insert�remove�find�iterfind�findall�findtext�clearrd�set�keys�items�iter�itertextrt�XML�
fromstring�PI�ProcessingInstruction)r0r�rIr�r)r�r�r0r�test_interface�s@

















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)NrM�Tag�TAG�Text�TEXT�Tail�TAIL�b�d)�a�c�B�D)�A�C)r7rsrtrM�assertIsNonerprorq)r0r�rrr�test_set_attributes*
z"ElementTreeTest.test_set_attributecCst�d�}|�|d�t�d�}|�|�|�|d�|�|�|�|d�|�d|�|�|d�|�|�|�|g�|�|d�|�|�|�t|g��|�|d�|�|�tjddd	�}|�|d
�t�d�}|�|�|�|d�|�d|�|�|d
�|�|�|�|d�|�|�|�|d
�|�	t
��
}|�|�Wd�n1s�wY|�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>rMr�r�z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in list�z
<subtag />�	�)r7r�r�rsr�r�r�r�r��assertRaises�
ValueErrorrtr��	exception)r0rE�er��
subelement�cmrrr�test_simpleops)sT








�

� "
�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>)r�r7r�r�rrr�
test_cdataUs���zElementTreeTest.test_cdatacCs|t�t�d��}tj|d�}|�|�d�jd�|�|�d�jd�tjt	d�}|�|�d�jd�|�|�d�jd�dS)Nr)rHrM�section/tagr�zelement/../empty-element�
empty-element)
r?r@�
SAMPLE_XMLr$r7r*rtr�rM�SIMPLE_XMLFILE)r0�
stringfilerIrrr�test_file_init_s�zElementTreeTest.test_file_initcCs�ddlm}t�t�}td�D]}t�|��dt|��qt	|j
�}td�D]}t�|��dt|��q'|�t	|j
�|�td�D]}t�|��dt|��qC|�t	|j
�|�td�D]}t�|��dt|��q_|�
t	|j
�d�dS)Nrr-�
z./�iXi�)r/r.r7r�r��ranger*r�r�ru�_cachert�
assertGreater�
assertLess)r0r.rE�i�cache_len_10rrr�test_path_cachejs
&
&&&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>)�copyr7r��deepcopyr�rMr�)r0r��e1�e2�e3rrr�	test_copyys


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

 r�z



		  s[<test a="&#13;" b="&#13;&#10;" c="&#09;&#10;&#13; " d="&#10;&#10;&#13;&#13;&#09;&#09;  " />rL)r7rsrdrtr�rqr�rp�tostring�sortedr�r�)r0rErqrrr�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)
NrMr�r�r�zattrib aliasingr�z!<tag><subtag key="value" /></tag>�<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r7rs�makeelement�assertIsNotrqr�r�r�r��tuple)r0rErq�subelemrrr�test_makeelement�s$


�z ElementTreeTest.test_makeelementcCs�t�t�}t��}|j|dd�|�|��d�t�t�}t��}|j|dd�|�|��d�t	t��}|�
�}Wd�n1sCwYt��}|�|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)r7�parser�r?rArBrtrC�SIMPLE_NS_XMLFILE�open�read�	XMLParserr��version�feedr��close�TreeBuilder)r0rI�stream�fr%�parserrrrr�test_parsefile�s6

�

�

�

�

�zElementTreeTest.test_parsefilecCs�t�d�}|�tj|dd�d�t�d�}|�tj|dd�d�gd�}t�|�}|�t�|�d�|�d�t�|��d�|�t�|d�d�t�d�\}}|�t	|�d	�t�d
�\}}|�t	|�d�|�|dj
d�dS)
N�<html><body>text</body></html>r=r�)z<html><body>ztext</boz
dy></html>�<html><body>text</body></html>��asciisE<?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>rz(<html><body id='body'>text</body></html>r��body)r7r�rtr�r��fromstringlist�join�tostringlist�XMLIDrurM)r0r��sequence�_�idsrrr�test_parseliteral�s0
�
�
���z!ElementTreeTest.test_parseliteralc	Cs4tj}|t�}t|�\}}|�||jfd�|�dd�|D�gd��|�|jjd�|t�}|�dd�|D�gd��d}|t|�}|�d	d�|D�g�d}|t|d
�}|�dd�|D�g�d}|t|�}|�d
d�|D�gd��d}|t|�}|�dd�|D�gd��d}|t�	d�|�}dd�|D�}|�|ddg�d}t
td��(}|�t��
}|||�Wd�n1s�wY|�
|j�Wd�n1s�wY|�t|j�d�t�|��,|�t��
}|t|�Wd�n1s�wY|�t|j�d�~Wd�n	1�swYt�d�}	d}||	|�}|�dd�|D�ddg�t�	d�}	||	�}
t|
�\}}|�||jfd �|�tj��}t|
�Wd�n	1�scwY|�t|j�d!�|�tjt�t
td"��
}|�d#�Wd�n	1�s�wY|t�}
t|
�\}}|�||jfd �t�|��.|�tj��}t|
�Wd�n	1�s�wY|�t|j�d!�~~
Wd�n	1�s�wYt�|��
|t�}
~
Wd�n	1�s�wY|�t��
|d$�Wd�dS1�swYdS)%N��endr�cS�g|]	\}}||jf�qSrrL�rO�actionrErrrrP�z2ElementTreeTest.test_iterparse.<locals>.<listcomp>)r�rr��r�rootr#cSrrrLrrrrrP$r )�r�{namespace}elementr$�r�{namespace}empty-element�r�{namespace}rootrcSrrrLrrrrrP-r ��eventscSrrrLrrrrrP1r ��startrcSrrrLrrrrrP5r ��r-r#�r-r�rr0r)r-r�r!r")r-r�start-ns�end-nscSs*g|]\}}|dvr||jfn||f�qS)r,rLrrrrrPBs
��)
�r1)��	namespace�r-r)�r-r%r$r7r$�r-r'r&r(�r2N�r1r2z<root xmlns=''/>cSsg|]\}}|�qSrrrrrrrPSsr1r2�r-r�bogus�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>
)r1cSsg|]\}}||f�qSrrrrrrrPis)r1)r4uhttp://éffbot.org/ns)r1)uclé�http://effbot.org/nsz<document />junk)r�documentz.junk after document element: line 1, column 12�wbs<document />junk�nonexistent)r7�	iterparser��nextrtrMr#rr?rArr�r��assertFalse�closedr�r�r�check_no_resource_warningr@�
ParseError�
addCleanupr�unlinkr
rB�FileNotFoundError)r0rB�contextrrEr+�resrr��sourcer�rrr�test_iterparses�



�������
�

���
����
$�zElementTreeTest.test_iterparsecCs�t�d�}d|_|�|d�dt�|d�_|�|d�d|_|�|d�|�dt�d	��|�|d
�t�dd�|d<|�|d
�dS)NrMrpz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>r�r�z)text<?key value?><subtag>subtext</subtag>)	r7rsrpr��
SubElementrMr��Commentr��r0rErrr�test_writefile�s
�zElementTreeTest.test_writefilecCs�tt��}|��}Wd�n1swYGdd�dt�}|�}tj|d�}|�|�|�|gd��tt��}|��}Wd�n1sIwYGdd�dt�}|�}tj|d�}|�|�|�|gd��dS)Nc@�$eZdZdd�Zdd�Zdd�ZdS)�4ElementTreeTest.test_custom_builder.<locals>.BuildercS�|�d|f�dS�Nr-�r��r0rMrqrrrr-�r'�:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSrW�NrrY�r0rMrrrr�r'�8ElementTreeTest.test_custom_builder.<locals>.Builder.endcS�dSrVr�r0rprrrr%���9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r:r;r<r-rr%rrrr�Builder��rcr�r.c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)rVcSrWrXrYrZrrrr-�r'r[cSrWr\rYr]rrrr�r'r^cSr_rVrr`rrrr%�rarbcS�|�d||f�dS)N�pirY)r0rr%rrrrf�r�z7ElementTreeTest.test_custom_builder.<locals>.Builder.picSrW)NrPrY)r0r%rrrrP�r'z<ElementTreeTest.test_custom_builder.<locals>.Builder.commentcSre)Nr1rY)r0�prefix�urirrr�start_ns�r�z=ElementTreeTest.test_custom_builder.<locals>.Builder.start_nscSrW�Nr2rY�r0rgrrr�end_ns�r'z;ElementTreeTest.test_custom_builder.<locals>.Builder.end_nsN)
r:r;r<r-rr%rfrPrirlrrrrrc�s))rfrfr%)rP�	 comment )r1r4r5r6r7r$r7r$r8r&r(�r2r4)	rr�rrvr7rrrtr)r0rr%rc�builderrrrr�test_custom_builder�s 

�


�
z#ElementTreeTest.test_custom_buildercCsFGdd�dt�}|�}tj|d�}|�t�d��|�|gd��dS)Nc@�eZdZdd�ZdS)z@ElementTreeTest.test_custom_builder_only_end_ns.<locals>.BuildercSrWrjrYrkrrrrl�r'zGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_nsN)r:r;r<rlrrrrrc��rcr�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>
            ))r2r�)r2�prn)rvr7rr�textwrap�dedentrt)r0rcrorrrr�test_custom_builder_only_end_ns�s
	z/ElementTreeTest.test_custom_builder_only_end_nscCs8tjdd�}|�|jtj�t��}|�|jtj�dS)Nr�)r7rrrrr	)r0r�parser2rrr�%test_initialize_parser_without_target�sz5ElementTreeTest.test_initialize_parser_without_targetcCs|ttd��
}t�|�}Wd�n1swY|�dd�|����D�gd�gggg�|�dd�|��D�gd�gggg�t�t�}|�t	t
|��d�|�t	t
|d��d�|�|dd�t
|��|d	}|d}|dd�=|�t	t
|��d�|�||d	�|�||d�||g|d	d�<|�||d	�|�||d�|�||d	�|��|�t
|�g�dS)
Nr=cS�g|]}t|��qSr�rSrNrrrrP���z1ElementTreeTest.test_children.<locals>.<listcomp>)r�r�r�cSryrrzrNrrrrPr{�r�r�r)
rr�r7rrtr�r�r�r�rurv�assertNotEqualr�)r0rrIrE�child1�child2rrr�
test_children�sJ�

���
���

zElementTreeTest.test_childrencCs<t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nrr)r7r�rtr�r�rSrrr�test_writestrings

z ElementTreeTest.test_writestringcCs�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d�t�d�}t�|�|�t�|�d	�t�d
�}t�|�|�t�|�d�dS)Nz
<root></root>s<root />rs"<html>
  <body>text</body>
</html>z!<html> <body>text</body>  </html>z"<html><body>text</body>tail</html>s%<html>
  <body>text</body>tail</html>z=<html><body><p>par</p>
<p>text</p>	<p><br/></p></body></html>s^<html>
  <body>
    <p>par</p>
    <p>text</p>
    <p>
      <br />
    </p>
  </body>
</html>�8<html><body><p>pre<br/>post</p><p>text</p></body></html>sJ<html>
  <body>
    <p>pre<br />post</p>
    <p>text</p>
  </body>
</html>�r7r��indentrtr�rSrrr�test_indent$s0









�

�zElementTreeTest.test_indentcCsXt�d�}tj|dd�|�t�|�d�t�d�}tj|dd�|�t�|�d�dS)Nr��	)�spacesD<html>
	<body>
		<p>pre<br />post</p>
		<p>text</p>
	</body>
</html>r4s><html>
<body>
<p>pre<br />post</p>
<p>text</p>
</body>
</html>r�rSrrr�test_indent_spacePs
�

�z!ElementTreeTest.test_indent_spacecCs�t�d�}t�|�|�dd�|��D�hd��|�dd�|��D�hd��|�tdd�|��D��tdd�|��D���dS)	Nz@<html><body><p>par</p><p>text</p><p><br/></p><p /></body></html>cS�h|]}|j�qSr�ro�rO�elrrr�	<setcomp>mrQz<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>>N�
�
  �
    cSr�r�rpr�rrrr�qrQ>N�
      �parrpr�r�cSr�rr�r�rrrr�urQcSsh|]}t|j��qSr)�idror�rrrr�vs)r7r�r�rtr�rurSrrr�test_indent_space_cachingis

���z)ElementTreeTest.test_indent_space_cachingcCs�t�d�}|�t��tj|dd�Wd�n1swY|�t�|�d�tj|dd�|�t�|�d�t�d�}tj|ddd	�|�t�|�d
�dS)Nr����)�levels9<html><body><p>pre<br />post</p><p>text</p></body></html>r�s^<html>
      <body>
        <p>pre<br />post</p>
        <p>text</p>
      </body>
    </html>r�� )r�r�sI<html>
  <body>
   <p>pre<br />post</p>
   <p>text</p>
  </body>
 </html>)r7r�r�r�r�rtr�rSrrr�test_indent_levelys&
���

�z!ElementTreeTest.test_indent_levelcCs<t�d�}|�tj|dd�d�|�tj|ddd�d�dS)N�0<body xmlns="http://effbot.org/ns"><tag/></body>r=r��A<ns0:body xmlns:ns0="http://effbot.org/ns"><ns0:tag /></ns0:body>r>�r>�default_namespace�1<body xmlns="http://effbot.org/ns"><tag /></body>�r7r�rtr�rSrrr�test_tostring_default_namespace�s
��z/ElementTreeTest.test_tostring_default_namespacecC�&t�d�}|�tj|ddd�d�dS)Nr�r=�foobarr�zP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>r�rSrrr�3test_tostring_default_namespace_different_namespace��

�zCElementTreeTest.test_tostring_default_namespace_different_namespacecCsPt�d�}d}|�t|��tj|ddd�Wd�dS1s!wYdS)Nr�z>^cannot use non-qualified names with default_namespace option$r=r�r�)r7r��assertRaisesRegexr�r�)r0rE�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�r�rSrrr� test_tostring_no_xml_declaration�s

�z0ElementTreeTest.test_tostring_no_xml_declarationcCr�)Nr��utf8T�r>�xml_declarations:<?xml version='1.0' encoding='utf8'?>
<body><tag /></body>r�rSrrr�test_tostring_xml_declaration�r�z-ElementTreeTest.test_tostring_xml_declarationcCr�)Nr�r=Tr��;<?xml version='1.0' encoding='utf-8'?>
<body><tag /></body>r�rSrrr�.test_tostring_xml_declaration_unicode_encoding�r�z>ElementTreeTest.test_tostring_xml_declaration_unicode_encodingc	Cstt�d�}gd�}|D],\}}}|�d|�d|����|�tj|||d�|�Wd�n1s2wYqdS)N�<body><tag>ø</tag></body>))�<body><tag>&#248;</tag></body>NN)�<body><tag>ø</tag></body>�UTF-8N)r��US-ASCIIN)�E<?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag>�</tag></body>�
ISO-8859-1N)r�r=N)r�NF)r�r�F)r�r�F)s<body><tag>�</tag></body>r�F)r�r=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>r�T)sH<?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>r�T)r�r�T)uA<?xml version='1.0' encoding='utf-8'?>
<body><tag>ø</tag></body>r=Tz	encoding=z xml_declaration=r�)r7r��subTestrtr�)r0rE�	TESTCASES�expected_retvalr>r�rrr�#test_tostring_xml_declaration_cases�s"

������z3ElementTreeTest.test_tostring_xml_declaration_casesc	CsHt�d�}|�d�tj|dd��d�|�d�tj|ddd��d�dS)	Nr�r4r=r�r�r>r�r�)r7r�rtrrrSrrr�#test_tostringlist_default_namespace�s
��z3ElementTreeTest.test_tostringlist_default_namespacecCs�t�d�}|�d�tj|dd��d�|�d�tj|dd��d	�tj|ddd
�}|�d�|�d�|�|dd
�|�gd�|dd��dS)Nr�r4r=r�r�rT)r�s><?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>r�r�rz%^<\?xml version='1.0' encoding='.+'?>)z<body�>z<tagz />z</body>r�)r7r�rtrrr�)r0rE�
stringlistrrr�!test_tostringlist_xml_declaration�s 
���z1ElementTreeTest.test_tostringlist_xml_declarationc	sd�fdd�	}|dd�|dd�|dd�|d	d
�|dd�|d
d�dd���fdd�}gd�}|D]}��t�t�||���d�q5gd�}|D]}��ttj||��qLgd�}|D]
}��tjtj||��q_��ttj�d��d����ttj�d��d��dS)Nr4cs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)rtr7r�r$rp)r>r�xmlr�rr�checks
�z,ElementTreeTest.test_encoding.<locals>.checkrr��us-ascii�
iso-8859-1�½ziso-8859-15u€�cp437u√�	mac-romanu˚cSsd|S)Nz*<?xml version='1.0' encoding='%s'?><xml />rr�rrrr��z*ElementTreeTest.test_encoding.<locals>.xmlcs�|��|�SrV)r$r�)r�rr�bxmlrTz+ElementTreeTest.test_encoding.<locals>.bxml)Crrz	utf-8-sig�utf-16�utf-16be�utf-16lez	iso8859-1z	iso8859-2z	iso8859-3z	iso8859-4z	iso8859-5z	iso8859-6z	iso8859-7z	iso8859-8z	iso8859-9z
iso8859-10z
iso8859-13z
iso8859-14z
iso8859-15z
iso8859-16r��cp720�cp737�cp775�cp850�cp852�cp855�cp856�cp857�cp858�cp860�cp861�cp862�cp863�cp865�cp866�cp869�cp874�cp1006�cp1125�cp1250�cp1251�cp1252�cp1253�cp1254�cp1255�cp1256�cp1257�cp1258zmac-cyrillicz	mac-greekzmac-icelandz
mac-latin2r�zmac-turkishz
iso2022-jpziso2022-jp-1ziso2022-jp-2ziso2022-jp-2004ziso2022-jp-3ziso2022-jp-extzkoi8-rzkoi8-tzkoi8-u�kz1048�hz�ptcp154s<xml />)�big5�	big5hkscs�cp932�cp949�cp950zeuc-jpzeuc-jis-2004zeuc-jisx0213zeuc-kr�gb2312�gbk�gb18030z
iso2022-kr�johabz	shift-jiszshift-jis-2004zshift-jisx0213zutf-7)
�cp037�cp424�cp500�cp864�cp875�cp1026�cp1140�utf_32�	utf_32_be�	utf_32_le�	undefined�xxx)r4)	rtr7r�r�r�r�rGr$�LookupError)r0r�r��supported_encodingsr>�&unsupported_ascii_compatible_encodings�(unsupported_ascii_incompatible_encodingsr�r0r�r�
test_encodings(





	zElementTreeTest.test_encodingcCstt�d�}d|_|�t|�d�|�t|dd�d�|�t|dd�d�|�t|dd�d�|�t|dd�d	�dS)
Nz-<html><link/><script>1 &lt; 2</script></html>r�z/<html><link /><script>1 &lt; 2</script></html>
r�r��htmlz*<html><link><script>1 < 2</script></html>
rpz1 < 2
)r7r�rortrJ�r0r�rrr�test_methodsKs

����zElementTreeTest.test_methodscCs2t�d�}|�t|�d�|�t|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>rr��r7r�rtrJrrrr�test_issue18347Zs

��zElementTreeTest.test_issue18347cCs6t�d�}|�t|dd�d�|�|d�|�tj��
}t�d�Wd�n1s+wY|�t|j�d�|�tj��
}t�t	�Wd�n1sOwY|�t|j�d�t�
�}d	|jd
<|�t	�|�
�}|�|d�|�tj��
}t�t�Wd�n1s�wY|�t|j�d�dS)
Nz*<document title='&#x8230;'>test</document>r�r�s*<document title="&#33328;">test</document>u%<document title="舰">test</document>z<document>&entity;</document>z#undefined entity: line 1, column 10z,undefined entity &entity;: line 5, column 10rp�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r7r�rtrJr�r�rGr�r��
ENTITY_XMLrr	rr�EXTERNAL_ENTITY_XML)r0r�r�rr#rrr�test_entityas8
�����

��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>)r7r�r��
SAMPLE_XML_NSrSrrr�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" />rhrM�tag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>r�z{uri}keyz+<ns0:tag xmlns:ns0="uri" ns0:key="value" />z
{uri}valuez0<ns0:tag xmlns:ns0="uri" ns0:key="{uri}value" />z/<ns0:tag xmlns:ns0="uri" ns0:key="ns0:value" />z{uri2}valuez	{uri1}keyz{<ns0:tag xmlns:ns0="uri" xmlns:ns1="uri1" xmlns:ns2="uri2"><tag ns1:key="ns2:value" /><tag ns1:key="ns2:value" /></ns0:tag>�nsz{ns}tagz	other-tagzns:tag)r7rsr��QNamerQr�rqr�rtr�r})r0rEr��q1�q2rrr�
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>)r7r�rSrrr�test_doctype_public�sz#ElementTreeTest.test_doctype_publiccs�ddlm�d?��fdd�	}|ddg�|dddg�|d	d
dg�|dd
dg�|d
gd��|dgd��|dgd��|dgd��|dgd��|dddg�|dgd��|ddg�|dgd��|ddg�|d gd!��|d"gd#��|d$gd%��|d&d
d'g�|d(d(g�|d)gd*��|d+gd,��|d-d-g�|d.d.g�|d/d/g�|d0d0g�|d1gd2��|d3gd4�d5d6i�|d7d8gd9d6i�|d:d
d8gd5d6i�|d;d
d7gd9d6i�|d<d
d=gd9d6i�|d&d
d'gd6d6d>��dS)@Nrr-cs"��dd���||�D�|�dS)NcSsg|]\}}|p	|�qSrr)rO�oprMrrrrP�s�zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)rt�xpath_tokenizer)rsr��
namespaces�r.r0rrr��s


��z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkr�ztext()rp�()z@name�@rfz@*zpara[1])�para�[�1�]zpara[last()])rr�lastrrz*/para)r��/rz/doc/chapter[5]/section[2])r!�docr!�chapterr�5rr!�sectionr�2rz
chapter//para)r#�//rz//parar'rz//olist/item)r'�olistr!�item�.z.//para)r*r'r�..z../@lang)r+r!r�langzchapter[title])r#r�titlerz#employee[@secretary and @assistant])
�employeerr�	secretaryr4�andr4r�	assistantrz	@{ns}attrz{ns}attr�{http://spam}eggz
./spam.egg)r*r!zspam.eggz.//{http://spam}egg)r*r'r2z{ns}*�{}*�{*}tag�{*}*z	.//{*}tag)r*r'r4z
./xsd:type)r*r!�&{http://www.w3.org/2001/XMLSchema}type�xsdz http://www.w3.org/2001/XMLSchema�typer6r4z	@xsd:typez@typez@{*}typez{*}type)r4rrV)r/r.)r0r�rrr�test_xpath_tokenizer�sd�
��
�
�
�
��z$ElementTreeTest.test_xpath_tokenizercCsn|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd�d�d�dS)	Nr�instructions<?test instruction?>z
<testing&>s<?test <testing&>?>u<testing&>ãzlatin-1s=<?xml version='1.0' encoding='latin-1'?>
<?test <testing&>�?>)rtr7r�r�r�r�rrr�test_processinginstruction*s����z*ElementTreeTest.test_processinginstructioncCspdD]3}||��fD]*}d|}tt�d|�dd�}|�||�tt�d||f�dd�}|�||�q
qdS)N)
�AREA�BASE�BASEFONT�BR�COL�FRAME�HR�IMG�INPUT�ISINDEX�LINK�META�PARAMz<%s>z<%s />rr�z	<%s></%s>)�lowerrJr7r�rt)r0r�rEr��
serializedrrr�#test_html_empty_elems_serialization:s���z3ElementTreeTest.test_html_empty_elems_serializationcCsVtjdddd�}t���
}t�|�Wd�n1swY|�|��d�dS)N�
cirriculum�public�example��status�companyz1<cirriculum status="public" company="example" />
)r7rsr�captured_stdout�dumprtrC)r0r��stdoutrrr�test_dump_attribute_orderGs
�
�z)ElementTreeTest.test_dump_attribute_ordercCs8tjdddd�}|�t|�d�|�t|dd�d�dS)	NrLrMrNrOz0<cirriculum status="public" company="example" />rr�z;<cirriculum status="public" company="example"></cirriculum>)r7rsrtrJ�r0r#rrr�test_tree_write_attribute_orderOs
��z/ElementTreeTest.test_tree_write_attribute_ordercCs$t�t�}|�|djddi�dS)Nrz*{http://www.w3.org/XML/1998/namespace}lang�eng)r7r��ATTLIST_XMLrtrqrVrrr�test_attlist_defaultWs
�z$ElementTreeTest.test_attlist_defaultN)0r:r;r<r�r�r�r�r�r�r�r�r�r�r
rrNrTrprvrxr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrrr9r;rKrUrWrZrrrrr��s\C,
6-x=	%, ,;%!A:
r�c@s�eZdZd dd�Zd dd�Zd dd�Zd dd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)!�XMLPullParserTestNcCsF|dur|�|�dStdt|�|�D]
}|�||||��qdS�Nr)rr�ru)r0rr%�
chunk_sizer�rrr�_feed`s
�zXMLPullParserTest._feedcCs$|�dd�t|��|�D�|�dS)NcSs g|]\}}||j|jff�qSr)rMrp)rO�eventrErrrrPis�z3XMLPullParserTest.assert_events.<locals>.<listcomp>)rtr�read_events�r0rr��
max_eventsrrr�
assert_eventsgs��zXMLPullParserTest.assert_eventscCs|�tt|��|��|�dSrV)rtrvrr`rarrr�assert_event_tuplesms�z%XMLPullParserTest.assert_event_tuplescCs(t|��|�}|�dd�|D�|�dS)NcSrrrLrrrrrPtr z7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)rr`rt)r0rr�rbr+rrr�assert_event_tagsrs�z#XMLPullParserTest.assert_event_tagsc	Cs�dD]u}|j|d��et��}|�|g�|�|d|�|�|g�|�|d|�|�|g�|�|d|�|�|dg�|�|d|�|�|d|�|�|dd	g�|�|d
|�|�|dg�|�|���Wd�n1srwYqdS)N)Nr��)r]�<!-- comment -->
z+<root>
  <element key='value'>text</element�>
r�<element>text</element>tail
�<empty-element/>
r!�</root>
r")r�r7�
XMLPullParserrer^r�r)r0r]rrrr�test_simple_xmlws2�����z!XMLPullParserTest.test_simple_xmlcCs�t��}|��}|�|d�t|�\}}|�||jfd�|�|d�t|�\}}|�||jfd�|�t��
t|�Wd�dS1sGwYdS)Nz-<root>
  <element key='value'>text</element>
rrkr")	r7rlr`r^rCrtrMr��
StopIteration)r0rr�rrErrr�test_feed_while_iterating�s
"�z+XMLPullParserTest.test_feed_while_iteratingcCs�t��}|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d�|�|ddg�|�|d	�|�|d
g�|�|���dS)Nrg�<root xmlns='namespace'>
�"<element key='value'>text</elementrhr$rirjr&rkr()r7rlrer^r�r�r0r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)Nr:r*rgrpr3rqrhrirjrkr9)r7rlr^rtrvr`r�rrrrrr�test_ns_events�s
�z XMLPullParserTest.test_ns_eventscCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|�|dg�dS)N)r1r-rr*� <tag xmlns='abc' xmlns:p='xyz'>
�r1)r4�abc�r1)rs�xyzr��rb�r-�{abc}tagr��
<child />
�r-�
{abc}child�rr�</tag>
�rr|�r7rlr^rdrerrrrrr�test_ns_events_start�s.�����
�z&XMLPullParserTest.test_ns_events_startcCs�tjdd�}|�|d�|j|ddgdd�|j|dgd	d�|�|d
�|�|ddg�|�|d
�|��|j|dgd	d�|�|ddg�dS)N)r1r-rr2r*rurvrxr�rzr{r�r}r~r�r�r�r9r�rrrrr�test_ns_events_start_end�s:�������
�z*XMLPullParserTest.test_ns_events_start_endcCs�tjdd�}|�|d�|�|g�tjdd�}|�|d�|�|g�tjdd�}|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|dg�|�|d�|�|gd
��|�|d�|�|���|�|dg�tjdd�}|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|g�|�|d�|�|ddg�|�|d�|�|���dS)Nrr*z<root/>
r,�<!-- text here -->
z<root>
r/rqr0rhrz8<element xmlns='foo'>text<empty-element/></element>tail
)�r-�{foo}element�r-�{foo}empty-element)rr�)rr�z</root>r")r-rgr�r�)r7rlr^rercr�rrrrrr�test_events�sL���zXMLPullParserTest.test_eventscCstjdd�}|�|d�|�|dtjdffg�|�|d�|�|dtjdffg�|�|d�|�|d	g�|�|d
�|�|dtjdffg�|�|d�|�|d
g�|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)N)r-rPrr*r�rPz text here z<!-- more text here -->
z more text here z<root-tag>text)r-�root-tagz<!-- inner comment-->
z inner commentz</root-tag>
)rr�z<!-- outer comment -->
z outer comment )rP)r7rlr^rcrRrerrrrr�test_events_comments z%XMLPullParserTest.test_events_commentcCsdtjdd�}|�|d�|�|dtjdffg�tjdd�}|�|d�|�|dtjdffg�dS)	N)r-rfrr*z
<?pitarget?>
rf�pitarget)rfz<?pitarget some text ?>
zpitarget some text )r7rlr^rcr�rrrrr�test_events_pi1sz XMLPullParserTest.test_events_picCslddh}tj|d�}|�|d�|�|ddg�Gdd�d�}tj|�d�}|�|d�|�|ddg�dS)	Nrr-r*z<foo>bar</foo>)r-r�)rr�c@rU)z9XMLPullParserTest.test_events_sequence.<locals>.DummyItercSstgd��|_dS)N)r-rr1)r�r+r�rrr�__init__Ar'zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|SrVrr�rrr�__iter__CrazBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�SrV)rCr+r�rrrr�E�
zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r:r;r<r�r�r�rrrr�	DummyIter@rdr�)r7rlr^re)r0�eventsetrr�rrr�test_events_sequence9sz&XMLPullParserTest.test_events_sequencecCs<|�t��tjdd�Wd�dS1swYdS)Nr;r*)r�r�r7rlr�rrr�test_unknown_eventLs"�z$XMLPullParserTest.test_unknown_eventrV)r:r;r<r^rcrdrermrorsrtr�r�r�r�r�r�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.xml�324387z	count.txtz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>This document has been <em>accessed</em>
  <xi:include href="count.txt" parse="text"/> times.</p>
</document>
�C2b.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source of the "data.xml" resource:</p>
  <example><xi:include href="data.xml" parse="text"/></example>
</document>
�C3.xmlzQ<?xml version='1.0'?>
<data>
  <item><![CDATA[Brooks & Shields]]></item>
</data>
zdata.xmlaW<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="example.txt" parse="text">
    <xi:fallback>
      <xi:include href="fallback-example.txt" parse="text">
        <xi:fallback><a href="mailto:bob@example.org">Report error</a></xi:fallback>
      </xi:include>
    </xi:fallback>
  </xi:include>
</div>
�C5.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>Example.</p>
  <xi:include href="{}"/>
</document>
�default.xmla
<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
</document>
�include_c1_repeated.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>120 Mz is adequate for an average home user.</p>
  <xi:include href="disclaimer.xml" parse="BAD_TYPE"/>
</document>
�B1.xmlzn<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:fallback></xi:fallback>
</div>
�B2.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive2.xml:</p>
  <xi:include href="Recursive2.xml"/>
</document>
�Recursive1.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive3.xml:</p>
  <xi:include href="Recursive3.xml"/>
</document>
zRecursive2.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="Recursive1.xml"/>
</document>
zRecursive3.xmlc@sHeZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dS)�XIncludeTestr�NcCs:zt|}Wntytd��w|dkrt�|�}|S)N�resource not foundr�)�XINCLUDE�KeyError�OSErrorr7r�)r0�hrefrr>r%rrr�xinclude_loader�s�
zXIncludeTest.xinclude_loadercCr_rVr)r0r�rr>rrr�none_loader�razXIncludeTest.none_loadercCsH|dkr"t|d��}t�|���Wd�S1swYdSdS)Nr�r=)rr7rr�)r0r�rrrrr�
_my_loader�s
$�zXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nrr+r�z�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r/r,r��includer�rtrJ)r0r,r"rrr�test_xinclude_default�s

�z"XIncludeTest.test_xinclude_defaultcCsddlm}|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d	�}|�||j�|�t|�d
�|�d�}|�t��}|�||j�Wd�n1srwY|�t|j	�d�|�t|�d
�dS)Nrr+r�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�r�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/r,r�r�rtrJr�r�r�r��r0r,r?r�rrr�
test_xinclude�s:

�

�

�

�
�
�zXIncludeTest.test_xincludecCs>ddlm}|�d�}|�||j�|�dt|�d���dS)Nrr+r�r�z.//p)r/r,r�r�rtrur�)r0r,r?rrr�test_xinclude_repeated:s
z#XIncludeTest.test_xinclude_repeatedcCs�ddlm}t�td�}|�|j��}|j||jd�Wd�n1s&wY|�	t
|j�d�t�td�}|�|j��}|j||jd�Wd�n1sTwY|�	t
|j�d�t�td�}|�|j��}|j||jd�Wd�n1s�wY|�	t
|j�d	�t�td
�}|�|j��}|j||jd�Wd�n1s�wY|�	t
|j�d�|�
d�}|�|j��}|�||j
�Wd�n1s�wY|�	t
|j�d
�|�
d�}|�|j��}|j||j
dd�Wd�n	1�s	wY|�	t
|j�d
�|�
d�}|�|j��}|j||j
dd�Wd�n	1�s7wY|�	t
|j�d�|�
d�}|�|j��}|j||j
dd�Wd�n	1�sewY|�	t
|j�d�|�
d�}|�|j��}|j||j
dd�Wd�n	1�s�wY|�	t
|j�d�|�
d�}|�|j��}|j||j
dd�Wd�n	1�s�wY|�	t
|j�d
�dS)Nrr+r�)rhz%cannot load 'disclaimer.xml' as 'xml'r�z!cannot load 'count.txt' as 'text'r�z1unknown 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�z#recursive include of Recursive2.xml)�	max_depthzAmaximum xinclude depth reached when including file Recursive2.xmlr�zAmaximum xinclude depth reached when including file Recursive3.xmlr�zAmaximum xinclude depth reached when including file Recursive1.xmlr|)r/r,r7r�r�r��FatalIncludeErrorr�r�rtr�r��XINCLUDE_BADr��LimitedRecursiveIncludeErrorr�rrr�test_xinclude_failuresAs���������
��
��
��
��
��
��z#XIncludeTest.test_xinclude_failures)r�NrV)
r:r;r<r�r�r�r�r�r�r�rrrrr��s

		@r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Ze�
e��d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:S);�BugsTestcs��fdd�}t�d�}||�t�d�}d|_||�t�d�}d|_||�t�d�}|�dd�||�t�d�}|�dd�||�dS)NcsH��t��}t|�Wd�n1swY��t|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorrJrtr�r�)rEr�r�rrr��s
��z-BugsTest.test_bug_xmltoolkit21.<locals>.check�{rE�123)r7rsrpror�)r0r�rErr�r�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)NrMrpr�rO)r7r�r�r*rtr�)r0rErIrrr�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.//tbody�tbody)r7r�rtrSr��r0rIrrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28cCsRt�d�}t���}t�|�|�|��d�Wd�dS1s"wYdS)Nr�z$<doc><table><tbody /></table></doc>
)r7r�rrRrSrtrC)r0rIrTrrr�test_bug_xmltoolkitX1�s



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

�
�

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

�zBugsTest.test_bug_xmltoolkit54cCsL|�tj��
}t�d�Wd�n1swY|�t|j�d�dS)Ns?<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>z+undefined entity &ldots;: line 1, column 36)r�r7rGr�rtr�r�)r0r�rrr�test_bug_xmltoolkit55�s��zBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|�ttj|��dS)Nc@rq)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�rV)r��r0r}rrrr�raz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r:r;r<rrrrr�
ExceptionFile�rrr�)r�r�r7r)r0r�rrr�test_bug_xmltoolkit60�szBugsTest.test_bug_xmltoolkit60cCsHddd�}t��}|j�|�|�d�|��}|�|�d�jd�dS)Nu’u‘)�rsquo�lsquoaF<?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’.)	r7rr	�updaterrrtr�rp)r0�ENTITIESr�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)NrMrp)r7r	r-r%r)rIrrr�xmltoolkit63s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)r]�getrefcountr�rt)r0r��countr�rrr�test_bug_xmltoolkit63s
zBugsTest.test_bug_xmltoolkit63c	Cs`tjddd�}|�t�|�d�|�t�t�|���d�d�|�t�t�t�|���d�dS)N�SomeTagzdef _f():
  return 3
r�s0<SomeTag text="def _f():&#10;  return 3&#10;" />rp)r7rsrtr�r�rdrrrr�test_bug_200708_newlines���z BugsTest.test_bug_200708_newlinecCs`t��}|�d�|�|��jd�Gdd�d�}tj|�d�}|�d�|�|��jd�dS)Nz<element>some text</element>r�c@rq)z2BugsTest.test_bug_200708_close.<locals>.EchoTargetcSs
t�d�S)Nr��r7rsr�rrrr'r�z8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN�r:r;r<rrrrr�
EchoTarget&rrr�r�)r7rrrtrrM)r0rr�rrr�test_bug_200708_closes

zBugsTest.test_bug_200708_closecCs�t�d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t��}t|dd�Wd�n1sWwY|�t|j�d�dS)	Nz
{default}elemr�)r�z%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>rEz<cannot use non-qualified names with default_namespace option)	r7rsrQrtrJr�r�r�r�)r0r��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/" />)r7rsrtr��register_namespacerrrr�"test_bug_200709_register_namespaceDs
�
�
�z+BugsTest.test_bug_200709_register_namespacecCs`t�d�}|�t�d��|�|djtj�t�d�}|�t�d��|�|djtj�dS)Nr�r�r)r7rsr�rRrtrMr�)r0r�rrr�test_bug_200709_element_commentSs

z(BugsTest.test_bug_200709_element_commentcCspt�d�}t�|d�}t�|d�}t�d�}|�d|�|�t|�gd��|�d|�|�t|�gd��dS)	Nr�r�r�r�r)r�r�r�r�)r�r�r�r�)r7rsrQr�rtrS�r0r�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)r7rsrQrRr�rtrSr�)r0r�r��	comment_brrr�test_bug_200709_iter_commentis



 z%BugsTest.test_bug_200709_iter_commentcCsDt��}|�d�}|�di�}|�d�}|��}|�t|�d�dS)Nr%rMr�)r7r	r%r-rrrtrJ)r0r|r�rrr�test_bug_1534630ss

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>rs<<?xml version='1.0' encoding='ascii'?>
<body>t&#227;g</body>s;<?xml version='1.0' encoding='iso-8859-1'?><body>t�g</body>r�rrrr�test_issue6233{s
�
�zBugsTest.test_issue6233cCsRt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�gd��dS)Nr�rM�rMrMr%)r7r�rtrSr�)r0rE�newelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)N�	test10777z
http://myuri/)r7r�r�rrr�test_issue10777�szBugsTest.test_issue10777cs`G�fdd�d�}t�d��|��_���}t|�}|�||�|��jt�|��jd�dS)Nc�eZdZ�fdd�ZdS)z%BugsTest.test_lost_text.<locals>.Textcs
d�_dS)N�changedTr�r��r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N�r:r;r<r�rr�rrr���r�rMr�)r7rsrpr�rCrrr�rt�r0r�r�r�rr�r�test_lost_text�s
zBugsTest.test_lost_textcs|G�fdd�d�}t�d����t�d��|��d_���}t|�}|�||�|��djt�|��djd�dS)Ncr�)z%BugsTest.test_lost_tail.<locals>.Textcsd�d_dS�Nr�rTr�r�r�rrr���
z.BugsTest.test_lost_tail.<locals>.Text.__bool__Nr�rr�rrr��r�r�r#rMrr�)	r7rsr�ror�rCrrr�rtr�rr�r�test_lost_tail�s
zBugsTest.test_lost_tailcs�G��fdd�d�}t�d����t�|�����t�d����d��zt��}Wnty9|�d�Ynw|�|j|�|��djt	�|�
�djd�dS)NcseZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcst�d��d<t��dSr�)r7rsrC)r0r��r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N�r:r;r<r�rr�rrr��sr�r#rMzgenerators are not reentrantrr�)r7rsr�r�rCr��skipTestrrrMr�rt)r0r�r�rr�r�test_lost_elem�s

�zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�r)r7r�rtrd�decode)r0rpr�r#rrr�check_expat224_utf8_bug�s
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r�r`rrr�test_expat224_utf8_bug�s
zBugsTest.test_expat224_utf8_bugcCs�ttd��}|��}Wd�n1swYt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nr=r�rr�r�����)
r�UTF8_BUG_XMLFILErr7r�rdr��stripr!rt)r0�fp�rawr#�xmlattrrprrr�test_expat224_utf8_bug_file�s
�

z$BugsTest.test_expat224_utf8_bug_filecCs.|�tt��jd�|�tt��jdd�dS)NrM)r�r�r7r	r-r�rrr�test_39495_treebuilder_start�sz%BugsTest.test_39495_treebuilder_startN)#r:r;r<r�r�r�r�r�r�r�r�r��unittest�skipIfr]�gettracer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrrr��s<			



r�c@�\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�BasicElementTestcCs�d}ddi}t�||�}|�|tj�|�dt|��|�dt|��|�dt|��|�dt|��|�|j|�|�|j�|�|j	�|�
|j|�|�|j|�d|d	<|�
|j|�|�|j|�dS)
Nr��zix�wyprMrqrpro�bazr�)
r7rsrrr�r�rtrMr�rpror�rqr})r0rMrq�element_foorrr�
test___init__�s zBasicElementTest.test___init__cCs�dttj�vrt�d��t�dddi�}|�t�dddi��|�t��|��}Wd�n1s3wY|�	||�|�
|j|j�|�
|j|j�|�
|j
|j
�|�
t|�t|��t�||�D]
\}}|�||�qf|�
|j|j�dS)	Nr�zElement.copy() not presentr�rrr�r	�qix)r�r7rsr�SkipTestr��assertWarns�DeprecationWarningr�r�rtrMrproru�	itertools�zip_longest�assertIsrq�r0r
�element_foo2r~rrrrr�	s

�zBasicElementTest.test_copycCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j|j�|�t	|�t	|��t
�||�D]
\}}|�||�qF|�|j
|j
�dS�Nr�rrr�r	r)r7rsr�r�r�rtrMrprorurrrrqrrrr�
test___copy__)	s
zBasicElementTest.test___copy__cCs�t�dddi�}|�t�dddi��t�|�}|�||�|�|j|j�|�|j|j�|�|j	|j	�|�t
|�t
|��t�||�D]
\}}|�||�qF|�|j
|j
�|�|j
|j
�d|j
d<|�|j
|j
�|�|j
|j
�dSr)r7rsr�r�r�r�rtrMrprorurrrqr}rrrr�test___deepcopy__A	s

z"BasicElementTest.test___deepcopy__cCs>t�d�}|�t|jd�|�t|jt�d�dg�|�t|jdd�t�d�g|dd�<|�t��d|d<Wd�n1sAwY|�t��t�d�dg|dd�<Wd�n1sawYt|d�r|ddgdd	d
d�}|�t|j|�t|d�r�Gd
d�dtj�}|d�g|dd�<|�tt	j
|�dSdS)N�joer�r�r�r�__setstate__rMr�rorp)rM�	_childrenrqrorp�__deepcopy__c@rq)z9BasicElementTest.test_augmentation_type_errors.<locals>.EcSr_rVr)r0�memorrrrv	razFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__N)r:r;r<rrrrr�Eu	rrr)r7rsr�r�r�r�r�r�rr�r�)r0r��staterrrr�test_augmentation_type_errors_	s0

��
�
�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@�eZdZdS)z.BasicElementTest.test_cyclic_gc.<locals>.DummyN�r:r;r<rrrr�Dummy|	�r"r)r�r�r�r�r�)	r7rs�dummyref�weakref�refr	r�rQr�)r0r"r��wrefr�r�r�r�rrr�test_cyclic_gc{	s2









zBasicElementTest.test_cyclic_gccs\d��fdd�}t�d�}t�||�}|�|�jd�~t�|��d�|�|�d�dS)NFcsd�dS�NTr)�w��flagrr�wref_cb�	sz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)r7rsr%r&rtrMr	)r0r-r�r'rr+r�test_weakref�	s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�r�r�r|)r}r~�zr}�)r�r*)r7rsrtrd)r0r�rrr�test_get_keyword_args�	sz&BasicElementTest.test_get_keyword_argsc	Cs�tdtjd�D]a}t|jdd�D]W\}}|jddd�}d|_d|_|�|d	��	|�d
��|�	|�d	��|�
d�d�d
d�|�|d|||�}|�
|jd�|�
|jdd�|�
t|�d�|�||�qqdS)Nr�r���repeatr��*)r�ztext goes herezopposite of head�child�
grandchildz
.//grandchildrr�zother valuer2r�)r�r^�HIGHEST_PROTOCOLrrXrsrprorQr�r�r�rnrtrMrqrurx)r0rirgrhr�r�rrr�test_pickle�	s"���zBasicElementTest.test_picklec	Cs�tdtjd�D]=}t|jdd�D]3\}}d}|�|�}t|d�r+|�|��dd�|�	|d|||�}|�|j
d�|�|d	j
d
�qqdS)Nr�r�r2z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__rM�groupr2r�dogs)r�r^r7rrXr�r�rtr9rnrM)r0rirgrh�XMLTEXTr�r�rrr�test_pickle_issue18997�	s

���z'BasicElementTest.test_pickle_issue18997N)
r:r;r<rr�rrrr(r.r1r8r=rrrrr�s#
rc@r)�BadElementTestcs|G�fdd�d�}|�g�t�d�}z|���Wn	ty"YnwGdd�d|tj�}|d�g�t�d�}|���dS)Nc�eZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcst�d�g�dd�<tjS)Nr	r�r���Lrr�	__class__�	sz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N�r:r;r<�propertyrBrr@rr�X�	�rEr�c@r )z2BadElementTest.test_extend_mutable_list.<locals>.YNr!rrrr�Y�	r#rGr}�r7rsr�r��r0rEr�rGrr@r�test_extend_mutable_list�	s
�

z'BadElementTest.test_extend_mutable_listcs�G�fdd�d�}|�t�d�g�t�d�}z|���Wn	ty&YnwGdd�d|tj�}|d�t�d�g�t�d�}|���dS)Ncr?)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjSrVr�r�r@rrrB�	s
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__NrCrr@rrrE�	rFrEr	r�c@r )z3BadElementTest.test_extend_mutable_list2.<locals>.YNr!rrrrrG�	r#rGr�rHrIrr@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)Ncr�)z3BadElementTest.test_remove_with_mutating.<locals>.Xc��dd�=dS)NFr�r0�or�rrr��	r�z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__Nr�rr�rrrE�	r�rEr�r�r	)r7rsr�r�r�r��r0rErr�r�test_remove_with_mutating�	s

z(BadElementTest.test_remove_with_mutatingc	Cs~t�d�}t|d|��*|�t��t|�Wd�n1s wYWd�dSWd�dS1s8wYdS)Nr�rM)r7rsr
r��RuntimeErrorr�rrrr�test_recursive_repr
s

��"�z"BadElementTest.test_recursive_reprcsnG�fdd�dt�}t��}|�di�|�d�|�|d��|�d�|�d�|���|��jd�dS)Ncr�)z/BadElementTest.test_element_get_text.<locals>.Xcs"z�jWdStyYdSwrV)rp�	NameErrorr��rErr�__del__
s
�z7BadElementTest.test_element_get_text.<locals>.X.__del__N�r:r;r<rUrrTrrrE
r�rErM�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�r7r	r-r%rrrtrp�r0rEr�rrTr�test_element_get_text
s


z$BadElementTest.test_element_get_textcs�G�fdd�dt�}t��}|�di�|�di�|�d�|�d�|�|d��|�d�|�d�|���|��djd	�dS)
Ncr�)z/BadElementTest.test_element_get_tail.<locals>.Xcs&z�djWdStyYdSwr\)rorSr�rTrrrU#
s
�z7BadElementTest.test_element_get_tail.<locals>.X.__del__NrVrrTrrrE"
r�rEr#rMrWrXrYrrZ)	r�r7r	r-rr%rrtror[rrTr�test_element_get_tail 
s



z$BadElementTest.test_element_get_tailcs^G�fdd�d�}t�d����t�d���d|����t�d���dd|��dS)Ncr�)z%BadElementTest.test_subscr.<locals>.XcrL�Nr�rr�r�rr�	__index__8
r�z/BadElementTest.test_subscr.<locals>.X.__index__N�r:r;r<r_rr�rrrE7
r�rErEr5rr�)r7rsr�rOrr�r�test_subscr5
s
zBadElementTest.test_subscrcsPG�fdd�d�}t�d��td�D]}��dt�d��qg�dd|��<dS)Ncr�)z)BadElementTest.test_ass_subscr.<locals>.Xcsg�dd�<dSr^rr�r�rrr_F
�z3BadElementTest.test_ass_subscr.<locals>.X.__index__Nr`rr�rrrEE
r�rErEr�rr5)r7rsr�r�)r0rErrr�r�test_ass_subscrC
s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcS�gSrVr�r}r~rrr�element_factoryR
raz>BadElementTest.test_treebuilder_start.<locals>.element_factory�rfrMrWr�)r7r	r-r%r��AttributeErrorr	�r0rfr�rrr�test_treebuilder_startP
s

z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|�di�|�d�|�t|jd�~t�dS)NcSrdrVrrerrrrf^
raz<BadElementTest.test_treebuilder_end.<locals>.element_factoryrgrMrW)r7r	r-r%r�rhrr	rirrr�test_treebuilder_end\
s

z#BadElementTest.test_treebuilder_endN)
r:r;r<rJrKrPrRr\r]rarcrjrkrrrrr>�	s

r>c@r()�MutatingElementPathcGstj|g|�R�}||_|SrV)r��__new__rE)rYrErr0rrrrmj
szMutatingElementPath.__new__cCs|jdd�=dSr)rTrMrrrr�n
rbzMutatingElementPath.__eq__N)r:r;r<rmr�rrrrrli
srlc@rq)�BadElementPathcCsdd�)Nr�rrrMrrrr�t
r�zBadElementPath.__eq__Nr�rrrrrns
rrrncsXeZdZ�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�r0r.�rBrrrry
s

zBadElementPathTest.setUpcs"ddlm}|j|_t���dSrp)r/r.rsr�rq�tearDownrtrurrrv
szBadElementPathTest.tearDowncC�0t�d�}|�t�d�g�|�t|d��dS�Nr�r�r})r7rsr�r�rlrrrr�test_find_with_mutating�
�
z*BadElementPathTest.test_find_with_mutatingcC�Ft�d�}|�t�d�g�z
|�td��WdSty"YdSwrx)r7rsr�r�rn�ZeroDivisionErrorrrrr�test_find_with_error�
�
�z'BadElementPathTest.test_find_with_errorcCrwrx)r7rsr�r�rlrrrr�test_findtext_with_mutating�
rzz.BadElementPathTest.test_findtext_with_mutatingcCr{rx)r7rsr�r�rnr|rrrr�test_findtext_with_error�
r~z+BadElementPathTest.test_findtext_with_errorcCrwrx)r7rsr�r�rlrrrr�test_findall_with_mutating�
rzz-BadElementPathTest.test_findall_with_mutatingcCr{rx)r7rsr�r�rnr|rrrr�test_findall_with_error�
r~z*BadElementPathTest.test_findall_with_error)r:r;r<rrrvryr}rr�r�r��
__classcell__rrrurrox
sroc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�dSrV)	rrr7rGr8rr*rsr	rr�rrr�test_istype�
szElementTreeTypeTest.test_istypecCsZGdd�dtj�}|d�}|�|tj�|�||�|�|jd�d|_|�|jd�dS)Nc@r )zDElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementNr!rrrr�	MyElement�
r#r�r�r)r7rsrrrtrMrp�r0r��myerrr�test_Element_subclass_trivial�
sz1ElementTreeTypeTest.test_Element_subclass_trivialcsVG�fdd�dtj���dddd�ddd	�}|�|jd
�|�t|���gd��dS)Ncs"eZdZif��fdd�	Z�ZS)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcs"t�|�j|d|fi|��dS)N�__)rqr�)r0rMrq�extra)r�rBrrr��
s"zQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r:r;r<r�r�r�r�rurr��
sr�r�r�r�)r�r�r|�)r�r��foo__))r�r�)r�r�)r�r|)r�r�)r7rsrtrMr�r�)r0r�rr�r�!test_Element_subclass_constructor�
s�z5ElementTreeTypeTest.test_Element_subclass_constructorcCs.Gdd�dtj�}|d�}|�|��d�dS)Nc@rq)zGElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementcS�|jSrVrLr�rrr�	newmethod�
�zQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r:r;r<r�rrrrr��
rrr�r)r7rsrtr�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@r )zAElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementNr!rrrrr��
r#r�r�rpr�rOr�r)r7rsrpr�rtr�r�rMrvr�ru)r0r�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)NrMr��./tagr�zsection/nexttag�nexttagrprOr4r��togz<tag><empty /></tag>�empty)	r7r�r�rtr�rM�SAMPLE_SECTIONr�r�rrrr�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]�XPathz./tag[0]z	./tag[-1]z./tag[last()-0]z./tag[last()+1])r7r�rtr�rqr��SyntaxError)r0�
LINEAR_XMLr�rrr�test_find_xpath�
s
zElementFindTest.test_find_xpathcCspt�t�}t�t�|d<|�t|�d��dg�|�t|�d��ddg�|�t|�d��g�|�t|�d��g�|�t|�d��gd��|�t|�d	��dgd
�|�t|�d��dg�|�t|�d��dgd�|�t|�d
��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��gd��|�t|�d��dg�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dg�|�t|�d��d g�|�t|�d!��g�|�t|�d"��g�|�t|�d#��dgd�|�|�d$�|�d��|�t|�d%��d g�|�t|�d&��d g�|�t|�d'��d g�|�t|�d(��d g�|�t|�d)��d g�|�t|�d*��g�|�t|�d+��g�|�t|�d,��g�|�t|�d-��g�|�t|�d.��g�|�t|�d/��dg�|�t|�d0��dg�|�t|�d1��dg�|�t|�d2��dg�|�t|�d3��dg�|�t|�d4��g�|�t|�d5��g�|�t|�d6��dgd�|�t|�d7��dgd�|�t|�d8��dgd�|�t|�d9��dgd�|�t|�d:��dgd�|�t|�d;��dgd
�|�t|�d<��dgd
�|d|d=<|�t|�d(��d d g�|�t|�d3��ddg�dS)>Nr�r*rrMr�ztog/foor�r�z.//tagr�r�zsection//tagz	section/*)rMr��nextsectionz
section//*)rMr�r�rMzsection/.//*z*/*z*//*z*/tagz*/./tagr�z././tagz.//tag[@class]r|z.//tag[@class="a"]z.//tag[@class!="a"]z.//tag[@class="b"]z.//tag[@class!="b"]z.//tag[@id]z.//section[tag]r%z.//section[element]z../tagzsection/../tagz	section//z.//section[tag='subtext']z.//section[tag ='subtext']z.//section[tag= 'subtext']z.//section[tag = 'subtext']z.//section[ tag = 'subtext' ]z.//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']z.//tag[.!='subtext']z.//tag[. !='subtext']z.//tag[.!= "subtext"]z.//tag[ . != "subtext" ]z.//tag[. != 'subtext']z.//tag[. != 'subtext ']z.//tag[.!= ' subtext']r�)r7r�r�r�rtrSr�rrrr�test_findalls
�����������������������������������������zElementFindTest.test_findallcCs\t�t�}|�t|�d��g�|�t|�d��dgd�|�t|�d��dgd�dS)NrMz{http://effbot.org/ns}tagr�z.//{http://effbot.org/ns}tagr|)r7r�r
rtrSr�rrrr�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>�xxrEz.//xx:b)rr��.//brGr�)r�r4)r7r�rtrur�)r0r#�nsmaprrr�test_findall_different_nsmaps�s

z-ElementFindTest.test_findall_different_nsmapscCs�t�d�}|�t�d��|�t|�d��gd��|�t|�d��dg�|�t|�d��dg�|�t|�d	��d
g�|�t|�d��ddg�|�t|�d
��dg�|�t|�d
��t|�d���|�t|�d��gd��|�t|�d�|dg�t|�d���|�t|�d��gd��|�t|�d��ddg�|�t|�d��ddg�|�t|�d��d
g�|�t|�d��gd��|�t|�d��ddg�|�t|�d��t|�d���dS)Nr�rz{*}b)�{X}br��{Y}bz{*}cr�z{X}*r�z{Y}*r�r3r�z{}br5)r�r�r�r�r�r�z.//{*}b)r�r�r�r�r�z.//{*}cz.//{X}*z.//{Y}*z.//{}*)r�r�r�r�z.//{}br�)r7r�r�rRrtrSr�rVrrr�test_findall_wildcard�sd
����������������z%ElementFindTest.test_findall_wildcardcCsFt�t�}|�td��|�d�Wd�dS1swYdS)Nzcannot use absolute pathz/tag)r7r�r�r�r�r�rrrr�
test_bad_find�s
"�zElementFindTest.test_bad_findcCs�t�t�}|�t�|��d�jd�|�t�|��d�d�|�tt�|��	d��dgd�d}|�
t|��t�|��	d�}Wd�n1sJwY|�t|�dgd�dS)NrMrpr�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//tagr|)r7r�r�rtr*r�rMr�rSr��assertWarnsRegex�
FutureWarning)r0r�r�r�rrr�test_find_through_ElementTree�s
��z-ElementFindTest.test_find_through_ElementTreeN)r:r;r<r�r�r�r�r�r�r�r�rrrrr��
sp
,r�c@s>eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�ZdS)�ElementIterTestNcCst|�|��SrV)rSr�)r0rErMrrr�_ilist�rTzElementIterTest._ilistcCs4t�d�}|�|�|�gd��|�|�|�d��ddg�|�t|���jd�|�d�|�	��d�|�d�|�d��	��d�|�t|�	��d	�t
|d
d�}|�tt�|��dd
�t
|d
d�}tjt�
�d�}|�ttj||d��dd
�t�d�}|�t|j�t�d�}|�d�|�	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>)rrr�rr�rr4zthis is a paragraph...zthis is a paragraph.z
this is a F)rFrrr�)rz*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)r7r�rtr�r�rCr�rMrr�rJrBrr	r*r�rh)r0r"�
sourcefilerrIrrr�
test_basic�s(
��

zElementIterTest.test_basiccCs�t�d�}|�|�|�dg�t�|d�}|�|�|�ddg�t�|d�}|�|�|�gd��t�|d�}|�|�|�gd��|d|d<|d=|�|�|�ddg�dS)	Nr�r�r�)r�r�r�r�)r�r�r�r�r�r)r7rsrtr�rQr�rrr�test_corners�s
zElementIterTest.test_cornerscCs�t�d�}|�|�|d�dgd�|�|�|d�dgd�|�t|jdd��dgd�gd�}|�t|���|�|�|�|�|�|�|�|d�|�dS)	NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>�roomr|�houser�rL)r?r�r�r��shedr�r�r�)r7r�rtr�rSr�)r0r"�all_tagsrrr�test_iter_by_tags

�z ElementIterTest.test_iter_by_tagcCsLt�d�}|��}|�t��t�|�Wd�dS1swYdS)Nr�)r7rsr�r�r�r�)r0r�r�rrrr�/s

"�zElementIterTest.test_copyc	Csft�d�}|��}ttjd�D] }|�ttjf��t�	||�Wd�n1s+wYqdS)Nr�r�)
r7rsr�r�r^r7r�r�rar_)r0r�r�rirrrr85s
���zElementIterTest.test_picklerV)	r:r;r<r�r�r�r�r�r8rrrrr��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)Nrrpr�r�divrOro)rtrMrprorqrvru)r0r��childrenr5rrr�_check_sample1_elementEsz&TreeBuilderTest._check_sample1_elementcCs�Gdd�d�}Gdd�d|�}tj|�d�}|�|j�|�|��d�tj|�d�}|�|j�|�|��d�tjt�d�}|�|j�|�|���dS)Nc@rq)z<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuildercS�dS)Nr4rr�rrrrTrazBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeNr�rrrr�BaseDummyBuilderSrrr�c@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWr_rVr)r�rrr�<lambda>X�zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)r:r;r<r%r-rrrrr�DummyBuilderWsr�r�r4)r7rr�sample1rtr�objectr�)r0r�r�rrrr�test_dummy_builderRsz"TreeBuilderTest.test_dummy_buildercCs�t��}|�|�d�jtj�|�|�d�jd�tjtjd�}|�|�d�jtj�|�|�d�jd�tjtd�}|�|�d�td��dS)N�ctext)�comment_factory)r7r	rtrPrMrRrpru�r0r�rrr�test_treebuilder_commentfsz(TreeBuilderTest.test_treebuilder_commentcCs�t��}|�|�dd�jtj�|�|�dd�jd�tjtjd�}|�|�d�jtj�|�|�d�jd�|�|�dd�jtj�|�|�dd�jd�tjdd�d�}|�|�d�td�df�|�|�dd�td�df�dS)Nr)�
pi_factoryr�z text zpitarget  text cSst|�|fSrV)ru)rrprrrr�}sz5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>)r7r	rtrfrMr�rprur�rrr�test_treebuilder_pirs z#TreeBuilderTest.test_treebuilder_picCs�Gdd�dtj�}d}t�|�}|�|jd�tj|�d�}|�|�|��}|�|jd�d}t�|�}|�|jd�d}tj|�d�}|�|�|��}|�|jd�dS)Nc@r )z;TreeBuilderTest.test_late_tail.<locals>.TreeBuilderSubclassNr!rrrr�TreeBuilderSubclass�r#r�z<a>text<!-- comment -->tail</a>�texttailr�z<a>text<?pi data?>tail</a>)r7r	r�rtrprrr)r0r�r�r�rrrr�test_late_tail�s 



zTreeBuilderTest.test_late_tailcCszGdd�dtj�}d}tjtjdd�d�}|�|�|��}|�|djd�|�|djd	�|�|jd
�tj|dd�d�}|�|�|��}|�|djd�|�|djd	�|�|jd
�d}tjtjdd�d�}|�|�|��}|�|djd
�|�|djd�|�|jd�tj|dd�d�}|�|�|��}|�|djd
�|�|djd�|�|jd�dS)Nc@r )zKTreeBuilderTest.test_late_tail_mix_pi_comments.<locals>.TreeBuilderSubclassNr!rrrrr��r#r�z/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)�insert_commentsr�rrmz
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)�
insert_piszpi dataroztext
)r7r	rrrrtrpro)r0r�r�rr�rrr�test_late_tail_mix_pi_comments�s6



z.TreeBuilderTest.test_late_tail_mix_pi_commentscCs6tjtjdd�d�}|�|j�|��}|�|�dS�Nrgr�)r7rr	rr�rr��r0rr�rrr�$test_treebuilder_elementfactory_none�sz4TreeBuilderTest.test_treebuilder_elementfactory_nonecCsXGdd�dtj�}|�}|�|�d�d�tj|d�}|�|j�|��}|�|�dS)Nc@rq)z4TreeBuilderTest.test_subclass.<locals>.MyTreeBuildercS�|dS�Nr�rr�rrrr��r�z;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN�r:r;r<r�rrrr�
MyTreeBuilder�rrr�r�r�r�)	r7r	rtr�rrr�rr��r0r��tbrr�rrr�
test_subclass�szTreeBuilderTest.test_subclasscCslGdd�dtj�}|tjtjd�}|�|�d�d�tj|d�}|�|j�|�d�|�	�}|�
|�dS)Nc@rq)z?TreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuildercSr�r�rr�rrrr��r�zFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobarNr�rrrrr��rrr�)r�r�r�r�r�z<!-- a comment--><?and a pi?>)r7r	rRr�rtr�rrr�rr�r�rrr�test_subclass_comment_pi�s
z(TreeBuilderTest.test_subclass_comment_picsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�SrV)r�r7rs)rMrq��lstrr�	myfactory�s
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryrgr��toplevel)r7r	rr�sample2rrt)r0r�r�rrr�r�test_element_factory�sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dSr�)r7r	rrr�rrrr�)r0rYr�rr�rrr�_check_element_factory_class�sz,TreeBuilderTest._check_element_factory_classcCs Gdd�dtj�}|�|�dS)Nc@r )z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementNr!rrrrr��r#r�)r7rsr�)r0r�rrr�test_element_factory_subclass�sz-TreeBuilderTest.test_element_factory_subclasscCs4tj}|�|jd�Gdd�d|t�}|�|�dS)Nr2c@r )zLTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementNr!rrrrr�
r#r�)r7�_Element_Pyrtr;r�r�)r0�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|_dSrV��_doctype�r0rf�pubid�systemrrr�doctype

sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSr�rVr�r�rrrr
r�z9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r:r;r<r�r�rrrrr�
DoctypeParser

sr�r��rz&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r7rrr�rtr)r0r�rrrr�test_doctype	
s	
�zTreeBuilderTest.test_doctypec	Cs�Gdd�d�}tj|�d�dD] }|�t|��tj||�d�Wd�n1s+wYqtj|td�d�dD]}tj||td�d�}|�|j�|�|���q<dS)Nc@s"eZdZdefdd�Zdd�ZdS)zBTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNcSs||_||_dSrV��raise_in�what)r0r�r�rrrr�
s
zKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWr_rVr)rrrr�handle#
raz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handler�)r0rfr�rrr�__getattr__ 
s
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r:r;r<r�r�r�rrrr�RaisingBuilder
sr�r�)r-r%rrPrf)r�)	r7rr�r�rhrr�r�r)r0r�r_rrrr�test_builder_lookup_errors
s���z*TreeBuilderTest.test_builder_lookup_errorsN)r:r;r<r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�=s$
$	
r�c@sPeZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�
XMLParserTests<file><line>22</line></file>s�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>uX<?xml version="1.0" encoding="iso-8859-1"?>
<money value="$£€𐅻">$£€𐅻</money>cCs6|�|jd�|�|djd�|�|djd�dS)NrHr�line�22)rtrMrprrrr�_check_sample_element=
sz#XMLParserTest._check_sample_elementcCs0tjdt��d�}|�|j�|�|���dS)Nr)r>r)r7rr	rr�r�r)r0rwrrr�test_constructor_argsB
s
�z#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|�|j�|�|���dS)Nc@r )z-XMLParserTest.test_subclass.<locals>.MyParserNr!rrrr�MyParserI
r#r�)r7rrr�r�r)r0r�rrrrr�H
szXMLParserTest.test_subclasscCsVt���t�dt�t��}|�|j�|��Wd�dS1s$wYdS)N�error)	�warnings�catch_warnings�simplefilterrr7rrr�rrrrrr�test_doctype_warningO
s

"�z"XMLParserTest.test_doctype_warningcsd�G�fdd�dtj�}|�}|�td��|�|j�Wd�n1s'wY|��|���d��t�	��9t�
dt�t�
dt�G�fdd�d�}||�d�}|�|j�|��|���|��d�Wd�dS1sywYdS)	Ncr�)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs||f�dSrVr)r0rrr�rrr�Y
szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN�r:r;r<r�rr�rr�MyParserWithDoctypeX
r�rr�rcr�)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dSrVrr���	_doctype2rrr�h
r[zBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeNrrrrrr�g
r�r�r�r�)
r7rr��RuntimeWarningrr�rr�rrrrrt)r0rrr�r)r�rr�test_subclass_doctypeV
s*�


�"�z#XMLParserTest.test_subclass_doctypecCsrt���+t�dt�t�dt�Gdd�dtj�}|�}|�|j�|�	�Wd�dS1s2wYdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)rc@r )zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr!rrrr�MyParserWithoutDoctypey
r#rN)
rrrrr	r7rrr�r)r0rrrrr�test_inherited_doctypet
s

"�z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)Nr��moneyr�u
$£€𐅻)
r7rr	r�sample3rrtrMrqrpr�rrr�test_parse_string
szXMLParserTest.test_parse_stringN)
r:r;r<r�r�rr�r�r�rr
rrrrrrr�4
sr�c@rq)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	N�hellor�)�hrz{hello}tabler�z.//{hello}tdr�z.//{foo}name)r7r��SAMPLE_XML_NS_ELEMSrtrur�)r0r�r"rrr�test_find_with_namespace�
s


z+NamespaceParseTest.test_find_with_namespaceN)r:r;r<rrrrrr�
rrrc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ElementSlicingTestcCsdd�|D�S)NcSrKrrL)rOr�rrrrP�
rQz1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)r0�elemlistrrr�
_elem_tags�
rTzElementSlicingTest._elem_tagscCs|�t|��SrV)rrvrSrrr�
_subelem_tags�
rTz 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)r7rsr�rQ)r0�numchildrenr�r�rrr�_make_elem_with_children�
s
z+ElementSlicingTest._make_elem_with_childrencsZ|�d��|��djd�|��djd�|�t�fdd��|�t�fdd��dS)	Nr�r��a1����a8c��dS)N�rrr�rrr��
�z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cr)Ni�rrr�rrr��
r )rrtrMr��
IndexErrorr�rr�r�test_getslice_single_index�
s

z-ElementSlicingTest.test_getslice_single_indexcCs�|�d�}|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��gd��|�|�|dd��ddg�|�|�|dd��ddg�|�|�|dd	��d
dg�dS)Nr�r|)�a3�a4�a5�rfr#r$r�r��a0r)rrtrrrrr�test_getslice_range�
s
"z&ElementSlicingTest.test_getslice_rangec	Cs�|�d�}|�|�|ddd��ddg�|�|�|ddd��gd��|�|�|ddd��ddg�|�|�|ddd��d	dg�|�|�|ddtj��d
g�|�|�|ddtjd>��d
g�dS)Nr��r�r�a9r|)r'r#�a6r*r'rr#�@�rrtrr]�maxsizerrrr�test_getslice_steps�
s
     (z&ElementSlicingTest.test_getslice_stepsc	Cs�|�d�}|�|�|ddd��gd��|�|�|ddd��ddg�|�|�|ddtj��dg�|�|�|ddtjd��dg�|�|�|ddtjd	>��dg�dS)
Nr�r�)r#�a2rr'rr#rr|r�r,r-rrrr�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�r0r#r�rr'r�r)rrtrrrrr�
test_delslice�
s$







z ElementSlicingTest.test_delslicecCs�|�d�}t�d�|d<|�|�|�gd��t�d�|d<|�|�|�gd��|�t��t�d�|d	<Wd�n1s@wY|�t��t�d�|d
<Wd�n1s\wY|�|�|�gd��dS)Nr�r�r��r'r�r0r#r�r)r'r�r�r#r�rf���)rr7rsrtrr�r!rrrr�test_setslice_single_index�
s
��z-ElementSlicingTest.test_setslice_single_indexcCs�|�d�}dd�td�D�|dd�<|�|�|�gd��|�d�}t�d�g|dd�<|�|�|�gd	��|�d�}d
d�td�D�|dd�<|�|�|�gd��dS)Nr�cS�g|]	}t�d|��qS�zb%sr��rOr�rrrrP�
r z:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�r�r|)r'�b0�b1r#r�)r'r�r#cSr6r7r�r8rrrrP�
r )r'r9r:�b2r#)rr�rtrr7rsrrrr�test_setslice_range�
s


z&ElementSlicingTest.test_setslice_rangecCs�|�d�}dd�td�D�|ddd�<|�|�|�gd��|�d�}|�t��t�d�g|ddd�<Wd�n1s>wY|�t��d	d�td
�D�|ddd�<Wd�n1sawY|�t��g|ddd�<Wd�n1s}wY|�|�|�gd��|�d�}t�d�g|ddtj	�<|�|�|�gd
��t�d�g|ddtj	d>�<|�|�|�gd��dS)Nr�cSr6r7r�r8rrrrP�
r z:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�r�rf)r'r9r0r:r$r%r�cSr6r7r�r8rrrrPr r|)r'rr0r#r$r%r�r3r�r,�r'r�r0r#�
rr�rtrr�r�r7rsr]r.rrrr�test_setslice_steps�
s&

���
z&ElementSlicingTest.test_setslice_stepscCs�|�d�}dd�td�D�|ddd�<|�|�|�gd��|�d�}|�t��t�d�g|ddd�<Wd�n1s>wY|�t��d	d�td
�D�|ddd�<Wd�n1sawY|�t��g|ddd�<Wd�n1s}wY|�|�|�gd��|�d�}t�d�g|ddtj	�<|�|�|�gd
��t�d�g|ddtj	d�<|�|�|�gd��t�d�g|ddtj	d>�<|�|�|�gd��dS)Nr�cSr6r7r�r8rrrrPr zCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rr�)r'r:r9r#r�cSr6r7r�r8rrrrPr r|)r'rr0r#r�r3r�r=r�r,)r'r�r0r#r>rrrr�test_setslice_negative_stepss*

���
z/ElementSlicingTest.test_setslice_negative_stepsN)r:r;r<rrrr"r(r/r1r2r5r<r?r@rrrrr�
s
	

	
rc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZGdd�d�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�IOTestc	Cs�t�d�}d|_|�t|�d�dD]-}|�|��|�t||d�d�|�t||��d�d�Wd�n1s:wYqdD]9}|�|��*|�t||d�d|�|��|��}|�t||d�d|�|��Wd�n1svwYqBt�d�}d	|_|�t|�d
�|�t|dd�d�|�t|d
d�d�dD]}|�t||d�d|�|��q�t�d�}d	|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�dD]}|�t||d�d|�|��q�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|�|���qOdS)NrMrwz<tag>abc</tag>)rr�r�s<tag>abc</tag>)r�r��utf-32z2<?xml version='1.0' encoding='%s'?>
<tag>abc</tag>z<&"'>z<tag>&lt;&amp;"'&gt;</tag>rs<tag>&lt;&amp;"'&gt;</tag>r�z><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>r�z"<tag key="&lt;&amp;&quot;'&gt;" />s"<tag key="&lt;&amp;&quot;'&gt;" />zF<?xml version='1.0' encoding='%s'?>
<tag key="&lt;&amp;&quot;'&gt;" />uåöö<>u<tag>åöö&lt;&gt;</tag>s<tag>åöö&lt;&gt;</tag>s%<tag>&#229;&#246;&#246;&lt;&gt;</tag>u=<?xml version='1.0' encoding='%s'?>
<tag>åöö&lt;&gt;</tag>u<tag key="åöö&lt;&gt;" />s<tag key="åöö&lt;&gt;" />s(<tag key="&#229;&#246;&#246;&lt;&gt;" />)r�r�r�r�rBu@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	r7rsrprtrJr��upperr$rq)r0rE�encrCrrrr)s�
����������
	����

����
����

�����zIOTest.test_encodingcCsh|�tjt�t�t�d��}|�t�ttd��}|�	|�
�d�Wd�dS1s-wYdS)N�<site>ø</site>r=�<site>&#248;</site>)rHrrIr
r7r*r�rBrrtr�r0rIrrrr�test_write_to_filenamens
"�zIOTest.test_write_to_filenamecCs�|�tjt�t�t�d��}|jtdd�ttd��}|�	|�
�d�Wd�n1s.wY|jtdd�ttd��}|�	|�
�td��Wd�dS1sUwYdS)NrErr�r=�<site>ø</site>r��:<?xml version='1.0' encoding='ISO-8859-1'?>
<site>�</site>)rHrrIr
r7r*r�rBrrtrr&rGrrr�$test_write_to_filename_with_encodingus��"�z+IOTest.test_write_to_filename_with_encodingcCs�|�tjt�ttd��}|j}Wd�n1swYt�t�t�t�d��}|j	tdd�ttd��}|�
|��d�Wd�dS1sLwYdS)Nr*rEr=r�r=rI)rHrrIr
rr>r7r*r�rBrtr)r0rr>rIrrr�!test_write_to_filename_as_unicode�s�
"�z(IOTest.test_write_to_filename_as_unicodecCs�|�tjt�t�t�d��}ttddd��}|j|dd�|�	|j
�Wd�n1s.wYttd��}|�|��d�Wd�n1sKwYttddd	d
��}|j|dd�|�	|j
�Wd�n1spwYttd��}|�|��d�Wd�n1s�wYttddd��}|j|dd�|�	|j
�Wd�n1s�wYttd��}|�|��d
�Wd�dS1s�wYdS)NrEr*rr�r=r=rIr�xmlcharrefreplace)r>�errorsrFr�s<site>�</site>�
rHrrIr
r7r*r�rrBrDrErtrrGrrr�test_write_to_text_file�s.�����"�zIOTest.test_write_to_text_filecCs�|�tjt�t�t�d��}ttd��}|�|�|�	|j
�Wd�n1s*wYttd��}|�|��d�Wd�dS1sHwYdS)NrEr@r=rFrOrGrrr�test_write_to_binary_file�s
�"�z IOTest.test_write_to_binary_filecCs |�tjt�t�t�d��}ttd��}|j|dd�|�	|j
�Wd�n1s,wYttd��}|�|��d�Wd�n1sIwYttd��}|j|dd�|�	|j
�Wd�n1skwYttd��}|�|��d�Wd�dS1s�wYdS)	NrEr@rr�r=rIr�rJrOrGrrr�'test_write_to_binary_file_with_encoding�s$���
�"�z.IOTest.test_write_to_binary_file_with_encodingcCs0|�tjt�t�t�d��}ttd��}|j|dd�|�	|j
�Wd�n1s,wYttd��}|�|��d�
d��Wd�n1sLwYttddd��}|j|dd�|�	|j
�Wd�n1spwYttd��}|�|��d�
d��Wd�dS1s�wYdS)	NrEr@r�r�r=u7<?xml version='1.0' encoding='utf-16'?>
<site>ø</site>r)�	buffering)rHrrIr
r7r*r�rrBrDrErtrr$rGrrr�"test_write_to_binary_file_with_bom�s,�
���
�"�z)IOTest.test_write_to_binary_file_with_bomcC�2t��}t�d�}|�|�|�|��jd�dS�Nz"<?xml version="1.0"?><site></site>�site)r7r*r?rArrtr�rM�r0rIr
rrr�test_read_from_stringio��

zIOTest.test_read_from_stringiocCs:t�t�d��}t��}|j|dd�|�|��d�dS�NrEr=r�)r7r*r�r?rArBrtrCrXrrr�test_write_to_stringio�szIOTest.test_write_to_stringiocCrU�Ns"<?xml version="1.0"?><site></site>rW)r7r*r?r@rrtr�rM�r0rIr�rrr�test_read_from_bytesio�rZzIOTest.test_read_from_bytesiocCs6t�t�d��}t��}|�|�|�|��d�dS�NrErF)r7r*r�r?r@rBrtrCr^rrr�test_write_to_bytesio�s
zIOTest.test_write_to_bytesioc@r )zIOTest.dummyNr!rrrr�dummy�r#rbcCsBt�d�}|��}|j|_t��}|�|�|�|��j	d�dSrV)
r?rArbrr7r*rrtr�rM)r0r
�readerrIrrr�test_read_from_user_text_reader�s

z&IOTest.test_read_from_user_text_readercCsJt�t�d��}t��}|��}|j|_|j|dd�|�|��d�dSr[)	r7r*r�r?rArbrBrtrC)r0rIr
�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@rbrr7r*rrtr�rM)r0r�rcrIrrr�!test_read_from_user_binary_reader�s

z(IOTest.test_read_from_user_binary_readercCsFt�t�d��}t��}|��}|j|_|�|�|�|��d�dSr`)	r7r*r�r?r@rbrBrtrC�r0rIr�rerrr� test_write_to_user_binary_writers
z'IOTest.test_write_to_user_binary_writercCsbt�t�d��}t��}|��}|j|_dd�|_|j|_|j|dd�|�	|�
�d�d��dS)Nz<site />cSr�r)rrrrrr�r�zBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>r�r�z0<?xml version='1.0' encoding='utf-16'?>
<site />)r7r*r�r?r@rbrB�seekable�tellrtrCr$rhrrr�)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=r4r�r)r7r�rtr�rrrVrrr�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)�short_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)r7r�rtr�rVrrr�test_short_empty_elements!s

���z IOTest.test_short_empty_elementsN)r:r;r<rrHrKrLrPrQrRrTrYr\r_rarbrdrfrgrirlrmrorrrrrA(s*E
			rAc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|�t��t�dSrV)rrr7rGr�r�rrrr�/r�zParseErrorTest.test_subclassc
Cs<zt�|�WdStjy}z|WYd}~Sd}~wwrV)r7r�rG)r0r�r�rrr�
_get_error2s��zParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)r�rz<tag>&foo;</tag>)r�rfzfoobar<)r�r�)rtrq�positionr�rrr�test_error_position8sz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	�xml.parsers.expat.errors�parsers�expatrNrtrq�code�codes�XML_ERROR_SYNTAX)r0�ERRORSrrr�test_error_code=s
�zParseErrorTest.test_error_codeN)r:r;r<r�rqrsr{rrrrrp.s
rpc@rq)�KeywordArgsTestc
Cs�t�d�}|�|�dd�|jddd��|�|�ddd�|jdddd��|�|�dd�|jddd��|�t|�dd��t|jddd���|�t�d�j	i�t�dt
ddd��tjdt
ddd�d�tjdt
dd	�dd
�tjdddd�tjdt
ddd�ddd�g}|D]}|�|jd�|�|j	t
ddd��q�tj|ddd
did�}|�|j	d
d�|�
td��t�dd�Wd�n1s�wY|�
td��tjddd�Wd�dS1s�wYdS)Nz
<a>foo</a>r�)�pathr)r}r�r�#r�)r�r�)rq)r�)r�rr��key1�value1zmust be dict, not strzI'm not a dict)r7r�rtr�r�r�rvr�rsrqrbrMrQr�r�)r0r}�elementsr�r�rrr�test_issue14818Fs>
������"�zKeywordArgsTest.test_issue14818N)r:r;r<r�rrrrr|Csr|c@r()�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)rWrr
r�rrrrrhs
�zNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dSrV)rrrWrsr��types�FunctionTyperr�rrr�test_correct_import_pyETmsz*NoAcceleratorTest.test_correct_import_pyETN)r:r;r<rrr�rrrrr�gsr�cKstj|fi|��SrV)rW�canonicalize)r�rGrrr�c14n_roundtripwr'r�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>)rtr�rrrr�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>)rtrurtr�rrrr�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|vr�dd�|dd�d�D�}dd�|dd�d�D�}
nd}
}d�dd�t|�
��D��}|�|�d|�d����|dkr�|s�|�
d|���|d kr�|s�|�
d|���d|vr�|dd�d!�dur�|�
d"|����|d#�}|d$k�r$t�d%�d&��+}t|d&��}t�|���d'|����}Wd�n	1�swYWd�n	1�swYtj||	|
||
|d(�}t�|d#�d)d*d+��}|��}|d,k�rP|�d-d.�}|�d-d.�}Wd�n	1�s[wY|�||�Wd�n	1�sqwYqRqKdS)0Nzc14n-20rrcSs"g|]
}|�d�r|dd��qS)�.xmlNr�)�endswith�rO�filenamerrrrP�s�z+C14NTest.test_xml_c14n2.<locals>.<listcomp>cSsg|]	}|�d�r|�qS)�in)�
startswithr�rrrrP�s��cs8i|]}|�d�r|dd�t��|�d���D��qS)�c14ncSs,i|]}|j�d�d|jpd��|f�qS)�}r�r4)rM�splitrpr�)rO�optionrrr�
<dictcomp>s��z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<dictcomp>r�)r�r7rr�r�)�	full_pathrrr�s���z+C14NTest.test_xml_c14n2.<locals>.<dictcomp>cs"i|]
����fdd��D��qS)csJg|]!}|�d��d��r#|�dd�d�vr|�|�dd�df�qS)�out_rr�r�)r��rsplitr�)�configs�
input_filerrrPs��z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<listcomp>r)rO)r��files)r�rr�
s����cSsg|]	}|D]}|�qqSrr)rO�output_files�output_filerrrrPs���cSs|�||df�dS)Nrr�rd)�config�option_namer�rrr�
get_optionr�z+C14NTest.test_xml_c14n2.<locals>.get_option�IgnoreComments�true�
TrimTextNodes�
PrefixRewrite�
sequential�
QNameAwarecS�(g|]}d|�d��d|�d����qS��{�NSr��Namer�r�rrrrP(���r�z/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrcSr�r�r�r�rrrrP-r�z){http://www.w3.org/2010/xml-c14n2}Element�,css:�|]\}\}}|�d|pd�dd�|D����VqdS)�=r�css �|]}|j�d�dVqdS)r�r�N)rMr�)rOr�rrr�	<genexpr>7s�z4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>N)r)rOrfr�r�rrrr�6s
�
 �
�z*C14NTest.test_xml_c14n2.<locals>.<genexpr>�(�)�
inNsRedeclz2Redeclared namespace handling is not supported in �inNsSuperfluousz.{http://www.w3.org/2010/xml-c14n2}XPathElementz2QName rewriting in XPath text is not supported in r��inC14N5z	world.txtr=s&ent2;)�	from_file�
with_commentsr��rewrite_prefixes�qname_aware_tags�qname_aware_attrs�rr�r��inC14N3z attr="default"r4rV)rrr"r}rr��listdirrtru�valuesr�r�r�r�r�rr?r@rr!r7r�)r0�datadir�input_files�testsr�r�r�r�r��
keep_commentsr�r��qattrs�qtags�config_descrr�entity_filerpr�r)r�r�r�r�test_xml_c14n2�s��
�
�
�
����������

������
����
������zC14NTest.test_xml_c14n2)r:r;r<�maxDiffr�r�r�rrrrr�{s
(Pr�cCs6tddgd�a|dur
t}|attttttt	t
ttt
tttttttg}ttur-|�tg�ddlm}tjj}|��}|j}|��|_ttd�rQt�tjtj �}nd}z't!j"|�Wddlm}|�#�|�$|�||_|durutj|�daadSddlm}|�#�|�$|�||_|dur�tj|�daaw)Nr2r3)�blockedrr-�_set_factories)%rrWr7r)rrr>ror�rArpr�r�r�r�r�r�r[r�r|r�r�r�r/r.r��_namespace_mapr�r�r�r�rRr�r�run_unittestr�r�)�module�test_classesr.r��
nsmap_copyrs�
old_factoriesrrr�	test_main`sj���



�


r��__main__)Tr=rV)Rr�rrr?rryr"r^r]rtr�rrr%rrrrr�test.supportrrrr	r
r�test.support.import_helperr�test.support.os_helperr
rWr7r�r$�UnicodeEncodeErrorr
rr�r�r�r
rr
rrYrr&�TestCaser)rJrSrUr�r[r��format�escaper�r�r�rr>r�rl�__hash__rnror�r�r�r�r�rrrArpr|r�r�r�r�r:rrrr�<module>s�
�



	


 !w	
�	7fd48z`xT
$
f
E
�

Youez - 2016 - github.com/yon3zu
LinuXploit