403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.153
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_xml_etree.cpython-36.pyc
3

x2_���
@s>ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZdadaeddd�Zyejd�Wnek
r�ejd	��YnXed
dd�Zeddd�ZdZd
ZdZdZdZ dZ!Gdd�dej"�Z#d_dd�Z$dd�Z%Gdd�d�Z&Gdd�dej"�Z'Gdd�dej"�Z(iZ)d e)d!<d"e)d#<d$e)d%<d&e)d'<d(e)d)<d*e)d+<d,e)d-<d.e)d/<d0j*ej+ed��e)d1<iZ,d2e,d3<d4e,d5<Gd6d7�d7ej"�Z-Gd8d9�d9ej"�Z.Gd:d;�d;e&ej"�Z/Gd<d=�d=e&ej"�Z0Gd>d?�d?e1�Z2e1j3e2_3Gd@dA�dAe1�Z4e1j3e4_3GdBdC�dCe&ej"�Z5GdDdE�dEej"�Z6GdFdG�dGej"�Z7GdHdI�dIej"�Z8GdJdK�dKej"�Z9GdLdM�dMej"�Z:GdNdO�dOej"�Z;GdPdQ�dQej"�Z<GdRdS�dSej"�Z=GdTdU�dUej"�Z>GdVdW�dWej"�Z?GdXdY�dYej"�Z@GdZd[�d[eA�ZBd`d\d]�ZCeDd^k�r:eC�dS)a�N)�product)�support)�TESTFN�findfile�import_fresh_module�
gc_collect�	swap_attrz
simple.xmlZxmltestdata)Zsubdirzutf-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>
c@seZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree)�ElementInclude)�ElementPath)�	xml.etreer
rr)�selfr
rr�r�8/opt/alt/python36/lib64/python3.6/test/test_xml_etree.py�test_sanityeszModuleTest.test_sanitycCsd}tj|t|dd�dS)N�xml.etree.ElementTree�_elementtree�
HTML_EMPTY)Z	blacklist)rr)r)rZcheck__all__�ET)r�namesrrr�test_alllszModuleTest.test_allN)�__name__�
__module__�__qualname__rrrrrrr	dsr	T�unicodecKsX|dkrtj�}ntj�}tj|�}|j|fd|i|��|rF|j�S|jd�|SdS)Nr�encodingr)�io�BytesIO�StringIOrr
�write�getvalue�seek)�elem�	to_stringrZoptions�file�treerrr�	serializeqs


r'cCsdd�|D�S)NcSsg|]
}|j�qSr)�tag)�.0r#rrr�
<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.setUpClasscCs�tj|}z�y.|tj|<tj||�}|tj|<tj|�}Wn^tjk
r�}	z@ttdftdfg�}
t	j
d||
j||�|
j||�f�|	�WYdd}	~	XnXWd|tj|<X|S)NZcETr.z%Failed to round-trip %r from %r to %r)�sysr/�pickle�dumps�loads�
PicklingError�dictrr.rZ
TestFailed�get)r�obj�name�dumper�loader�protoZsave_mZtemp�resultZpeZhumanrrr�pickleRoundTrip�s



*zElementTestCase.pickleRoundTripcCs�|j|tjtjf�|j|tjtjf�|jtt|��tt|���x"t||�D]\}}|j||�qPWt	j
dddd�}|j||�||��dS)Nr(�tail�text�attrib)�assertIsInstancer�Elementr.�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)rZalice�bob�x�yZ
propertiesrrrrI�sz#ElementTestCase.assertEqualElementsN)rrr�classmethodr1r?rIrrrrr-�sr-c@s�eZdZdd�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�Zd7S)8�ElementTreeTestcCs|jt|�|�dS)N)rEr')rr#�expectedrrr�serialize_check�szElementTreeTest.serialize_checkcs��fdd���fdd������fdd��tjd�}�|�tj|�}�|j��tjdd	d
�}tj|�}�jt|�d�tjdd	d
�}�fdd
���|j��|j��|j��|j	��|j
��|j��|j��|j
��|j��|j��|j��|j��|j��|j��|j��|j��|j��fdd�}||jd��||jd��||jd��||jd���jtjtj��jtjtj�dS)NcsNt|�x$|D]}�jt|�dd|d�qW|d}|d}|dd�dS)N�z%expected one-character string, got %r)�msg�� r)rFrE)�string�charZ
new_string)rrr�check_string�s
z4ElementTreeTest.test_interface.<locals>.check_stringcsVt|�|j�}|j�}x|D]}||}qWd|d<�j|ddd|dd�dS)N�value�keyzexpected value string, got %r)rT)rF�keys�itemsrE)�mappingr\r]r[�item)rrr�
check_mapping�s
z5ElementTreeTest.test_interface.<locals>.check_mappingcs��jtj|�dd�t|�}x8d	D]0}�jt||�d|d��j||d|d�q"W�|j��|j�|jdk	r~�|j�|j	dk	r��|j	�x|D]}�|�q�WdS)
Nznot an element)rTr(rBrAr@zno %s memberzno %s visible by dir)r(rBrAr@)
�
assertTruerZ	iselement�dir�hasattrZassertInr(rBrAr@)�elementZdirelem�attrr#)�
check_elementr`rYrrrrf�s







z5ElementTreeTest.test_interface.<locals>.check_elementr(utägrZ)r[z^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callable)rT)rarc)�method)rrr�check_method�sz4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dS)N)�__next__)�it)rirr�
check_iter�sz2ElementTreeTest.test_interface.<locals>.check_iter�*)rrDr
�getroot�assertRegex�repr�append�extend�insert�remove�getchildren�find�iterfind�findall�findtext�clearr8�setr\r]�iter�itertext�getiteratorrE�XML�
fromstring�PI�ProcessingInstruction)rrdr&rlr)rfr`rirYrr�test_interface�sH	




















zElementTreeTest.test_interfacecCs�tjd�}|j|jd�d|_|j|jd�d|_|j|jd�|j|j�d|_|j|jd�d|_|j|jd�|j|j�d|_|j|jd�d|_|j|jd�|j|ji�dd	d
�|_|j|jdd	d
��ddd
�|_|j|jddd
��dS)Nr(�TagZTAG�TextZTEXTZTailZTAIL�b�d)�a�c�B�D)�A�C)rrDrEr(�assertIsNonerAr@rB)rrdrrr�test_set_attributes*
z"ElementTreeTest.test_set_attributecCs�tjd�}|j|d�tjd�}|j|�|j|d�|j|�|j|d�|jd|�|j|d�|j|�|j|g�|j|d�|j|�tjddd	�}|j|d
�tjd�}|j|�|j|d�|jd|�|j|d
�|j|�|j|d�|j|�|j|d
�|jt	��}|j|�WdQRX|j
t|j�d�|j|d
�|||g|dd�<|j|dd�|j
|dd�|d|dg�|j
|ddd�|d|dg�|dd�=|j|d
�dS)Nz<body><tag/></body>z<body><tag /></body>�tag2z<body><tag /><tag2 /></body>rz<body><tag2 /><tag /></body>r(rZ)r[z<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listrSz
<subtag />�	�)
rrrRrDrqrtrsrr�assertRaises�
ValueErrorrE�str�	exception)rr#�erdZ
subelement�cmrrr�test_simpleopssH









 "
zElementTreeTest.test_simpleopscCs:|jtjd�d�|jtjd�d�|jtjd�d�dS)Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)rRrr)rrrr�
test_cdataFszElementTreeTest.test_cdatacCs|tjtjd��}tj|d�}|j|jd�jd�|j|jd�jd�tjt	d�}|j|jd�jd�|j|jd�jd�dS)Nzutf-8)r%r(zsection/tagrdzelement/../empty-elementz
empty-element)
rr�
SAMPLE_XML�encoderr
rErvr(�SIMPLE_XMLFILE)rZ
stringfiler&rrr�test_file_initPszElementTreeTest.test_file_initcCsddlm}tjt�}x(td�D]}tj|�jdt|��q Wt	|j
�}x(td�D]}tj|�jdt|��qTW|jt	|j
�|�x(td�D]}tj|�jdt|��q�W|jt	|j
�|�x(td�D]}tj|�jdt|��q�W|j
t	|j
�d�dS)Nr)r�
z./�iXi�)r
rrrr��ranger
rvr�rF�_cacherEZ
assertGreaterZ
assertLess)rrr#�iZcache_len_10rrr�test_path_cache[s

zElementTreeTest.test_path_cachecCsZddl}tjd�}|j|�}|j|�}d|jd�_|j|d�|j|d�|j|d�dS)Nrz<tag>hello<foo/></tag>�bar�fooz<tag>hello<bar /></tag>z<tag>hello<foo /></tag>)�copyrr�deepcopyrvr(rR)rr��e1�e2�e3rrr�	test_copyjs


zElementTreeTest.test_copycCs"tjd�}|jd�|j|jdd�d�|jdd�|j|jd�d�tjddd�}|j|jd�d�|j|jddi�ddi}tjd|�}|j�|j|jd�d�|j|jddi�ddi}tjd|�}|j�|j|jd�d�|j|jddi�tjdddidd�}|j|jd�d�|j|jddi�tjd�}d|_|jd	d
�|jdd�|jtj|�d
�|jt	|j
��d	dg�|jt	|j��ddg�|j|jdd�d|jd<d|jd<|jtj|�d�tjd�}|jdd�|jdd�|jdd�|jdd�|jtj|�d�dS)Nr(r[�defaultrZ)r[�other�testZaa�testa�testval�testb�test2s-<test testa="testval" testb="test2">aa</test>Ztest1Ztestcs;<test testa="testval" testb="test1" testc="test2">aa</test>r��
r�z
r�z	

 r�z

s@<test a="&#10;" b="&#10;" c="&#09;&#10;&#10; " d="&#10;&#10;" />)r()r�r�)r�r�)rrDr8rEr{rBrzrA�tostring�sortedr\r])rr#rBrrr�test_attribvsT






zElementTreeTest.test_attribcCs�tjd�}ddi}|jd|�}|j|j|dd�|j|�|j|d�|j�|j|d�|j|�|j|d�|j||g�|j|d	�|g|dd�<|j|d�t	|g�|dd�<|j|d�dS)
Nr(r[rZr�zattrib aliasing)rTz!<tag><subtag key="value" /></tag>z<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
rrDZmakeelementZassertIsNotrBrqrRrzrr�tuple)rr#rB�subelemrrr�test_makeelement�s"


z ElementTreeTest.test_makeelementc
Cs�tjt�}tj�}|j|dd�|j|j�d�tjt�}tj�}|j|dd�|j|j�d�t	t��}|j
�}WdQRXtj�}|j|j
d�|j|�|j|j�d�tj�}tj|d�}|j|�|j|j�d�dS)Nr)rzi<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�rrr rEr!�SIMPLE_NS_XMLFILE�open�read�	XMLParserro�version�feedrR�close�TreeBuilder)rr&�stream�f�data�parserr�rrr�test_parsefile�s,








zElementTreeTest.test_parsefilecCs�tjd�}|jtj|dd�d�tjd�}|jtj|dd�d�dddg}tj|�}|jtj|�d�|jdjtj|��d�|jtj|d	�d
�tjd�\}}|jt	|�d�tjd�\}}|jt	|�d
�|j|dj
d�dS)Nz<html><body>text</body></html>r)rz<html><body>ztext</boz
dy></html>s<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>rS�body)rrrEr�r�Zfromstringlist�join�tostringlistZXMLIDrFr()rrdZsequence�_Zidsrrr�test_parseliteral�s&



z!ElementTreeTest.test_parseliteralc;Cs@tj}|t�}t|�\}}|j||jfd$�|jdd�|D�d%d&d'g�|j|jjd�|t�}|jdd�|D�d(d)d*d+g�f}|t|�}|jdd�|D�g�f}|t|d�}|jd
d�|D�g�d,}|t|�}|jdd�|D�d-d.d/d0d1d2d3d4g�d5}|t|�}|jdd�|D�d7d8d9d:d;d<d=d>d?d@g
�dA}|tj	d�|�}dd�|D�}|j|ddg�dB}t
td��2}|jt��}|||�WdQRX|j
|j�WdQRX|jt|j�d�tj|��:|jt��}|t|�WdQRX|jt|j�d�~WdQRXtjd�}	dC}||	|�}|jdd�|D�dEdGg�tj	d�}	||	�}
t|
�\}}|j||jfdH�|jtj��}t|
�WdQRX|jt|j�d!�|jtjt�t
td"��}|jd#�WdQRX|t�}
t|
�\}}|j||jfdI�tj|��<|jtj��}t|
�WdQRX|jt|j�d!�~~
WdQRXdS)JN�endrdcSsg|]\}}||jf�qSr)r()r)�actionr#rrrr*sz2ElementTreeTest.test_iterparse.<locals>.<listcomp>�
empty-element�rootcSsg|]\}}||jf�qSr)r()r)r�r#rrrr*s�{namespace}element�{namespace}empty-element�{namespace}rootcSsg|]\}}||jf�qSr)r()r)r�r#rrrr*s)�eventscSsg|]\}}||jf�qSr)r()r)r�r#rrrr*!s�startcSsg|]\}}||jf�qSr)r()r)r�r#rrrr*%s�start-ns�end-nscSs*g|]"\}}|dkr||jfn||f�qS)r�r�)r�r�)r()r)r�r#rrrr*2srU�	namespacez<root xmlns=''/>cSsg|]\}}|�qSrr)r)r�r#rrrr*Cs�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>
cSsg|]\}}||f�qSrr)r)r�r#rrrr*Ys�http://éffbot.org/ns�clé�http://effbot.org/nsz<document />junk�documentz.junk after document element: line 1, column 12�wbs<document />junk)r�rd)r�rd)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�rd)r�rd)r�rd)r�rd)r�r�)r�r�)r�r�)r�r�r�r��rUr�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�N)r�r�)r�r�r�)r��rUr�)r�r��r�r�)r�r�)r�r�)r�r�)r�	iterparser��nextrEr(r�r�rrr�r�r��assertFalse�closedr�r�rZcheck_no_resource_warningr�
ParseError�
addCleanup�unlinkrr )rr��contextr�r#r��resr�r��sourcerkrrr�test_iterparses�





zElementTreeTest.test_iterparsecCs�tjd�}d|_|j|d�dtj|d�_|j|d�d|_|j|d�|jdtjd	��|j|d
�tjdd�|d<|j|d
�dS)Nr(rAz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>r[rZz)text<?key value?><subtag>subtext</subtag>)	rrDrArR�
SubElementr(rs�Commentr�)rr#rrr�test_writefilets
zElementTreeTest.test_writefilecCs�tt��}|j�}WdQRXGdd�dt�}|�}tj|d�}|j|�|j|ddddddddg�tt��}|j�}WdQRXGd	d�dt�}|�}tj|d�}|j|�|j|dddddddd d!d"g
�dS)#Nc@s$eZdZdd�Zdd�Zdd�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|jd|f�dS)Nr�)rq)rr(rBrrrr��sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|jd|f�dS)Nr�)rq)rr(rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rrArrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)rrrr�r�r�rrrr�Builder�sr�)r�r�r�rdr��
empty-elementc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|jd|f�dS)Nr�)rq)rr(rBrrrr��sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|jd|f�dS)Nr�)rq)rr(rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rrArrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.datacSs|jd||f�dS)N�pi)rq)rr�r�rrrr��sz7ElementTreeTest.test_custom_builder.<locals>.Builder.picSs|jd|f�dS)Nr�)rq)rr�rrrr��sz<ElementTreeTest.test_custom_builder.<locals>.Builder.commentN)rrrr�r�r�r�r�rrrrr��s
r�r�r��	 comment �{namespace}root�{namespace}element�{namespace}empty-element)r�r�)r�rd)r�rd)r�rd)r�rd)r�r�)r�r�)r�r�)r�r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r�)	r�r�r�rGrr�r�rEr�)rr�r�r�Zbuilderr�rrr�test_custom_builder�s@



z#ElementTreeTest.test_custom_builderc
Cslttd��}tj|�}WdQRX|jdd�|j�j�D�dddggggg�|jdd�|j�D�dddggggg�tjt	�}|jt
|j��d�|jt
|dj��d	�|j|dd�|j��|d
}|d}|d	d�=|jt
|j��d�|j||d
�|j||d	�||g|d
d�<|j||d
�|j||d	�|j||d
�|j
�|j|j�g�dS)Nr�cSsg|]}t|j���qSr)r,ru)r)r#rrrr*�sz4ElementTreeTest.test_getchildren.<locals>.<listcomp>rdz
empty-elementcSsg|]}t|j���qSr)r,ru)r)r#rrrr*�s�r�rSr)r�r�rr�rErnr|r~rr�rFru�assertNotEqualrz)rr�r&r#Zchild1Zchild2rrr�test_getchildren�s<




z ElementTreeTest.test_getchildrencCs<tjd�}|jtj|�d�tjd�}|jtj|�d�dS)Nz<html><body>text</body></html>s<html><body>text</body></html>)rrrEr�r�)rr#rrr�test_writestring�s

z ElementTreeTest.test_writestringcCs�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}x(|D] }�jtjtj||���dS�q�WdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddeg}x"|D]}�jttj||���q@Wdfdgdhdidjdkdldmdndog
}x$|D]}�jtjtj||���q|W�jttj�dp�jd���jttj�dq�jd��dS)sNrUcs>d||f}�jtj|j|��j|��jtj|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)rErrr�rA)rr��xml)rrr�check�s
z,ElementTreeTest.test_encoding.<locals>.checkr�r�zus-asciiz
iso-8859-1�½ziso-8859-15u€�cp437u√z	mac-romanu˚cSsd|S)Nz*<?xml version='1.0' encoding='%s'?><xml />r)rrrrr�sz*ElementTreeTest.test_encoding.<locals>.xmlcs�|�j|�S)N)r�)r)rrr�bxml�sz+ElementTreeTest.test_encoding.<locals>.bxmlzutf-8z	utf-8-sigzutf-16zutf-16bezutf-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)rU)	rErr�rr�r�r�r��LookupError)rrrZsupported_encodingsrZ&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr)rrr�
test_encoding�sR








 


zElementTreeTest.test_encodingcCsttjd�}d|_|jt|�d�|jt|dd�d�|jt|dd�d�|jt|dd�d�|jt|dd�d	�dS)
Nz-<html><link/><script>1 &lt; 2</script></html>�
z/<html><link /><script>1 &lt; 2</script></html>
)rhr�htmlz*<html><link><script>1 < 2</script></html>
rAz1 < 2
)rrr@rEr')rr�rrr�test_methods#s

zElementTreeTest.test_methodscCs2tjd�}|jt|�d�|jt|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>r8)rh)rrrEr')rr�rrr�test_issue183472s


zElementTreeTest.test_issue18347cCs�tjd�}|jt|dd�d�|j|d�|jtj��}tjd�WdQRX|jt|j�d�|jtj��}tjt	�WdQRX|jt|j�d�tj
�}d	|jd
<|jt	�|j
�}|j|d�|jtj��}tjt�WdQRX|jt|j�d�dS)
Nz*<document title='&#x8230;'>test</document>zus-ascii)rs*<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 10rA�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)rrrEr'rRr�r�r�r��
ENTITY_XMLr�r;r�r��EXTERNAL_ENTITY_XML)rr�r�r�r�rrr�test_entity9s*


zElementTreeTest.test_entitycCsrtjd�}|j|d�tjd�}|j|d�tjd�}|j|d�tjd�}|j|d�tjt�}|j|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>)rrrR�
SAMPLE_XML_NS)rr#rrr�test_namespace^s




zElementTreeTest.test_namespacecCs�tjd�}|j|d�tjtjd��}|j|d�tjtjdd��}|j|d�tjtjdd��}tj|tjdd��}tj|tjdd��}|j|d�|j�d|jd	<|j|d
�|j�d|jtjd	�<|j|d
�|j�d|jd	<|j|d�|j�tjd�|jd	<|j|d
�|j�tjd�}tjd�|jd<|j|�|j|�|j|d�|jt	tjdd��d�|jt	tjd��d�tjdd�}tjdd�}|j||�tjdd�}|j
||�|j
|d�|j|d�dS)Nz{uri}tagz<ns0:tag xmlns:ns0="uri" />Zurir(Ztag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>rZz{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)rrDrR�QNamer�rzrBrqrEr�r)rr#r�Zq1Zq2rrr�
test_qnamesV





zElementTreeTest.test_qnamecCstjd�}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>)rr)rr#rrr�test_doctype_public�sz#ElementTreeTest.test_doctype_publiccsrddlm���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/g�|d0d"dd1g�|d2d"dd/g�dS)3Nr)rcs �jdd��j|�D�|�dS)NcSsg|]\}}|p|�qSrr)r)�opr(rrrr*�szGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)rEZxpath_tokenizer)�prQ)rrrrr�s
z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkrmztext()rAz()z@name�@r:z@*zpara[1]Zpara�[�1�]zpara[last()]Zlastz*/para�/z/doc/chapter[5]/section[2]�docZchapter�5�section�2z
chapter//paraz//z//paraz//olist/itemZolistr_�.z.//paraz..z../@langZlangzchapter[title]�titlez#employee[@secretary and @assistant]ZemployeeZ	secretaryrU�andZ	assistantz{http://spam}eggz
./spam.eggzspam.eggz.//{http://spam}egg)r
r)rrr)rrr�test_xpath_tokenizer�s2z$ElementTreeTest.test_xpath_tokenizercCsn|jtjtjdd��d�|jtjtjdd��d�|jtjtjdd��d�|jtjtjdd�d�d�dS)	Nr�Zinstructions<?test instruction?>z
<testing&>s<?test <testing&>?>u<testing&>ãzlatin-1s=<?xml version='1.0' encoding='latin-1'?>
<?test <testing&>�?>)rErr�r�r�)rrrr�test_processinginstruction�sz*ElementTreeTest.test_processinginstructionc
CsxxrdD]j}xd||j�gD]T}d|}ttjd|�dd�}|j||�ttjd||f�dd�}|j||�qWqWdS)N�AREA�BASE�BASEFONT�BR�COL�FRAME�HR�IMG�INPUT�ISINDEX�LINK�META�PARAMz<%s>z<%s />r8)rhz	<%s></%s>)
rUrVrWrXrYrZr[r\r]r^r_r`ra)�lowerr'rrrE)rrdr#rQZ
serializedrrr�#test_html_empty_elems_serialization�sz3ElementTreeTest.test_html_empty_elems_serializationN)rrrrRr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr6r9r:r>r@rCrDrSrTrcrrrrrP�s6X)
5-p8%;%!A#rPc@sVeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�XMLPullParserTestNcCsH|dkr|j|�n0x.tdt|�|�D]}|j||||��q&WdS)Nr)r�r�rF)rr�r��
chunk_sizer�rrr�_feedszXMLPullParserTest._feedcCs"|j�}|jdd�|D�|�dS)NcSsg|]\}}||jf�qSr)r()r)r�r#rrrr*sz7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)�read_eventsrE)rr�rQr�rrr�assert_event_tagssz#XMLPullParserTest.assert_event_tagsc
Cs�x�dD]�}|j|d���tj�}|j|g�|j|d|�|j|g�|j|d|�|j|g�|j|d|�|j|dg�|j|d	|�|j|d
|�|j|ddg�|j|d|�|j|dg�|j|j��WdQRXqWdS)NrS�)rez<!-- comment -->
z+<root>
  <element key='value'>text</elementz>
r�rdz<element>text</element>tail
z<empty-element/>
�
empty-elementz</root>
r�)NrSri)r�rd)r�rd)r�rj)r�r�)�subTestr�
XMLPullParserrhrfr�r�)rrer�rrr�test_simple_xmls(
z!XMLPullParserTest.test_simple_xmlc	Cs�tj�}|j�}|j|d�t|�\}}|j||jfd�|j|d�t|�\}}|j||jfd�|jt��t|�WdQRXdS)Nz-<root>
  <element key='value'>text</element>
r�rdz</root>
r�)r�rd)r�r�)	rrlrgrfr�rEr(r��
StopIteration)rr�rkr�r#rrr�test_feed_while_iterating.sz+XMLPullParserTest.test_feed_while_iteratingcCs�tj�}|j|g�|j|d�|j|g�|j|d�|j|g�|j|d�|j|g�|j|d�|j|dg�|j|d�|j|d�|j|d
dg�|j|d
�|j|dg�|j|j��dS)Nz<!-- comment -->
z<root xmlns='namespace'>
z"<element key='value'>text</elementz>
r��{namespace}elementz<element>text</element>tail
z<empty-element/>
�{namespace}empty-elementz</root>
�{namespace}root)r�rp)r�rp)r�rq)r�rr)rrlrhrfr�r�)rr�rrr�test_simple_xml_with_ns:s$z)XMLPullParserTest.test_simple_xml_with_nscCs�tjd
d�}|j|d�|j|d�|jt|j��dg�|j|d�|j|d	�|j|d
�|j|d�|j|d�|jt|j��dg�|j|j��dS)N�start-ns�end-ns)r�z<!-- comment -->
z<root xmlns='namespace'>
rUr�z"<element key='value'>text</elementz>
z<element>text</element>tail
z<empty-element/>
z</root>
)rtru�rUr�)rtrv)ruN)rrlrfrErGrgr�r�)rr�rrr�test_ns_eventsOs
z XMLPullParserTest.test_ns_eventscCs�tjfd�}|j|d�|j|g�tjdd�}|j|d�|j|g�|j|d�|j|dg�|j|d�|j|dg�|j|d
�|j|dg�|j|d�|j|ddddg�|j|d�|j|j��|j|dg�tjdd�}|j|d�|j|g�|j|d�|j|dg�|j|d�|j|dg�|j|d
�|j|g�|j|d�|j|ddg�|j|d�|j|j��dS)N)r�z<root/>
r�r�z<!-- comment -->
z<root>
r�z"<element key='value'>text</elementrdz>
z8<element xmlns='foo'>text<empty-element/></element>tail
�{foo}element�{foo}empty-elementz</root>)r�r�)r�r�)r�rd)r�rd)r�rx)r�ry)r�ry)r�rx)r�r�)r�)r�r�)r�rd)r�rx)r�ry)rrlrfrhr�r�)rr�rrr�test_events^sLzXMLPullParserTest.test_eventscCslddh}tj|d�}|j|d�|j|dd	g�Gdd�d�}tj|�d�}|j|d�|j|d
dg�dS)Nr�r�)r�z<foo>bar</foo>r�c@s$eZdZdd�Zdd�Zdd�ZdS)z9XMLPullParserTest.test_events_sequence.<locals>.DummyItercSstdddg�|_dS)Nr�r�zstart-ns)r|r�)rrrr�__init__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__cSs|S)Nr)rrrr�__iter__�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__cSs
t|j�S)N)r�r�)rrrrrj�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)rrrr{r|rjrrrr�	DummyIter�sr})r�r�)r�r�)r�r�)r�r�)rrlrfrh)rZeventsetr�r}rrr�test_events_sequence�sz&XMLPullParserTest.test_events_sequencecCs&|jt��tjdd�WdQRXdS)Nr�r�r�)r�)r�r�r�)r�r�rrl)rrrr�test_unknown_event�sz$XMLPullParserTest.test_unknown_event)N)rrrrfrhrmrorsrwrzr~rrrrrrd	s
,rdz�<?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>
zC1.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>
zC2.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>
zC2b.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>
zC3.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>
zC5.xmlz�<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>Example.</p>
  <xi:include href="{}"/>
</document>
zdefault.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>
zB1.xmlzn<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:fallback></xi:fallback>
</div>
zB2.xmlc@s@eZdZddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)�XIncludeTestrNcCs@yt|}Wntk
r(td��YnX|dkr<tj|�}|S)Nzresource not foundr)�XINCLUDE�KeyError�OSErrorrr)r�hrefr�rr�rrr�xinclude_loaders
zXIncludeTest.xinclude_loadercCsdS)Nr)rr�r�rrrr�none_loaderszXIncludeTest.none_loaderc	Cs2|dkr*t|d��}tj|�j�SQRXndSdS)Nrr�)r�rr�rn)rr�r�r�rrr�
_my_loaderszXIncludeTest._my_loadercCs8ddlm}|jd�}|j||j�|jt|�d�dS)Nr)rzdefault.xmlz�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r
rr��includer�rEr')rrrLrrr�test_xinclude_defaults


z"XIncludeTest.test_xinclude_defaultc
Csddlm}|jd�}|j||j�|jt|�d�|jd�}|j||j�|jt|�d�|jd�}|j||j�|jt|�d�|jd	�}|j||j�|jt|�d
�|jd�}|jt��}|j||j�WdQRX|jt|j	�d�|jt|�d
�dS)Nr)rzC1.xmla<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>zC2.xmlzO<document>
  <p>This document has been accessed
  324387 times.</p>
</document>zC2b.xmlzX<document>
  <p>This document has been <em>accessed</em>
  324387 times.</p>
</document>zC3.xmlz�<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>zC5.xmlzresource not foundaI<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�rEr'r�r�r�r�)rrr�r�rrr�
test_xinclude(s.










zXIncludeTest.test_xincludec Cs0ddlm}tjtd�}|j|j��}|j||jd�WdQRX|j	t
|j�d�tjtd�}|j|j��}|j||jd�WdQRX|j	t
|j�d�tjtd�}|j|j��}|j||jd�WdQRX|j	t
|j�d	�tjtd
�}|j|j��}|j||jd�WdQRX|j	t
|j�d�dS)Nr)rzC1.xml)r<z%cannot load 'disclaimer.xml' as 'xml'zC2.xmlz!cannot load 'count.txt' as 'text'zB1.xmlz1unknown parse type in xi:include tag ('BAD_TYPE')zB2.xmlzYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback'))
r
rrrr�r�ZFatalIncludeErrorr�r�rEr�r��XINCLUDE_BAD)rrr�r�rrr�test_xinclude_failureshs*z#XIncludeTest.test_xinclude_failures)rN)N)	rrrr�r�r�r�r�r�rrrrr�s
	
	@r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zej
ej�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�}tjd�}||�tjd�}d|_||�tjd�}d|_||�tjd�}|jdd�||�tjd�}|jdd�||�dS)Nc
s4�jt��}t|�WdQRX�jt|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorr'rEr�r�)r#r�)rrrr�sz-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r#Z123)rrDrAr@r{)rrr#r)rr�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<tjt�}tj|�}|j|jd�d�|j|jd�d�dS)Nr(rAzsection/tagr�)rrr�r
rEry)rr#r&rrr�test_bug_xmltoolkit25�s

zBugsTest.test_bug_xmltoolkit25cCs<tjd�}|jt|jd��g�|jt|jd��dg�dS)Nz"<doc><table><tbody/></table></doc>z.//theadz.//tbodyZtbody)rrrEr,rx)rr&rrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28c
Cs<tjd�}tj�� }tj|�|j|j�d�WdQRXdS)Nz"<doc><table><tbody/></table></doc>z$<doc><table><tbody /></table></doc>
)rrrZcaptured_stdout�dumprEr!)rr&�stdoutrrr�test_bug_xmltoolkitX1�s


zBugsTest.test_bug_xmltoolkitX1cCs�tjd�}|jtj|d�d�tjd�}|j|jddi�|jtj|d�d�tjd�}|jtj|d�d	�tjd
�}|jtj|d�d�tjd�}|jdd�|jtj|d�d�dS)Ns2<?xml version='1.0' encoding='iso-8859-1'?><t�g />zutf-8s<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>utägr()rrrEr�rBrDr{)rr&rrr�test_bug_xmltoolkit39�s




zBugsTest.test_bug_xmltoolkit39cCs2tjd�}|jt|dd�d�|jt|�d�dS)Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>zus-ascii)rs<doc>&#33328;</doc>u<doc>舰</doc>)rrrEr')rr�rrr�test_bug_xmltoolkit54�s
zBugsTest.test_bug_xmltoolkit54c
Cs8|jtj��}tjd�WdQRX|jt|j�d�dS)Ns?<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>z+undefined entity &ldots;: line 1, column 36)r�rr�rrEr�r�)rr�rrr�test_bug_xmltoolkit55�szBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|jttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�dS)N)r�)rrMrrrr��sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)rrrr�rrrr�
ExceptionFile�sr�)r�r�rr�)rr�rrr�test_bug_xmltoolkit60�szBugsTest.test_bug_xmltoolkit60cCsHddd�}tj�}|jj|�|jd�|j�}|j|jd�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’.)	rr�r;�updater�r�rErvrA)rZENTITIESr��trrr�test_bug_xmltoolkit62�s
zBugsTest.test_bug_xmltoolkit62zSkips under coverage.cCsFdd�}|�tjd�}xtd�D]
}|�q"W|jtjd�|�dS)NcSs,tj�}|jdi�|jd�|jd�dS)Nr(rA)rr�r�r�r�)r&rrr�xmltoolkit63s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)r2�getrefcountr�rE)rr��countr�rrr�test_bug_xmltoolkit63s

zBugsTest.test_bug_xmltoolkit63cCs`tjddd�}|jtj|�d�|jtjtj|��jd�d�|jtjtjtj|���d�dS)NZSomeTagzdef _f():
  return 3
)rAs0<SomeTag text="def _f():&#10;  return 3&#10;" />rA)rrDrEr�rr8)rr�rrr�test_bug_200708_newlinesz BugsTest.test_bug_200708_newlinecCs^tj�}|jd�|j|j�jd�Gdd�d�}tj|��}|jd�|j|j�jd�dS)Nz<element>some text</element>rdc@seZdZdd�ZdS)z2BugsTest.test_bug_200708_close.<locals>.EchoTargetcSs
tjd�S)Nrd)rrD)rrrrr�'sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN)rrrr�rrrr�
EchoTarget&sr�)rr�r�rEr�r()rr�r�rrr�test_bug_200708_closes

zBugsTest.test_bug_200708_closecCs�tjd�}tj|d�}|jt|dd�d�tjd�}tj|d�}tj|d�}|jt|dd�d�tjd�}tj|d�}tj|d�}|jt��}t|dd�WdQRX|jt|j�d�dS)	Nz
{default}elemr�)Zdefault_namespacez%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>r#z<cannot use non-qualified names with default_namespace option)	rrDr�rEr'r�r�r�r�)rr��sr�rrr�!test_bug_200709_default_namespace-s 


z*BugsTest.test_bug_200709_default_namespacecCsdtjd�}|jtj|�d�tjdd�tjd�}|jtj|�d�tjd�}|jtj|�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/" />)rrDrEr��register_namespace)rr�rrr�"test_bug_200709_register_namespaceDs


z+BugsTest.test_bug_200709_register_namespacecCs`tjd�}|jtjd��|j|djtj�tjd�}|jtjd��|j|djtj�dS)Nr�r�r)rrDrqr�rEr(r�)rr�rrr�test_bug_200709_element_commentSs

z(BugsTest.test_bug_200709_element_commentcCsvtjd�}tj|d�}tj|d�}tjd�}|jd|�|jt|�dddg�|jd|�|jt|�ddddg�dS)Nr�r�r�r�rrS���)rrDr�rsrEr,)rr�r�r�r�rrr�test_bug_200709_element_insert_s

z'BugsTest.test_bug_200709_element_insertcCsJtjd�}tj|d�}tjd�}|j|�|jt|jtj��tjg�dS)Nr�r�zTEST-b)rrDr�r�rqrEr,r|)rr�r�Z	comment_brrr�test_bug_200709_iter_commentis



z%BugsTest.test_bug_200709_iter_commentcCsDtj�}|jd�}|jdi�}|jd�}|j�}|jt|�d�dS)Nr�r(z<tag />)rr�r�r�r�r�rEr')rrLr�rrr�test_bug_1534630ss

zBugsTest.test_bug_1534630cCs@tjd�}|jtj|d�d�tjd�}|jtj|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>)rrrEr�)rr�rrr�test_issue6233{s

zBugsTest.test_issue6233cCs8tjd�}|j|jd�tj|�}|jtj|�d�dS)Nz+<prefix:localname xmlns:prefix="${stuff}"/>z{${stuff}}localnames&<ns0:localname xmlns:ns0="${stuff}" />)rrrEr(r
r�)rr�r�rrr�test_issue3151�s

zBugsTest.test_issue3151cCsTtjd�}|jt|�dg�tjt�}|dd�|dd�<|jt|�dddg�dS)Nz<body><tag/></body>r(rN)rrrEr,r�)rr#Znewelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCstjdd�tjdd�dS)NZ	test10777z
http://myuri/)rr�)rrrr�test_issue10777�szBugsTest.test_issue10777cs`G�fdd�d�}tjd��|��_�j�}t|�}|j||�|j�jt�|j�jd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_text.<locals>.Textcs
d�_dS)N�changedT)rA)r)r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N)rrrr�r)r�rrr��sr�r(r�)rrDrAr}r�rCr�rE)rr�r�r�r)r�r�test_lost_text�s
zBugsTest.test_lost_textcs|G�fdd�d�}tjd���jtjd��|��d_�j�}t|�}|j||�|j�djt�|j�djd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_tail.<locals>.Textcsd�d_dS)Nr�rT)r@)r)r�rrr��s
z.BugsTest.test_lost_tail.<locals>.Text.__bool__N)rrrr�r)r�rrr��sr�r�r(rr�)	rrDrqr@r}r�rCr�rE)rr�r�r�r)r�r�test_lost_tail�s
zBugsTest.test_lost_tailcs�G��fdd�d�}tjd���jtj|����jtjd���jd��yt��}Wntk
rt|jd�YnX|j|j|�|j�djt	�|j
�djd�dS)NcseZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcstjd��d<t��dS)Nr�rT)rrDr�)rr�)r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N)rrrr�r)r�r�rrr��sr�r�r(zgenerators are not reentrantrr�)rrDrqr|r�r�ZskipTestrCr(r�rE)rr�r�r)r�r�r�test_lost_elem�s

zBugsTest.test_lost_elemcCs.d|}tj|�}|j|jd�|jd��dS)Ns<a b="%s"/>r�zutf-8)rrrEr8�decode)rrArr�rrr�check_expat224_utf8_bug�s
z BugsTest.check_expat224_utf8_bugcCs,dd}|j|�ddd}|j|�dS)Nsài�x)r�)rrArrr�test_expat224_utf8_bug�s
zBugsTest.test_expat224_utf8_bugc
Csnttd��}|j�}WdQRXtj|�}|jd�}|jd�j�}|jdd�}|dd�}|j	|jd�|�dS)	Nr�r�zutf-8z
rV�����)
r��UTF8_BUG_XMLFILEr�rr�r8r��strip�replacerE)r�fp�rawr�ZxmlattrrArrr�test_expat224_utf8_bug_file�s

z$BugsTest.test_expat224_utf8_bug_fileN)#rrrr�r�r�r�r�r�r�r�r��unittestZskipIfr2�gettracer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr��s8			

r�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BasicElementTestcCsJtjd�}|jt|jd�|jt|jtjd�dg�|jt|jdd�dS)N�joer�r�r�r)rrDr�r�rqrrrs)rr�rrr�test_augmentation_type_errors�s
z.BasicElementTest.test_augmentation_type_errorscCs�Gdd�d�}|�}tjd|d�|_tj|�}~t�|j|��tjd�}|�}||_tj|�}tj|d|d�}~~~t�|j|��tjd�}tjd�}tjd�}|j|�|j|�|j|�tj|�}~~~t�|j|��dS)	Nc@seZdZdS)z.BasicElementTest.test_cyclic_gc.<locals>.DummyN)rrrrrrr�Dummy�sr�r�)rer�r�r�r�)	rrDZdummyref�weakref�refrr�r�rq)rr�r��wrefr�r�r�r�rrr�test_cyclic_gc�s2









zBasicElementTest.test_cyclic_gccsVd��fdd�}tjd�}tj||�}|j|�jd�~|j�d�|j|�d�dS)NFcsd�dS)NTr)�w)�flagrr�wref_cbsz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)rrDr�r�rEr()rr�r�r�r)r�r�test_weakrefs
zBasicElementTest.test_weakrefcCsBtjddddd�}|j|jddd�d�|j|jd	dd�d�dS)
Nr�rSr�r)rMrN�zrM�)r�r�)rrDrEr8)rr�rrr�test_get_keyword_args'sz&BasicElementTest.test_get_keyword_argscCs�x�tdtjd�D]�}x�t|jdd�D]�\}}|jddd�}d|_d|_|j|d	�j	|jd
��|j	|jd	��|j
d�djd
d�|j|d|||�}|j
|jd�|j
|jdd�|j
t|�d�|j||�q&WqWdS)Nr�rS)�repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrrezother valuezxml.etree.ElementTreer�)r�r3�HIGHEST_PROTOCOLrr/rDrAr@r�rqrxr{r?rEr(rBrFrI)rr=r;r<r�r�rrr�test_pickle,s
zBasicElementTest.test_picklecCs�x�tdtjd�D]~}xxt|jdd�D]f\}}d}|j|�}t|d�rZ|j|j�dd�|j	|d|||�}|j|j
d�|j|d	j
d
�q&WqWdS)Nr�rS)r�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r(�groupzxml.etree.ElementTreerZdogs)r�r3r�rr/r�rcrEr�r?r()rr=r;r<ZXMLTEXTr�r�rrr�test_pickle_issue18997?s


z'BasicElementTest.test_pickle_issue18997N)	rrrr�r�r�r�r�r�rrrrr��s#r�c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BadElementTestc
s~G�fdd�d�}|�g�tjd�}y|j��Wntk
rFYnXGdd�d|tj�}|d�g�tjd�}|j��dS)NcseZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcstjd�g�dd�<tjS)N�baz)rrD)r)�Lrr�	__class__Qsz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N)rrr�propertyr�r)r�rr�XPsr�r�c@seZdZdS)z2BadElementTest.test_extend_mutable_list.<locals>.YN)rrrrrrr�Y\sr�rM)rrDrrr�)rr�r�r�r)r�r�test_extend_mutable_listOs


z'BadElementTest.test_extend_mutable_listc
s�G�fdd�d�}|�tjd�g�tjd�}y|j��Wntk
rNYnXGdd�d|tj�}|d�tjd�g�tjd�}|j��dS)NcseZdZe�fdd��ZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjS)N)rrD)r)r�rrr�ds
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__N)rrrr�r�r)r�rrr�csr�r�r�c@seZdZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.YN)rrrrrrrr�osr�r�)rrDrrr�)rr�r�r�r)r�r�test_extend_mutable_list2bs

z(BadElementTest.test_extend_mutable_list2cszG�fdd�dtj�}tjd���j|d�g�|jt�jtjd��tjd���jtjd�g�|jt�j|d��dS)NcseZdZ�fdd�ZdS)z3BadElementTest.test_remove_with_mutating.<locals>.Xcs�dd�=dS)NFr)r�o)r�rrr�ws
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__N)rrrr�r)r�rrr�vsr�r�r�r�)rrDrrr�r�rt)rr�r)r�r�test_remove_with_mutatingus

z(BadElementTest.test_remove_with_mutatingcCsDtjd�}t|d|��$|jt��t|�WdQRXWdQRXdS)Nr�r()rrDrr��RuntimeErrorrp)rr�rrr�test_recursive_repr�s
z"BadElementTest.test_recursive_reprcsnG�fdd�dt�}tj�}|jdi�|jd�|j|d��|jd�|jd�|j��|j�jd�dS)NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_text.<locals>.Xcs$y
�jWntk
rYnXdS)N)rA�	NameError)r)r#rr�__del__�s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N)rrrr�r)r#rrr��sr�r(�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�rr�r�r�r�r�rErA)rr�r�r)r#r�test_element_get_text�s


z$BadElementTest.test_element_get_textcs�G�fdd�dt�}tj�}|jdi�|jdi�|jd�|jd�|j|d��|jd�|jd�|j��|j�djd	�dS)
NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_tail.<locals>.Xcs(y�djWntk
r"YnXdS)Nr)r@r�)r)r#rrr��sz7BadElementTest.test_element_get_tail.<locals>.X.__del__N)rrrr�r)r#rrr��sr�r�r(r�r�r�rr�)	r�rr�r�r�r�r�rEr@)rr�r�r)r#r�test_element_get_tail�s



z$BadElementTest.test_element_get_tailcCspddgdddd�}tjd�}y|j|�Wntk
rD||_YnX|j�}|jt|�|�|jtt|�dS)Nr(rer@rA)r(Z	_childrenrBr@rA)	rrD�__setstate__�AttributeError�__dict__r|ZassertIsr�r�)r�stater�rkrrr�test_element_iter�s
z BadElementTest.test_element_itercs^G�fdd�d�}tjd���jtjd���d|���jtjd���dd|��dS)NcseZdZ�fdd�ZdS)z%BadElementTest.test_subscr.<locals>.Xcs�dd�=dS)NrSr)r)r�rr�	__index__�s
z/BadElementTest.test_subscr.<locals>.X.__index__N)rrrr�r)r�rrr��sr�r#r�rr�)rrDrq)rr�r)r�r�test_subscr�s
zBadElementTest.test_subscrcsTG�fdd�d�}tjd��x"td�D]}�jdtjd��q&Wg�dd|��<dS)NcseZdZ�fdd�ZdS)z)BadElementTest.test_ass_subscr.<locals>.Xcsg�dd�<dS)NrSr)r)r�rrr��sz3BadElementTest.test_ass_subscr.<locals>.X.__index__N)rrrr�r)r�rrr��sr�r#r�rr�)rrDr�rs)rr�r�r)r�r�test_ass_subscr�s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|jdi�|jd�|jt|jdi�~t�dS)NcSsgS)Nr)rMrNrrr�element_factory�sz>BadElementTest.test_treebuilder_start.<locals>.element_factory)r�r(r�r�)rr�r�r�r�r�r)rr�r�rrr�test_treebuilder_start�s
z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|jdi�|jd�|jt|jd�~t�dS)NcSsgS)Nr)rMrNrrrr��sz<BadElementTest.test_treebuilder_end.<locals>.element_factory)r�r(r�)rr�r�r�r�r�r�r)rr�r�rrr�test_treebuilder_end�s
z#BadElementTest.test_treebuilder_endN)rrrr�r�r�r�r�r�r�r�r�r�r�rrrrr�Ns

r�c@seZdZdd�Zdd�ZdS)�MutatingElementPathcGstj|f|��}||_|S)N)r��__new__r#)r0r#�argsrrrrr��szMutatingElementPath.__new__cCs|jdd�=dS)NT)r#)rr�rrrr��szMutatingElementPath.__eq__N)rrrr�r�rrrrr��sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)NrSrr)rr�rrrr�szBadElementPath.__eq__N)rrrr�rrrrrsrcsXeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�BadElementPathTestcs(t�j�ddlm}|j|_i|_dS)Nr)r)�super�setUpr
rr��
path_cache)rr)r�rrr	s
zBadElementPathTest.setUpcs"ddlm}|j|_t�j�dS)Nr)r)r
rrr�r�tearDown)rr)r�rrrszBadElementPathTest.tearDowncCs0tjd�}|jtjd�g�|jt|d��dS)Nr�r�rM)rrDrrrvr�)rr�rrr�test_find_with_mutatings
z*BadElementPathTest.test_find_with_mutatingcCsHtjd�}|jtjd�g�y|jtd��Wntk
rBYnXdS)Nr�r�rM)rrDrrrvr�ZeroDivisionError)rr�rrr�test_find_with_errors
z'BadElementPathTest.test_find_with_errorcCs0tjd�}|jtjd�g�|jt|d��dS)Nr�r�rM)rrDrrryr�)rr�rrr�test_findtext_with_mutating!s
z.BadElementPathTest.test_findtext_with_mutatingcCsHtjd�}|jtjd�g�y|jtd��Wntk
rBYnXdS)Nr�r�rM)rrDrrryrr)rr�rrr�test_findtext_with_error&s
z+BadElementPathTest.test_findtext_with_errorcCs0tjd�}|jtjd�g�|jt|d��dS)Nr�r�rM)rrDrrrxr�)rr�rrr�test_findall_with_mutating.s
z-BadElementPathTest.test_findall_with_mutatingcCsHtjd�}|jtjd�g�y|jtd��Wntk
rBYnXdS)Nr�r�rM)rrDrrrxrr)rr�rrr�test_findall_with_error3s
z*BadElementPathTest.test_findall_with_error)rrrrrrr	r
rrr
�
__classcell__rr)r�rrsrc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|jtjt�|jtjt�|jtjt�|jtjt�|jtjt�|jtjt�dS)N)	rCrr��typerBr
rDr�r�)rrrr�test_istype=szElementTreeTypeTest.test_istypecCsZGdd�dtj�}|d�}|j|tj�|j||�|j|jd�d|_|j|jd�dS)Nc@seZdZdS)zDElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementN)rrrrrrr�	MyElementFsrr�r�)rrDrCrEr(rA)rr�myerrr�test_Element_subclass_trivialEsz1ElementTreeTypeTest.test_Element_subclass_trivialcsZG�fdd�dtj���dddd�ddd	�}|j|jd
�|jt|j��ddddg�dS)Ncs"eZdZif��fdd�	Z�ZS)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcst�|�j|d|f|�dS)N�__)rr{)rr(rBZextra)rr�rrr{TszQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)rrrr{rr)r)r�rrSsrr�rSr�)r�r�rr�)r�r�Zfoo__r�r�r�r�)r�rS)r�r�)r�r)r�r�)rrDrEr(r�r])rrr)rr�!test_Element_subclass_constructorRs
z5ElementTreeTypeTest.test_Element_subclass_constructorcCs.Gdd�dtj�}|d�}|j|j�d�dS)Nc@seZdZdd�ZdS)zGElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementcSs|jS)N)r()rrrr�	newmethod^szQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)rrrrrrrrr]srr�)rrDrEr)rrrrrr� test_Element_subclass_new_method\sz4ElementTreeTypeTest.test_Element_subclass_new_methodcCs�Gdd�dtj�}tjd�}d|_|d�}d|_|j|�|j|jd�d�|j|jd�jd�t|j	d��}|jt
|�d|�|j|djd�dS)	Nc@seZdZdS)zAElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementN)rrrrrrrresrr�rAr�r�rSr)rrDrArqrEryrvr(rGrxrF)rrr��sub�foundrrr�test_Element_subclass_findds

z.ElementTreeTypeTest.test_Element_subclass_findN)rrrrrrrrrrrrr<s


rc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ElementFindTestcCs�tjt�}|j|jd�jd�|j|jd�jd�|j|jd�jd�tjt�|d<|j|jd�jd�|j|jd�d�|j|jd�d�|j|jd�d	�|j|jdd
�d	�|j|jd��|j|jdd
�d
�|jtjd�jd
�d	�dS)Nr(zsection/tagz./tagr�zsection/nexttag�nexttagrAr�rUr��togz<tag><empty /></tag>�empty)	rrr�rErvr(�SAMPLE_SECTIONryr�)rr�rrr�test_find_simpleus
z ElementFindTest.test_find_simplecCs�d}tj|�}|j|jd�jdd�|j|jd�jdd�|j|jd�jdd�|j|jd	�jdd
�|j|jd�jdd�|jtd|jd
�|jtd|jd�|jtd|jd�|jtd|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])rrrErvrB�assertRaisesRegex�SyntaxError)rZ
LINEAR_XMLr�rrr�test_find_xpath�s
zElementFindTest.test_find_xpathcCs�tjt�}tjt�|d<|jt|jd��dg�|jt|jd��ddg�|jt|jd��g�|jt|jd��g�|jt|jd��dddg�|jt|jd	��dgd
�|jt|jd��dg�|jt|jd��dgd�|jt|jd
��dddg�|jt|jd��ddddg�|jt|jd��ddddg�|jt|jd��dddg�|jt|jd��ddddg�|jt|jd��dg�|jt|jd��dg�|jt|jd��dgd�|jt|jd��dgd�|jt|jd��dgd�|jt|jd��dg�|jt|jd��dgd�|jt|jd��dg�|jt|jd��dg�|jt|jd��g�|jt|jd��g�|jt|jd ��dgd�|j|jd!�|jd��dS)"Nr�rPr�r(rztog/foormrNz.//tagr�zsection/tagzsection//tagz	section/*rZnextsectionz
section//*zsection/.//*z*/*z*//*z*/tagz*/./tagz./tagz././tagz.//tag[@class]rz.//tag[@class="a"]z.//tag[@class="b"]z.//tag[@id]z.//section[tag]z.//section[element]z../tagzsection/../tagz	section//)rrr�r rEr,rx)rr�rrr�test_findall�sR
zElementFindTest.test_findallcCs\tjt�}|jt|jd��g�|jt|jd��dgd�|jt|jd��dgd�dS)Nr(z{http://effbot.org/ns}tagr�z.//{http://effbot.org/ns}tagr)rrr?rEr,rx)rr�rrr�test_test_find_with_ns�s
z&ElementFindTest.test_test_find_with_nscCs�tjd�}ddi}|jt|jd|d��d�|jt|jd|d��d�ddi}|jt|jd|d��d	�|jt|jd|d��d�dS)
Nz�
            <a xmlns:x="X" xmlns:y="Y">
                <x:b><c/></x:b>
                <b/>
                <c><x:b/><b/></c><y:b/>
            </a>Zxxr�z.//xx:b)�
namespacesr�z.//br�rS)rrrErFrx)rr��nsmaprrr�test_findall_different_nsmaps�sz-ElementFindTest.test_findall_different_nsmapsc	Cs0tjt�}|jtd��|jd�WdQRXdS)Nzcannot use absolute pathz/tag)rrr�r#r$rx)rr�rrr�
test_bad_find�s
zElementFindTest.test_bad_findcCs�tjt�}|jtj|�jd�jd�|jtj|�jd�d�|jttj|�j	d��dgd�|jttj|�j	d��dgd�dS)Nr(rAr�z//tagr)
rrr�rEr
rvr(ryr,rx)rr�rrr�test_find_through_ElementTree�s
z-ElementFindTest.test_find_through_ElementTreeN)
rrrr!r%r&r'r*r+r,rrrrrts,
rc@sFeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�ElementIterTestNcCst|j|��S)N)r,r|)rr#r(rrr�_ilist�szElementIterTest._ilistcCs6tjd�}|j|j|�dddg�|j|j|jd��ddg�|jt|j��jd�|jdj|j	��d�|jdj|jd�j	��d�|jt|j	��d�t
|d	d
�}|jttj|��dd�t
|d	d
�}tjtj
�d
�}|jttj||d��dd�tjd�}|jt|j�tjd�}|jdj|j	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>r8r�r�rUzthis is a paragraph...zthis is a paragraph.z
this is a F)r$rr�)r�)r�z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)rrrEr.rvr�r|r(r�r}r'r�r�r�r
r�r�)rrLZ
sourcefiler�r&rrr�
test_basic�s$


zElementIterTest.test_basiccCs�tjd�}|j|j|�dg�tj|d�}|j|j|�ddg�tj|d�}|j|j|�dddg�tj|d�}|j|j|�ddddg�|d|d<|d=|j|j|�ddg�dS)Nr�r�r�r�rSr)rrDrEr.r�)rr�r�r�r�rrr�test_corners	s
zElementIterTest.test_cornerscCs�tjd�}|j|j|d�dgd�|j|j|d�dgd�|jt|jdd��dgd�dddddddg}|jt|j��|�|j|j|�|�|j|j|d	�|�dS)
NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>�roomr�houser�)r(r��shedrm)rrrEr.r,r|)rrL�all_tagsrrr�test_iter_by_tag+	s
z ElementIterTest.test_iter_by_tagcCs�tjd�}|jt|jd��dgd�|jt|jd��dgd�|jt|jdd��dgd�dddddddg}|jt|j��|�|jt|jd��|�|jt|jd	��|�dS)
NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>r1rr2r�)r(r�r3rm)rrrEr,r~)rrLr4rrr�test_getiteratorH	s
z ElementIterTest.test_getiteratorc	Cs6tjd�}|j�}|jt��tj|�WdQRXdS)Nr�)rrDr|r�r�r�)rr�rkrrrr�g	s
zElementIterTest.test_copycCsVtjd�}|j�}x>ttjd�D],}|jttjf��tj	||�WdQRXq"WdS)Nr�rS)
rrDr|r�r3r�r�r�r6r4)rr�rkr=rrrr�m	s

zElementIterTest.test_pickle)N)
rrrr.r/r0r5r6r�r�rrrrr-�s
r-c@sdeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZdS)�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�|j|jd�|j|jd�|j|jd�|j|ji�t|�}|jt|�d�|d}|j|jd�|j|jd�|j|jd�|j|ji�dS)Nr8rArSrZdivr�r@)rEr(rAr@rBrGrF)rr�Zchildrenr�rrr�_check_sample1_element}	sz&TreeBuilderTest._check_sample1_elementcCs�Gdd�d�}Gdd�d|�}tj|�d�}|j|j�|j|j�d�tj|�d�}|j|j�|j|j�d�tjt�d�}|j|j�|j|j��dS)Nc@seZdZdd�ZdS)z<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuildercSsdS)Nr�r)rrrrr��	szBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeN)rrrr�rrrr�BaseDummyBuilder�	sr9c@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdS)Nr)r�rrr�<lambda>�	szATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)rrrr�r�r�rrrr�DummyBuilder�	sr;)r�r�)rr�r��sample1rEr��objectr�)rr9r;r�rrr�test_dummy_builder�	sz"TreeBuilderTest.test_dummy_buildercCs6tjtjdd�d�}|j|j�|j�}|j|�dS)N)r�)r�)rr�r�r�r<r�r8)rr�r�rrr�$test_treebuilder_elementfactory_none�	sz4TreeBuilderTest.test_treebuilder_elementfactory_nonecCsXGdd�dtj�}|�}|j|jd�d�tj|d�}|j|j�|j�}|j|�dS)Nc@seZdZdd�ZdS)z4TreeBuilderTest.test_subclass.<locals>.MyTreeBuildercSs|dS)Nr�r)rrMrrr�foobar�	sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN)rrrr@rrrr�
MyTreeBuilder�	srAr�r�)r�)	rr�rEr@r�r�r<r�r8)rrA�tbr�r�rrr�
test_subclass�	szTreeBuilderTest.test_subclasscsNg��fdd�}tj|d�}tj|d�}|j|j�|j�|j�dg�dS)Ncs�j|�tj||�S)N)rqrrD)r(rB)�lstrr�	myfactory�	s
z7TreeBuilderTest.test_element_factory.<locals>.myfactory)r�)r�Ztoplevel)rr�r�r��sample2r�rE)rrErBr�r)rDr�test_element_factory�	sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|j|j�|j�}|j||�|j|�dS)N)r�)r�)rr�r�r�r<r�rCr8)rr0rBr�r�rrr�_check_element_factory_class�	sz,TreeBuilderTest._check_element_factory_classcCs Gdd�dtj�}|j|�dS)Nc@seZdZdS)z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementN)rrrrrrrr�	sr)rrDrH)rrrrr�test_element_factory_subclass�	sz-TreeBuilderTest.test_element_factory_subclasscCs4tj}|j|jd�Gdd�d|t�}|j|�dS)Nzxml.etree.ElementTreec@seZdZdS)zLTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementN)rrrrrrrr�	sr)rZ_Element_PyrErr�rH)r�baserrrr�)test_element_factory_pure_python_subclass�	sz9TreeBuilderTest.test_element_factory_pure_python_subclasscCs<Gdd�d�}tj|�d�}|j|j�|j|j�d�dS)Nc@s eZdZdZdd�Zdd�ZdS)z3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNcSs|||f|_dS)N)�_doctype)rr:�pubid�systemrrr�doctype�	sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jS)N)rL)rrrrr��	sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)rrrrLrOr�rrrr�
DoctypeParser�	srP)r�r8�&-//W3C//DTD XHTML 1.0 Transitional//EN�7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r8rQrR)rr�r�r<rEr�)rrPr�rrr�test_doctype�	s	
zTreeBuilderTest.test_doctypecCs�Gdd�d�}tj|�d�x4d
D],}|jt|��tj||�d�WdQRXq"Wtj|td	�d�x:dD]2}tj||td	�d�}|j|j�|j|j��qjWdS)Nc@s"eZdZdefdd�Zdd�ZdS)zBTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNcSs||_||_dS)N)�raise_in�what)rrTrUrrrr{�	szKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|j|j��dd�}|S)NcWsdS)Nr)rrrr�handle�	sz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handle)rTrU)rr:rVrrr�__getattr__�	s
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)rrrr�r{rWrrrr�RaisingBuilder�	srX)r�r�r�r�r�r�)rU)r�r�r�r�r�)r�r�r�r�r�)	rr�r#r�r�r�r<r�r�)rrXZeventr�rrr�test_builder_lookup_errors�	s

z*TreeBuilderTest.test_builder_lookup_errorsN)rrrr<rFr8r>r?rCrGrHrIrKrSrYrrrrr7u	s
	
r7c@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|j|jd�|j|djd�|j|djd�dS)Nr%r�lineZ22)rEr(rA)rr�rrr�_check_sample_element
sz#XMLParserTest._check_sample_elementcCs`tjdtj�d�}|j|j�|j|j��tjdigtj�d�}|j|j�|j|j��dS)Nzutf-8)rr8r�)rr�r�r�r<r\r�)rr�Zparser2rrr�test_constructor_args
sz#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|j|j�|j|j��dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserN)rrrrrrr�MyParser#
sr^)rr�r�r<r\r�)rr^r�rrrrC"
szXMLParserTest.test_subclasscCs~tj�}|jt��|jddd�WdQRX|jd�|j�tj��.tj	dt�tj�}|j|j
�|j�WdQRXdS)Nr8z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdz<html/>�error)rr��assertWarns�DeprecationWarningrOr�r��warnings�catch_warnings�simplefilterrF)rr�rrr�test_doctype_warning)
s

z"XMLParserTest.test_doctype_warningcs�d�G�fdd�dtj�}|�}|jt��|j|j�WdQRX|j�|j�d
�d��tj	��Ztj
dt�G�fdd�d�}||�d	�}|j|j�|j�|j��|j�d�WdQRXdS)NcseZdZ�fdd�ZdS)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs|||f�dS)Nr)rr:rMrN)rLrrrO:
szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN)rrrrOr)rLrr�MyParserWithDoctype9
srfr8�&-//W3C//DTD XHTML 1.0 Transitional//EN�7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdr_cseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dS)Nr)rr:rMrN)�	_doctype2rrrOJ
szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeN)rrrrOr)rirrrPI
srP)r�)r8rgrh)r8rgrh)rr�r`rar�rFr�rErbrcrdr�)rrfr�rPr)rLrir�test_subclass_doctype7
s(

z#XMLParserTest.test_subclass_doctypecCsPtj��>tjdt�Gdd�dtj�}|�}|j|j�|j�WdQRXdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)r_c@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeN)rrrrrrr�MyParserWithoutDoctypeZ
srkN)	rbrcrdrarr�r�rFr�)rrkr�rrr�test_inherited_doctypeV
s
z$XMLParserTest.test_inherited_doctypecCsVtjtj�d�}|j|j�|j�}|j|jd�|j|jdd�|j|j	d�dS)N)r�ZmoneyrZu
$£€𐅻)
rr�r�r��sample3r�rEr(rBrA)rr�r�rrr�test_parse_string`
szXMLParserTest.test_parse_stringN)
rrrr<rFrmr\r]rCrerjrlrnrrrrrZ
s
rZc@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}tjt�}|jt|jd|��d�|jt|jd|��d�|jt|jd|��d�dS)	NZhellor�)�hr�z{hello}tablerSz.//{hello}tdr�z.//{foo}name)rr��SAMPLE_XML_NS_ELEMSrErFrx)rr)rLrrr�test_find_with_namespacej
s


z+NamespaceParseTest.test_find_with_namespaceN)rrrrrrrrrroi
sroc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ElementSlicingTestcCsdd�|D�S)NcSsg|]
}|j�qSr)r()r)r�rrrr*u
sz1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)rZelemlistrrr�
_elem_tagst
szElementSlicingTest._elem_tagscCs|jt|��S)N)rtrG)rr#rrr�
_subelem_tagsw
sz ElementSlicingTest._subelem_tagscCs0tjd�}x t|�D]}tj|d|�qW|S)zxCreate an Element with a tag 'a', with the given amount of children
           named 'a0', 'a1' ... and so on.

        r�za%s)rrDr�r�)rZnumchildrenr�r�rrr�_make_elem_with_childrenz
s
z+ElementSlicingTest._make_elem_with_childrencsZ|jd��|j�djd�|j�d	jd�|jt�fdd��|jt�fdd��dS)
Nr�rS�a1r��a8cs�dS)N�rr)r�rrr:�
sz?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Nryi�rr)r�rrr:�
s���)rvrEr(r��
IndexError)rr)r�r�test_getslice_single_index�
s

z-ElementSlicingTest.test_getslice_single_indexcCs�|jd�}|j|j|dd��dddg�|j|j|dd��dddg�|j|j|dd��dddg�|j|j|dd��ddg�|j|j|dd��ddg�|j|j|dd	��d
dg�dS)
Nr�r�a3�a4�a5�rirSr��a0rwr�)rvrErt)rr�rrr�test_getslice_range�
s
   z&ElementSlicingTest.test_getslice_rangecCs�|jd�}|j|j|ddd��ddg�|j|j|ddd��ddd	dg�|j|j|ddd��ddg�|j|j|ddd��d
dg�|j|j|ddtj��dg�|j|j|ddtjd>��dg�dS)Nr��rSrxZa9rr�r}Za6rw�@)rvrErtr2�maxsize)rr�rrr�test_getslice_steps�
s
 $   z&ElementSlicingTest.test_getslice_stepscCs�|jd�}|j|j|ddd
��ddddg�|j|j|ddd��ddg�|j|j|ddtj��dg�|j|j|ddtjd��dg�|j|j|ddtjd	>��dg�dS)Nr�rSr}�a2rwr�r�rr�r�rz)rvrErtr2r�)rr�rrr�test_getslice_negative_steps�
s
$ "&z/ElementSlicingTest.test_getslice_negative_stepscCs�|jd�}|dd�=|j|j|�ddg�|jd�}|dd�=|j|j|�g�|jd�}|ddd	�=|j|j|�g�|jd�}|ddd
�=|j|j|�ddg�|jd�}|ddd�=|j|j|�ddg�|jd�}|ddd�=|j|j|�dg�dS)Nr�rr�r�r}rSr�rwr�rz)rvrEru)rr�rrr�
test_delslice�
s$







z ElementSlicingTest.test_delslicecCs�|jd�}tjd�|d<|j|j|�ddddg�tjd�|d<|j|j|�ddddg�|jt��tjd	�|d
<WdQRX|jt��tjd	�|d<WdQRX|j|j|�ddddg�dS)
Nr�r�rSr�r�r}r�r�r�rirz���)rvrrDrErur�r{)rr�rrr�test_setslice_single_index�
s
z-ElementSlicingTest.test_setslice_single_indexcCs�|jd�}dd�td�D�|dd�<|j|j|�ddd	d
g�|jd�}tjd�g|dd�<|j|j|�ddd
g�|jd�}dd�td�D�|dd�<|j|j|�ddd	d
d
g�dS)Nr�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
sz:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rSrr��b0�b1r}r�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
sZb2)rvr�rErurrD)rr�rrr�test_setslice_range�
s


z&ElementSlicingTest.test_setslice_rangecCsd|jd�}dd�td�D�|ddd�<|j|j|�ddd	d
ddg�|jd�}|jt��tjd
�g|ddd�<WdQRX|jt��"dd�td�D�|ddd�<WdQRX|jt��g|ddd�<WdQRX|j|j|�ddd	dddg�|jd�}tjd
�g|ddtj	�<|j|j|�dd
d	dg�tjd�g|ddtj	d>�<|j|j|�ddd	dg�dS)Nr�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
sz:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rSrir�r�r�r�r~rr�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
srrwr}r�r�r�)
rvr�rErur�r�rrDr2r�)rr�rrr�test_setslice_steps�
s 

 &
z&ElementSlicingTest.test_setslice_stepscCs�|jd�}dd�td�D�|ddd�<|j|j|�ddd	d
g�|jd�}|jt��tjd�g|ddd�<WdQRX|jt��"dd�td
�D�|ddd�<WdQRX|jt��g|ddd�<WdQRX|j|j|�dddd
g�|jd�}tjd�g|ddtj	�<|j|j|�dddd
g�tjd�g|ddtj	d�<|j|j|�dddd
g�tjd�g|ddtj	d>�<|j|j|�dddd
g�dS)Nr�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
szCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rrSr�r�r�r}r�cSsg|]}tjd|��qS)zb%s)rrD)r)r�rrrr*�
srrwr�r�r�r�r�r�r�r�)
rvr�rErur�r�rrDr2r�)rr�rrr�test_setslice_negative_steps�
s$

 &
z/ElementSlicingTest.test_setslice_negative_stepsN)rrrrtrurvr|r�r�r�r�r�r�r�r�rrrrrss
s
	

	
rsc@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�tjd�}d|_|jt|�d�xNdD]F}|j|��2|jt||d�d�|jt||j�d�d�WdQRXq&Wxfd D]^}|j|��J|jt||d�d|j|��|j�}|jt||d�d|j|��WdQRXqvWtjd�}d|_|jt|�d
�|jt|dd�d�|jt|dd�d�x,d!D]$}|jt||d�d|j|���q&Wtjd�}d|jd<|jt|�d�|jt|dd�d�|jt|dd�d�x,d"D]$}|jt||d�d|j|���q�Wtjd�}d|_|jt|�d�|jt|dd�d�|jt|dd�d�x,d#D]$}|jt||d�d|j|���qWtjd�}d|jd<|jt|�d�|jt|dd�d�|jt|dd�d�x,d$D]$}|jt||d�d|j|���q�WdS)%Nr(�abcz<tag>abc</tag>�utf-8�us-ascii)rs<tag>abc</tag>�
iso-8859-1�utf-16�utf-32z2<?xml version='1.0' encoding='%s'?>
<tag>abc</tag>z<&"'>z<tag>&lt;&amp;"'&gt;</tag>s<tag>&lt;&amp;"'&gt;</tag>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;" />�utf-16le�utf-16beu@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�)r�r�r�r�r�)	rrDrArEr'rk�upperr�rB)rr#�encr�rrrr6
s|












zIOTest.test_encodingc
CsR|jtjt�tjtjd��}|jt�ttd��}|j	|j
�d�WdQRXdS)Nz<site />r�s<site />)r�rr�rrr
rr r�rEr�)rr&r�rrr�test_write_to_filenameOs

zIOTest.test_write_to_filenamecCs||jtjt�tjtjd��}ttddd�� }|j|dd�|j	|j
�WdQRXttd��}|j|j�d�WdQRXdS)Nz<site />r�zutf-8)rrr�s<site />)
r�rr�rrr
rr�r r�r�rEr�)rr&r�rrr�test_write_to_text_fileVszIOTest.test_write_to_text_filecCst|jtjt�tjtjd��}ttd��}|j|�|j	|j
�WdQRXttd��}|j|j�d�WdQRXdS)Nz<site />r�r�s<site />)
r�rr�rrr
rr�r r�r�rEr�)rr&r�rrr�test_write_to_binary_file_s
z IOTest.test_write_to_binary_filec Cs�|jtjt�tjtjd��}ttd�� }|j|dd�|j	|j
�WdQRXttd��}|j|j�dj
d��WdQRXttddd�� }|j|dd�|j	|j
�WdQRXttd��}|j|j�dj
d��WdQRXdS)	Nz<site />r�zutf-16)rr�z0<?xml version='1.0' encoding='utf-16'?>
<site />r)�	buffering)r�rr�rrr
rr�r r�r�rEr�r�)rr&r�rrr�"test_write_to_binary_file_with_bomhs 

z)IOTest.test_write_to_binary_file_with_bomcCs2tj�}tjd�}|j|�|j|j�jd�dS)Nz"<?xml version="1.0"?><site></site>�site)rr
rrr�rErnr()rr&r�rrr�test_read_from_stringio|s

zIOTest.test_read_from_stringiocCs:tjtjd��}tj�}|j|dd�|j|j�d�dS)Nz<site />r)r)rr
rrrr rEr!)rr&r�rrr�test_write_to_stringio�szIOTest.test_write_to_stringiocCs2tj�}tjd�}|j|�|j|j�jd�dS)Ns"<?xml version="1.0"?><site></site>r�)rr
rrr�rErnr()rr&r�rrr�test_read_from_bytesio�s

zIOTest.test_read_from_bytesiocCs6tjtjd��}tj�}|j|�|j|j�d�dS)Nz<site />s<site />)rr
rrrr rEr!)rr&r�rrr�test_write_to_bytesio�s
zIOTest.test_write_to_bytesioc@seZdZdS)zIOTest.dummyN)rrrrrrr�dummy�sr�cCsBtjd�}|j�}|j|_tj�}|j|�|j|j�j	d�dS)Nz"<?xml version="1.0"?><site></site>r�)
rrr�r�rr
r�rErnr()rr��readerr&rrr�test_read_from_user_text_reader�s

z&IOTest.test_read_from_user_text_readercCsJtjtjd��}tj�}|j�}|j|_|j|dd�|j|j�d�dS)Nz<site />r)r)	rr
rrrr�r rEr!)rr&r��writerrrr�test_write_to_user_text_writer�sz%IOTest.test_write_to_user_text_writercCsJtjd�}|j�}|j|_tj�}|j|�|j|j�j	d�tj�}dS)Ns"<?xml version="1.0"?><site></site>r�)
rrr�r�rr
r�rErnr()rr�r�r&rrr�!test_read_from_user_binary_reader�s

z(IOTest.test_read_from_user_binary_readercCsFtjtjd��}tj�}|j�}|j|_|j|�|j|j�d�dS)Nz<site />s<site />)	rr
rrrr�r rEr!)rr&r�r�rrr� test_write_to_user_binary_writer�s
z'IOTest.test_write_to_user_binary_writercCsbtjtjd��}tj�}|j�}|j|_dd�|_|j|_|j|dd�|j	|j
�djd��dS)Nz<site />cSsdS)NTrrrrrr:�szBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>zutf-16)rz0<?xml version='1.0' encoding='utf-16'?>
<site />)rr
rrrr�r �seekable�tellrEr!r�)rr&r�r�rrr�)test_write_to_user_binary_writer_with_bom�s

z0IOTest.test_write_to_user_binary_writer_with_bomcCsRtjd�}|jtj|d�djtj|d���|jtj|d�djtj|d���dS)Nz<tag>foo</tag>rrUzutf-16r�)rr�rEr�r�r�)rr�rrr�test_tostringlist_invariant�s


z"IOTest.test_tostringlist_invariantcCsRtjd�}|jtj|d�d�|jtj|ddd�d�|jtj|ddd�d�dS)Nz<tag>a<x />b<y></y>c</tag>rz<tag>a<x />b<y />c</tag>T)Zshort_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)rr�rEr�)rr�rrr�test_short_empty_elements�s

z IOTest.test_short_empty_elementsN)rrrr6r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�	s"E				r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|jtj�t�dS)N)rCrr�r$)rrrrrC�szParseErrorTest.test_subclasscCs6ytj|�Wn"tjk
r0}z|Sd}~XnXdS)N)rr�r�)rr�r�rrr�
_get_error�szParseErrorTest._get_errorcCs@|j|jd�jd�|j|jd�jd	�|j|jd�jd
�dS)Nr�rSrz<tag>&foo;</tag>rizfoobar<r�)rSr)rSri)rSr�)rEr�Zposition)rrrr�test_error_position�sz"ParseErrorTest.test_error_positioncCs.ddljjj}|j|jd�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errorsZparsersZexpat�errorsrEr��codeZcodesZXML_ERROR_SYNTAX)rZERRORSrrr�test_error_code�szParseErrorTest.test_error_codeN)rrrrCr�r�r�rrrrr��sr�c@seZdZdd�ZdS)�KeywordArgsTestcCs�tjd�}|j|jdd�|jddd��|j|jddd�|jdddd��|j|jdd�|jddd��|jt|jdd��t|jddd���|jtjd�j	i�tjdt
ddd��tjdt
ddd�d�tjdt
dd	�dd
�tjdddd�tjdt
ddd�ddd�g}x2|D]*}|j|jd�|j|j	t
ddd���qWtj|ddd
did�}|j|j	d
d�|j
td��tjdd�WdQRX|j
td��tjddd�WdQRXdS)Nz
<a>foo</a>r�)�pathr()r�r�r(�#r�)r��id)rB)r�)r�rr@Zkey1Zvalue1zmust be dict, not strzI'm not a dict)rrrErvryrxrGrwrDrBr7r(r�r#r�)rrM�elementsr�r�rrr�test_issue14818�s0

zKeywordArgsTest.test_issue14818N)rrrr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCststjd��dS)Nzonly for the Python version)r.r��SkipTest)rrrrrszNoAcceleratorTest.setUpcCs(|jtjjtj�|jtjjtj�dS)N)rCr.rDr{�types�FunctionTyper�)rrrr�test_correct_import_pyETsz*NoAcceleratorTest.test_correct_import_pyETN)rrrrr�rrrrr�sr�c@s.eZdZdZdZd
dd�Zdd�Zdd	�ZdS)�CleanContextz1Provide default namespace mapping and path cache.NFcCs<tjjdkrd}dtfdtfdtff}tj|d|i�|_dS)Nr�Tz�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@This method will be removed in future versions.  Use .+ instead.�quiet)	r2�flags�optimize�
FutureWarningra�PendingDeprecationWarningrZcheck_warnings�
checkwarnings)rr�Zdeprecationsrrrr{'szCleanContext.__init__cCsDddlm}tjj|_|jj�|_|j|_	|j	j�|_|j
j�dS)Nr)r)r
rrr�Z_namespace_map�_nsmapr��_nsmap_copyr��_path_cacher��	__enter__)rrrrrr�8s
zCleanContext.__enter__cGs<ddlm}|jj�|jj|j�|j|_|jj	|�dS)Nr)r)
r
rr�rzr�r�r�r�r��__exit__)rrrrrrr�Bs

zCleanContext.__exit__)F)rrr�__doc__r�r{r�r�rrrrr�#s


r�cCs�tddgd�a|dkrt}|attttttt	t
ttt
tttttg}ttk	rV|jtg�z(tttk	d��tj|�WdQRXWddaaXdS)Nzxml.etree.ElementTreer)Zblocked)r�)rr.rr	rsr�r�rrPr�r�r�rrr-r7rZrdr�rrr�r�rZrun_unittest)�moduleZtest_classesrrr�	test_mainKs8
r��__main__)Tr)N)Er�r8rrJr3r2r�r�rbr��	itertoolsrr�rZtest.supportrrrrrr.rr�r��UnicodeEncodeErrorr�r�r�r�r r?rqr<r=ZTestCaser	r'r,r-rPrdr��format�escaper�r�r�r�r�r�r��__hash__rrrrr-r7rZrorsr�r�r�r�r=r�r�rrrrr�<module>s�




#j	
	h],48c
R$(
0


Youez - 2016 - github.com/yon3zu
LinuXploit