Your IP : 216.73.216.85


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_xml_etree.cpython-35.opt-1.pyc



��Yf���
@sgddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZmZmZmZmZdadaeddd�Zyejd�Wn!ek
rejd	��YnXed
dd�ZdZdZd
ZdZdZGdd�dej �Z!dddd�Z"dd�Z#Gdd�d�Z$Gdd�dej �Z%Gdd�dej �Z&iZ'de'd<d e'd!<d"e'd#<d$e'd%<d&e'd'<d(e'd)<d*e'd+<d,e'd-<d.j(ej)ed��e'd/<iZ*d0e*d1<d2e*d3<Gd4d5�d5ej �Z+Gd6d7�d7ej �Z,Gd8d9�d9e$ej �Z-Gd:d;�d;e$ej �Z.Gd<d=�d=e/�Z0e/j1e0_1Gd>d?�d?e/�Z2e/j1e2_1Gd@dA�dAe$ej �Z3GdBdC�dCej �Z4GdDdE�dEej �Z5GdFdG�dGej �Z6GdHdI�dIej �Z7GdJdK�dKej �Z8GdLdM�dMej �Z9GdNdO�dOej �Z:GdPdQ�dQej �Z;GdRdS�dSej �Z<GdTdU�dUej �Z=GdVdW�dWej �Z>GdXdY�dYe?�Z@ddZd[�ZAeBd\krceA�dS)]�N)�product)�support)�TESTFN�findfile�import_fresh_module�
gc_collect�	swap_attrz
simple.xmlZsubdirZxmltestdatazutf-8z!filename is not encodable to utf8z
simple-ns.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>
c@seZdZdd�ZdS)�
ModuleTestcCs4ddlm}ddlm}ddlm}dS)Nr)�ElementTree)�ElementInclude)�ElementPath)�	xml.etreer
rr)�selfr
rr�r�8/opt/alt/python35/lib64/python3.5/test/test_xml_etree.py�test_sanity`szModuleTest.test_sanityN)�__name__�
__module__�__qualname__rrrrrr	]sr	T�unicodecKsq|dkrtj�}ntj�}tj|�}|j|d||�|r\|j�S|jd�|SdS)Nr�encodingr)�io�BytesIO�StringIO�ETr
�write�getvalue�seek)�elem�	to_stringrZoptions�file�treerrr�	serializehs

r"cCsdd�|D�S)NcSsg|]}|j�qSr)�tag)�.0rrrr�
<listcomp>vs	z"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_listusr'c@s:eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS)N)�pyETr�modules)�clsrrr�
setUpClasszszElementTestCase.setUpClasscCs�tj|}z�y?|tj|<tj||�}|tj|<tj|�}Wn}tjk
r�}	zZttdftdfg�}
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


	3zElementTestCase.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
propertiesrrrrD�s(z#ElementTestCase.assertEqualElementsN)rrr�classmethodr,r:rDrrrrr(ysr(c@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�Zd7S)8�ElementTreeTestcCs|jt|�|�dS)N)r@r")rr�expectedrrr�serialize_check�szElementTreeTest.serialize_checkcsC�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)Ncsat|�x.|D]&}�jt|�ddd|�qW|d}|d}|dd�dS)N��msgz%expected one-character string, got %r�� r)rAr@)�string�charZ
new_string)rrr�check_string�s



z4ElementTreeTest.test_interface.<locals>.check_stringcsmt|�|j�}|j�}x|D]}||}q)Wd|d<�j|dddd|d�dS)N�value�keyrOzexpected value string, got %r)rA�keys�itemsr@)�mappingrWrXrV�item)rrr�
check_mapping�s


z5ElementTreeTest.test_interface.<locals>.check_mappingcs��jtj|�dd��jt|d�dd��jt|d�dd��jt|d�dd��jt|d	�dd
��|j��|j�|jdk	r��|j�|jdk	r��|j�x|D]}�|�q�WdS)NrOznot an elementr#z
no tag memberr=zno attrib memberr<zno text memberr;zno tail member)�
assertTruerZ	iselement�hasattrr#r=r<r;)�elementr)�
check_elementr[rTrrrr_�s




z5ElementTreeTest.test_interface.<locals>.check_elementr#utägrVrUz^<Element 't\xe4g' at 0x.*>$cs$�jt|d�dd|�dS)N�__call__rOz%s not callable)r\r])�method)rrr�check_method�sz4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dS)N)�__next__)�it)rbrr�
check_iter�sz2ElementTreeTest.test_interface.<locals>.check_iter�*)rr?r
�getroot�assertRegex�repr�append�extend�insert�remove�getchildren�find�iterfind�findall�findtext�clearr3�setrWrX�iter�itertext�getiteratorr@�XML�
fromstring�PI�ProcessingInstruction)rr^r!rer)r_r[rbrTrr�test_interface�sH	


















zElementTreeTest.test_interfacecCsitjd�}|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
di|_|j|jdd	d
di�dd
ddi|_|j|jdd
ddi�dS)Nr#�TagZTAG�TextZTEXTZTailZTAIL�a�b�c�d�A�B�C�D)rr?r@r#�assertIsNoner<r;r=)rr^rrr�test_set_attribute�s*						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#rVrUz<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listrNz
<subtag />�	�)
rrxrMr?rjrmrlrk�assertRaises�
ValueErrorr@�str�	exception)rr�er^Z
subelement�cmrrr�test_simpleopssH




	

(+
	zElementTreeTest.test_simpleopscCsO|jtjd�d�|jtjd�d�|jtjd�d�dS)Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)rMrrx)rrrr�
test_cdata;szElementTreeTest.test_cdatacCs�tjtjd��}tjd|�}|j|jd�jd�|j|jd�jd�tjdt	�}|j|jd�jd�|j|jd�jd�dS)Nzutf-8r r#zsection/tagr^zelement/../empty-elementz
empty-element)
rr�
SAMPLE_XML�encoderr
r@ror#�SIMPLE_XMLFILE)rZ
stringfiler!rrr�test_file_initEszElementTreeTest.test_file_initcCsYddlm}tjt�}x4td�D]&}tj|�jdt|��q,Wt	|j
�}x4td�D]&}tj|�jdt|��qrW|jt	|j
�|�x4td�D]&}tj|�jdt|��q�W|jt	|j
�|�x4td�D]&}tj|�jdt|��qW|j
t	|j
�d�dS)Nr)r�
z./�iXi�)r
rrrxr��ranger
ror�rA�_cacher@Z
assertGreaterZ
assertLess)rrr�iZcache_len_10rrr�test_path_cachePs$$$$zElementTreeTest.test_path_cachecCsddl}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>)�copyrrx�deepcopyror#rM)rr��e1�e2�e3rrr�	test_copy_s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|_|jdd	�|jd
d�|jtj|�d�|jt	|j
��dd
g�|jt	|j��ddg�|j|jd
d�d
|jd
<d|jd<|jtj|�d�tjd�}|jdd�|jdd�|jdd�|jdd�|jtj|�d�dS)Nr#rV�defaultrU�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�)rr?r3r@rtr=rsr<�tostring�sortedrWrX)rrr=rrr�test_attribksT


	"


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#rVrUr�rOzattrib aliasingz!<tag><subtag key="value" /></tag>z<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
rr?ZmakeelementZassertIsNotr=rjrMrsrk�tuple)rrr=�subelemrrr�test_makeelement�s"


	z ElementTreeTest.test_makeelementc
Cs1tjt�}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�}tjd|�}|j|�|j|j�d�dS)Nrrzi<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�rrrr@r�SIMPLE_NS_XMLFILE�open�read�	XMLParserrh�version�feedrM�close�TreeBuilder)rr!�stream�f�data�parserr�rrr�test_parsefile�s,

zElementTreeTest.test_parsefilecCsBtjd�}|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>rrz<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>rN�body)rrxr@r�ryZfromstringlist�join�tostringlistZXMLIDrAr#)rr^Zsequence�_Zidsrrr�test_parseliteral�s&z!ElementTreeTest.test_parseliteralc;CsItj}|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}|td|�}|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��=}|jt��}|||�WdQRX|j
|j�WdQRX|jt|j�d�tj|��G|jt��}|t|�WdQRX|jt|j�d�~WdQRXtjd�}	dC}||	|�}|jdd�|D�dEdGg�tj	d�}	||	�}
t|
�\}}|j||jfdH�|jtj��}t|
�WdQRX|jt|j�d!�t
td"��}|jd#�WdQRX|t�}
t|
�\}}|j||jfdI�tj|��J|jtj��}t|
�WdQRX|jt|j�d!�~~
WdQRXdS)JN�endr^cSs%g|]\}}||jf�qSr)r#)r$�actionrrrrr%s	z2ElementTreeTest.test_iterparse.<locals>.<listcomp>�
empty-element�rootcSs%g|]\}}||jf�qSr)r#)r$r�rrrrr%	s	�{namespace}element�{namespace}empty-element�{namespace}rootcSs%g|]\}}||jf�qSr)r#)r$r�rrrrr%s	�eventscSs%g|]\}}||jf�qSr)r#)r$r�rrrrr%s	�startcSs%g|]\}}||jf�qSr)r#)r$r�rrrrr%s	�start-ns�end-nscSs=g|]3\}}|dkr-||jfn	||f�qS)r�r�)r�r�)r#)r$r�rrrrr%'s	rP�	namespacez<root xmlns=''/>cSsg|]\}}|�qSrr)r$r�rrrrr%8s	�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>
cSs"g|]\}}||f�qSrr)r$r�rrrrr%Ns	�http://éffbot.org/ns�clé�http://effbot.org/nsz<document />junk�documentz.junk after document element: line 1, column 12�wbs<document />junk)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�)r�r�)r�r�)r�r�r�r��rPr�)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��rPr�)r�r��r�r�)r�r�)r�r�)r�r�)r�	iterparser��nextr@r#r�r�rrr�r�r��assertFalse�closedr�r�rZcheck_no_resource_warningr�
ParseErrorrr)rr��contextr�rr��resr�r��sourcerdrrr�test_iterparse�s�	




	
zElementTreeTest.test_iterparsecCs�tjd�}d|_|j|d�dtj|d�_|j|d�d|_|j|d�|jdtjd	��|j|d
�tjdd�|d<|j|d
�dS)Nr#r<z<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>rVrUz)text<?key value?><subtag>subtext</subtag>)	rr?r<rM�
SubElementr#rl�Commentrz)rrrrr�test_writefilehs			zElementTreeTest.test_writefilecCstt��}|j�}WdQRXGdd�dt�}|�}tjd|�}|j|�|j|ddddddddg�tt��}|j�}WdQRXGd	d�dt�}|�}tjd|�}|j|�|j|dddddddd d!d"g
�dS)#Nc@s4eZdZdd�Zdd�Zdd�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|jd|f�dS)Nr�)rj)rr#r=rrrr�sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|jd|f�dS)Nr�)rj)rr#rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rr<rrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)rrrr�r�r�rrrr�Builder~sr�r�r�r�r^r��
empty-elementc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|jd|f�dS)Nr�)rj)rr#r=rrrr��sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|jd|f�dS)Nr�)rj)rr#rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rr<rrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.datacSs|jd||f�dS)N�pi)rj)rr�r�rrrr��sz7ElementTreeTest.test_custom_builder.<locals>.Builder.picSs|jd|f�dS)Nr�)rj)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�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�)r�r�)r�r�)	r�r�r�rBrr�r�r@r�)rr�r�r�Zbuilderr�rrr�test_custom_builderys@	
	
	
	z#ElementTreeTest.test_custom_builderc
Cs�ttd��}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�cSs"g|]}t|j���qSr)r'rn)r$rrrrr%�s	z4ElementTreeTest.test_getchildren.<locals>.<listcomp>r^z
empty-elementcSs"g|]}t|j���qSr)r'rn)r$rrrrr%�s	�r�rNr)r�r�rr�r@rgrurwrxr�rArn�assertNotEqualrs)rr�r!rZchild1Zchild2rrr�test_getchildren�s<


  



z ElementTreeTest.test_getchildrencCsTtjd�}|jtj|�d�tjd�}|jtj|�d�dS)Nz<html><body>text</body></html>s<html><body>text</body></html>)rrxr@r�ry)rrrrr�test_writestring�sz ElementTreeTest.test_writestringcCs�d�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}x6|D].}�jtjtj||���dS�qWWdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddeg}x*|D]"}�jttj||��q�Wdfdgdhdidjdkdldmdndog
}x-|D]%}�jtjtj||��qW�jttj�dp�jd���jttj�dq�jd��dS)rNrPcsUd||f}�jtj|j|��j|��jtj|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)r@rrxr�r<)rr��xml)rrr�check�s
%z,ElementTreeTest.test_encoding.<locals>.checkr�rzus-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)r�rr�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)	r@rr�rxr�r�r�r��LookupError)rr�r�Zsupported_encodingsrZ&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr)rr�r�
test_encoding�sR





	
,				
 
#%zElementTreeTest.test_encodingcCs�tjd�}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>
rar��htmlz*<html><link><script>1 < 2</script></html>
r<z1 < 2
)rrxr;r@r")rr�rrr�test_methodss	zElementTreeTest.test_methodscCsEtjd�}|jt|�d�|jt|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>rar/)rrxr@r")rr�rrr�test_issue18347&s
zElementTreeTest.test_issue18347cCstjd�}|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�dS)Nz*<document title='&#x8230;'>test</document>rzus-asciis*<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 10r<�entityz<document>text</document>)rrxr@r"rMr�r�r�r��
ENTITY_XMLr�r2r�r�)rr�r�r�r�rrr�test_entity-s"

zElementTreeTest.test_entitycCs�tjd�}|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>)rrxrM�
SAMPLE_XML_NS)rrrrr�test_namespaceKs				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>rUz{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)rr?rM�QNamer�rsr=rjr@r�r�)rrr�Zq1Zq2rrr�
test_qnamelsV	

	
	

	
	


	"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>)rrx)rrrrr�test_doctype_public�sz#ElementTreeTest.test_doctype_publiccs�ddlm���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)NcSs"g|]\}}|p|�qSrr)r$�opr#rrrr%�s	zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)r@Zxpath_tokenizer)�prL)rrrrr��sz3ElementTreeTest.test_xpath_tokenizer.<locals>.checkrfztext()r<z()z@name�@r5z@*zpara[1]Zpara�[�1�]zpara[last()]Zlastz*/para�/z/doc/chapter[5]/section[2]�docZchapter�5�section�2z
chapter//paraz//z//paraz//olist/itemZolistrZ�.z.//paraz..z../@langZlangzchapter[title]�titlez#employee[@secretary and @assistant]ZemployeeZ	secretaryrP�andZ	assistantz{http://spam}eggz
./spam.eggzspam.eggz.//{http://spam}egg)r
r)rr�r)rrr�test_xpath_tokenizer�s2	"z$ElementTreeTest.test_xpath_tokenizercCs�|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&>�?>)r@rr�r{rz)rrrr�test_processinginstruction�s!z*ElementTreeTest.test_processinginstructionc
Cs�x�ddddddddd	d
ddd
g
D]�}x�||j�gD]t}d|}ttjd|�dd�}|j||�ttjd||f�dd�}|j||�qGWq.WdS)NZAREAZBASEZBASEFONTZBRZCOLZFRAMEZHRZIMGZINPUTZISINDEXZLINKZMETAZPARAMz<%s>z<%s />rar/z	<%s></%s>)�lowerr"rrxr@)rr^rrLZ
serializedrrr�#test_html_empty_elems_serialization�s
	z3ElementTreeTest.test_html_empty_elems_serializationN)rrrrMr|r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r-r0r1r4r6r9r:rIrJrLrrrrrK�s6V)
5-o8%;!A#rKc@seZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�XMLPullParserTestNcCs^|dkr|j|�n>x;tdt|�|�D]!}|j||||��q5WdS)Nr)r�r�rA)rr�r��
chunk_sizer�rrr�_feed�szXMLPullParserTest._feedcCs-|j�}|jdd�|D�|�dS)NcSs%g|]\}}||jf�qSr)r#)r$r�rrrrr%s	z7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)�read_eventsr@)rr�rLr�rrr�assert_event_tags�sz#XMLPullParserTest.assert_event_tagsc
Cs,x%dD]}|jd|��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)NrN�rNz<!-- comment -->
z+<root>
  <element key='value'>text</elementz>
r�r^z<element>text</element>tail
z<empty-element/>
�
empty-elementz</root>
r�)NrNrR)r�r^)r�r^)r�rS)r�r�)�subTestr�
XMLPullParserrQrOr�r�)rrNr�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�r^z</root>
r�)r�r^)r�r�)	rrUrPrOr�r@r#r��
StopIteration)rr�rdr�rrrr�test_feed_while_iteratingsz+XMLPullParserTest.test_feed_while_iteratingcCstj�}|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�rY)r�rY)r�rZ)r�r[)rrUrQrOr�r�)rr�rrr�test_simple_xml_with_ns's$	
z)XMLPullParserTest.test_simple_xml_with_nscCs�tjdd
�}|j|d�|j|d�|jt|j��dg�|j|d�|j|d	�|j|d
�|j|d�|j|d�|jt|j��dg�|j|j��dS)Nr��start-ns�end-nsz<!-- comment -->
z<root xmlns='namespace'>
rPr�z"<element key='value'>text</elementz>
z<element>text</element>tail
z<empty-element/>
z</root>
)r]r^�rPr�)r]r_)r^N)rrUrOr@rBrPr�r�)rr�rrr�test_ns_events<s
z XMLPullParserTest.test_ns_eventscCstjdf�}|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)Nr�z<root/>
r�r�z<!-- comment -->
z<root>
r�z"<element key='value'>text</elementr^z>
z8<element xmlns='foo'>text<empty-element/></element>tail
�{foo}element�{foo}empty-elementz</root>)r�r�)r�r�)r�r^)r�r^)r�ra)r�rb)r�rb)r�ra)r�r�)r�)r�r�)r�r^)r�ra)r�rb)rrUrOrQr�r�)rr�rrr�test_eventsKsL		
		
zXMLPullParserTest.test_eventscCs�ddh}tjd|�}|j|d�|j|dd	g�Gdd�d�}tjd|��}|j|d�|j|d
dg�dS)Nr�r�r�z<foo>bar</foo>r�c@s4eZdZdd�Zdd�Zdd�ZdS)z9XMLPullParserTest.test_events_sequence.<locals>.DummyItercSstdddg�|_dS)Nr�r�zstart-ns)rur�)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�)rrrrrc�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)rrrrdrercrrrr�	DummyIter~srf)r�r�)r�r�)r�r�)r�r�)rrUrOrQ)rZeventsetr�rfrrr�test_events_sequencewsz&XMLPullParserTest.test_events_sequencecCs+|jt��tjdd�WdQRXdS)Nr�r�r�r�)r�r�r�)r�r�rrU)rrrr�test_unknown_event�sz$XMLPullParserTest.test_unknown_event)rrrrOrQrVrXr\r`rcrgrhrrrrrM�s,rMz�<?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@saeZdZdddd�Zddd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)�XIncludeTestr�NcCsNyt|}Wntk
r.td��YnX|dkrJtj|�}|S)Nzresource not foundr�)�XINCLUDE�KeyError�OSErrorrrx)r�hrefr�rr�rrr�xinclude_loader�s
zXIncludeTest.xinclude_loadercCsdS)Nr)rrmr�rrrr�none_loader�szXIncludeTest.none_loaderc	CsC|dkr;t|d��}tj|�j�SWdQRXndSdS)Nr�r�)r�rr�rg)rrmr�r�rrr�
_my_loader�szXIncludeTest._my_loadercCsLddlm}|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
rrn�includerpr@r")rrrBrrr�test_xinclude_defaults
z"XIncludeTest.test_xinclude_defaultc
Cs^ddlm}|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
rrnrqr@r"r�rlr�r�)rrr�r�rrr�
test_xincludes.
zXIncludeTest.test_xincludec Cs�ddlm}tjtd�}|j|j��}|j|d|j�WdQRX|j	t
|j�d�tjtd�}|j|j��}|j|d|j�WdQRX|j	t
|j�d�tjtd�}|j|j��}|j|d|j�WdQRX|j	t
|j�d	�tjtd
�}|j|j��}|j|d|j�WdQRX|j	t
|j�d�dS)Nr)rzC1.xmlr7z%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
rrrxrjr�ZFatalIncludeErrorrqror@r�r��XINCLUDE_BAD)rrr�r�rrr�test_xinclude_failuresUs*z#XIncludeTest.test_xinclude_failures)	rrrrnrorprrrsrurrrrri�s		@ric@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�Zd3S)4�BugsTestcs��fdd�}tjd�}||�tjd�}d|_||�tjd�}d|_||�tjd�}|jdd�||�tjd�}|jdd�||�dS)Nc
s@�jt��}t|�WdQRX�jt|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorr"r@r�r�)rr�)rrrr�}sz-BugsTest.test_bug_xmltoolkit21.<locals>.check�{rZ123)rr?r<r;rt)rr�rr)rr�test_bug_xmltoolkit21zs
	
	

zBugsTest.test_bug_xmltoolkit21cCsTtjt�}tj|�}|j|jd�d�|j|jd�d�dS)Nr#r<zsection/tagr�)rrxr�r
r@rr)rrr!rrr�test_bug_xmltoolkit25�szBugsTest.test_bug_xmltoolkit25cCsTtjd�}|jt|jd��g�|jt|jd��dg�dS)Nz"<doc><table><tbody/></table></doc>z.//theadz.//tbodyZtbody)rrxr@r'rq)rr!rrr�test_bug_xmltoolkit28�szBugsTest.test_bug_xmltoolkit28c
CsLtjd�}tj��*}tj|�|j|j�d�WdQRXdS)Nz"<doc><table><tbody/></table></doc>z$<doc><table><tbody /></table></doc>
)rrxrZcaptured_stdout�dumpr@r)rr!�stdoutrrr�test_bug_xmltoolkitX1�s
zBugsTest.test_bug_xmltoolkitX1cCstjd�}|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#)rrxr@r�r=r?rt)rr!rrr�test_bug_xmltoolkit39�szBugsTest.test_bug_xmltoolkit39cCsEtjd�}|jt|dd�d�|jt|�d�dS)Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>rzus-asciis<doc>&#33328;</doc>u<doc>舰</doc>)rrxr@r")rr�rrr�test_bug_xmltoolkit54�szBugsTest.test_bug_xmltoolkit54c
CsF|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�rxr@r�r�)rr�rrr�test_bug_xmltoolkit55�szBugsTest.test_bug_xmltoolkit55cCs0Gdd�d�}|jttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSs
t�dS)N)rl)rrHrrrr��sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)rrrr�rrrr�
ExceptionFile�sr�)r�rlrr�)rr�rrr�test_bug_xmltoolkit60�szBugsTest.test_bug_xmltoolkit60cCsgddddi}tj�}|jj|�|jd�|j�}|j|jd�jd�dS)NZrsquou’Zlsquou‘aF<?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�r2�updater�r�r@ror<)rZENTITIESr��trrr�test_bug_xmltoolkit62�szBugsTest.test_bug_xmltoolkit62cCs]dd�}|�tjd�}xtd�D]
}|�q/W|jtjd�|�dS)NcSs:tj�}|jdi�|jd�|jd�dS)Nr#r<)rr�r�r�r�)r!rrr�xmltoolkit63�s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)r-�getrefcountr�r@)rr��countr�rrr�test_bug_xmltoolkit63�szBugsTest.test_bug_xmltoolkit63cCs�tjddd�}|jtj|�d�|jtjtj|��jd�d�|jtjtjtj|���d�dS)NZSomeTagr<zdef _f():
  return 3
s0<SomeTag text="def _f():&#10;  return 3&#10;" />)rr?r@r�rxr3)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>r^c@seZdZdd�ZdS)z2BugsTest.test_bug_200708_close.<locals>.EchoTargetcSs
tjd�S)Nr^)rr?)rrrrr�sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN)rrrr�rrrr�
EchoTargetsr�)rr�r�r@r�r#)rr�r�rrr�test_bug_200708_closes

zBugsTest.test_bug_200708_closecCstjd�}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}elemZdefault_namespacer�z%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>rz<cannot use non-qualified names with default_namespace option)	rr?r�r@r"r�r�r�r�)rr��sr�rrr�!test_bug_200709_default_namespaces z*BugsTest.test_bug_200709_default_namespacecCs�tjd�}|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/" />)rr?r@r��register_namespace)rr�rrr�"test_bug_200709_register_namespace0sz+BugsTest.test_bug_200709_register_namespacecCs�tjd�}|jtjd��|j|djtj�tjd�}|jtjd��|j|djtj�dS)Nrr�r)rr?rjr�r@r#rz)rrrrr�test_bug_200709_element_comment?sz(BugsTest.test_bug_200709_element_commentcCs�tjd�}tj|d�}tj|d�}tjd�}|jd|�|jt|�dddg�|jd|�|jt|�ddddg�dS)Nrr�r�r�rrN���)rr?r�rlr@r')rrr�r�r�rrr�test_bug_200709_element_insertKsz'BugsTest.test_bug_200709_element_insertcCsitjd�}tj|d�}tjd�}|j|�|jt|jtj��tjg�dS)Nrr�zTEST-b)rr?r�r�rjr@r'ru)rrr�Z	comment_brrr�test_bug_200709_iter_commentUs

z%BugsTest.test_bug_200709_iter_commentcCsbtj�}|jd�}|jdi�}|jd�}|j�}|jt|�d�dS)Nr�r#z<tag />)rr�r�r�r�r�r@r")rrGr�rrr�test_bug_1534630_szBugsTest.test_bug_1534630cCsZtjd�}|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>)rrxr@r�)rr�rrr�test_issue6233gszBugsTest.test_issue6233cCsNtjd�}|j|jd�tj|�}|jtj|�d�dS)Nz+<prefix:localname xmlns:prefix="${stuff}"/>z{${stuff}}localnames&<ns0:localname xmlns:ns0="${stuff}" />)rrxr@r#r
r�)rr�r�rrr�test_issue3151sszBugsTest.test_issue3151cCsttjd�}|jt|�dg�tjt�}|dd�|dd�<|jt|�dddg�dS)Nz<body><tag/></body>r#rD)rrxr@r'r�)rrZnewelemrrr�test_issue6565ys
zBugsTest.test_issue6565cCs$tjdd�tjdd�dS)NZ	test10777z
http://myuri/)rr�)rrrr�test_issue10777�szBugsTest.test_issue10777cs�G�fdd�d�}tjd��|��_�j�}t|�}|j||�|j�jt�|j�jd�dS)Ncs"eZdZ�fdd�ZdS)z%BugsTest.test_lost_text.<locals>.Textcs
d�_dS)N�changedT)r<)r)r�rr�__bool__�s	z.BugsTest.test_lost_text.<locals>.Text.__bool__N)rrrr�r)r�rrr~�sr~r#r�)rr?r<rvr�r>r�r@)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)Ncs"eZdZ�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~�sr~r�r#rr�)	rr?rjr;rvr�r>r�r@)rr~r�r�r)r�r�test_lost_tail�szBugsTest.test_lost_tailcs�G��fdd�d�}tjd���jtj|����jtjd���jd��yt��}Wntk
r�|jd�YnX|j|j|�|j�djt	�|j
�djd�dS)Ncs%eZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcs!tjd��d<t��dS)Nr�rT)rr?r�)rr�)r�r�rr�__eq__�s
z+BugsTest.test_lost_elem.<locals>.Tag.__eq__N)rrrr�r)r�r�rrr}�sr}r�r#zgenerators are not reentrantrr�)rr?rjrur�r�ZskipTestr>r#r�r@)rr}r�r)r�r�r�test_lost_elem�s
zBugsTest.test_lost_elemN)rrrryrzr{r~rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrvxs2			

rvc@sXeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BasicElementTestcCsgtjd�}|jt|jd�|jt|jtjd�dg�|jt|jdd�dS)N�joer�r�r�r)rr?r�rwrjrkrl)rr�rrr�test_augmentation_type_errors�s%z.BasicElementTest.test_augmentation_type_errorscCsLGdd�d�}|�}tjdd|�|_tj|�}~t�|j|��tjd�}|�}||_tj|�}tj|dd|�}~~~t�|j|��tjd�}tjd�}tjd�}|j|�|j|�|j|�tj|�}~~~t�|j|��dS)	Nc@seZdZdS)z.BasicElementTest.test_cyclic_gc.<locals>.DummyN)rrrrrrr�Dummy�sr�r��attrr�r�r�r�)	rr?Zdummyref�weakref�refrr�r�rj)rr�r��wrefr�r�r�r�rrr�test_cyclic_gc�s2				


	zBasicElementTest.test_cyclic_gccsyd��fdd�}tjd�}tj||�}|j|�jd�~|j�d�|j|�d�dS)NFcs
d�dS)NTr)�w)�flagrr�wref_cb�sz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)rr?r�r�r@r#)rr�r�r�r)r�r�test_weakref�szBasicElementTest.test_weakrefcCsctjddddddd�}|j|jddd	�d�|j|jd
dd	�d	�dS)Nr�rHrNrIr��zr�r��r�)rr?r@r3)rr�rrr�test_get_keyword_args�s!z&BasicElementTest.test_get_keyword_argscCs2x+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||�q3WqWdS)Nr�rN�repeatr�r��*ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrr�zother valuezxml.etree.ElementTree)r�r.�HIGHEST_PROTOCOLrr*r?r<r;r�rjrqrtr:r@r#r=rArD)rr8r6r7r�r�rrr�test_pickle�s"		"zBasicElementTest.test_picklecCs�x�tdtjd�D]�}x�t|jdd�D]�\}}d}|j|�}t|d�r}|j|j�dd�|j	|d|||�}|j|j
d�|j|d	j
d
�q3WqWdS)Nr�rNr�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r#�groupzxml.etree.ElementTreerZdogs)r�r.r�rr*ryr]r@r�r:r#)rr8r6r7ZXMLTEXTr�r�rrr�test_pickle_issue18997s"z'BasicElementTest.test_pickle_issue18997N)	rrrr�r�r�r�r�r�rrrrr��s#r�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�BadElementTestc
s�G�fdd�d�}|�g�tjd�}y|j��Wntk
rYYnXGdd�d|tj�}|d�g�tjd�}|j��dS)Ncs(eZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcs#tjd�g�dd�<tjS)N�baz)rr?)r)�Lrr�	__class__sz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N)rrr�propertyr�r)r�rr�Xsr�r�c@seZdZdS)z2BadElementTest.test_extend_mutable_list.<locals>.YN)rrrrrrr�Y)sr�rH)rr?rkrw)rr�r�r�r)r�r�test_extend_mutable_lists
z'BadElementTest.test_extend_mutable_listc
s�G�fdd�d�}|�tjd�g�tjd�}y|j��Wntk
reYnXGdd�d|tj�}|d�tjd�g�tjd�}|j��dS)Ncs(eZdZe�fdd��ZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjS)N)rr?)r)r�rrr�1s
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__N)rrrr�r�r)r�rrr�0sr�r�r�c@seZdZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.YN)rrrrrrrr�<sr�r�)rr?rkrw)rr�r�r�r)r�r�test_extend_mutable_list2/s
z(BadElementTest.test_extend_mutable_list2cs�G�fdd�dtj�}tjd���j|d�g�|jt�jtjd��tjd���jtjd�g�|jt�j|d��dS)Ncs"eZdZ�fdd�ZdS)z3BadElementTest.test_remove_with_mutating.<locals>.Xcs�dd�=dS)NFr)r�o)r�rrr�Ds
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__N)rrrr�r)r�rrr�Csr�r�r�r�)rr?rkr�r�rm)rr�r)r�r�test_remove_with_mutatingBsz(BadElementTest.test_remove_with_mutatingcCsNtjd�}t|d|��&|jt��t|�WdQRXWdQRXdS)Nr�r#)rr?rr��RuntimeErrorri)rr�rrr�test_recursive_reprOsz"BadElementTest.test_recursive_reprcs�G�fdd�dt�}tj�}|jdi�|jd�|j|d��|jd�|jd�|j��|j�jd�dS)Ncs"eZdZ�fdd�ZdS)z/BadElementTest.test_element_get_text.<locals>.Xcs$y�jWntk
rYnXdS)N)r<�	NameError)r)rrr�__del__Ys
z7BadElementTest.test_element_get_text.<locals>.X.__del__N)rrrr�r)rrrr�Xsr�r#�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�rr�r�r�r�r�r@r<)rr�r�r)rr�test_element_get_textVs


z$BadElementTest.test_element_get_textcs�G�fdd�dt�}tj�}|jdi�|jdi�|jd�|jd�|j|d��|jd�|jd�|j��|j�djd	�dS)
Ncs"eZdZ�fdd�ZdS)z/BadElementTest.test_element_get_tail.<locals>.Xcs(y�djWntk
r#YnXdS)Nr)r;r�)r)rrrr�ls
z7BadElementTest.test_element_get_tail.<locals>.X.__del__N)rrrr�r)rrrr�ksr�r�r#r�r�r�rr�)	r�rr�r�r�r�r�r@r;)rr�r�r)rr�test_element_get_tailis



z$BadElementTest.test_element_get_tailcCs�ddddgddddddi}tjd�}y|j|�Wntk
rd||_YnX|j�}|jt|�|�|jtt|�dS)Nr#Z	_childrenr=r�r;r<)	rr?�__setstate__�AttributeError�__dict__ruZassertIsr�r�)r�stater�rdrrr�test_element_iter~s	
z BadElementTest.test_element_itercs}G�fdd�d�}tjd���jtjd���d|���jtjd���dd|��dS)Ncs"eZdZ�fdd�ZdS)z%BadElementTest.test_subscr.<locals>.Xcs�dd�=dS)NrNr)r)r�rr�	__index__�s
z/BadElementTest.test_subscr.<locals>.X.__index__N)rrrr�r)r�rrr��sr�rr�rr�)rr?rj)rr�r)r�r�test_subscr�szBadElementTest.test_subscrcsrG�fdd�d�}tjd��x-td�D]}�jdtjd��q5Wg�dd|��<dS)Ncs"eZdZ�fdd�ZdS)z)BadElementTest.test_ass_subscr.<locals>.Xcsg�dd�<dS)NrNr)r)r�rrr��sz3BadElementTest.test_ass_subscr.<locals>.X.__index__N)rrrr�r)r�rrr��sr�rr�rr�)rr?r�rl)rr�r�r)r�r�test_ass_subscr�s
zBadElementTest.test_ass_subscrcCsbdd�}tjd|�}|jdi�|jd�|jt|jdi�~t�dS)NcSsgS)Nr)rHrIrrr�element_factory�sz>BadElementTest.test_treebuilder_start.<locals>.element_factoryr�r#r�r�)rr�r�r�r�r�r)rr�r�rrr�test_treebuilder_start�s
z%BadElementTest.test_treebuilder_startcCs_dd�}tjd|�}|jdi�|jd�|jt|jd�~t�dS)NcSsgS)Nr)rHrIrrrr��sz<BadElementTest.test_treebuilder_end.<locals>.element_factoryr�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�s

r�c@s(eZdZdd�Zdd�ZdS)�MutatingElementPathcGstj||�}||_|S)N)r��__new__r)r+r�argsrrrrr��s	zMutatingElementPath.__new__cCs|jdd�=dS)NT)r)rr�rrrr��szMutatingElementPath.__eq__N)rrrr�r�rrrrr��sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)NrNrr)rr�rrrr��szBadElementPath.__eq__N)rrrr�rrrrr��sr�cs|eZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�S)�BadElementPathTestcs6t�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r�r�r��tearDown)rr)r�rrr��szBadElementPathTest.tearDowncCsBtjd�}|jtjd�g�|jt|d��dS)Nr�r�rH)rr?rkror�)rr�rrr�test_find_with_mutating�sz*BadElementPathTest.test_find_with_mutatingcCsXtjd�}|jtjd�g�y|jtd��Wntk
rSYnXdS)Nr�r�rH)rr?rkror��ZeroDivisionError)rr�rrr�test_find_with_error�s
z'BadElementPathTest.test_find_with_errorcCsBtjd�}|jtjd�g�|jt|d��dS)Nr�r�rH)rr?rkrrr�)rr�rrr�test_findtext_with_mutating�sz.BadElementPathTest.test_findtext_with_mutatingcCsXtjd�}|jtjd�g�y|jtd��Wntk
rSYnXdS)Nr�r�rH)rr?rkrrr�r�)rr�rrr�test_findtext_with_error�s
z+BadElementPathTest.test_findtext_with_errorcCsBtjd�}|jtjd�g�|jt|d��dS)Nr�r�rH)rr?rkrqr�)rr�rrr�test_findall_with_mutating�sz-BadElementPathTest.test_findall_with_mutatingcCsXtjd�}|jtjd�g�y|jtd��Wntk
rSYnXdS)Nr�r�rH)rr?rkrqr�r�)rr�rrr�test_findall_with_errors
z*BadElementPathTest.test_findall_with_error)rrrr�r�r�r�r�r�r�r�rr)r�rr��sr�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ElementTreeTypeTestcCsv|jtjt�|jtjt�|jtjt�|jtjt�|jtjt�|jtjt�dS)N)	r>rr��typer8r
r?r�r�)rrrr�test_istype
szElementTreeTypeTest.test_istypecCs{Gdd�dtj�}|d�}|j|tj�|j||�|j|jd�d|_|j|jd�dS)Nc@seZdZdS)zDElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementN)rrrrrrr�	MyElementsr�r�r�)rr?r>r@r#r<)rr��myerrr�test_Element_subclass_trivials	z1ElementTreeTypeTest.test_Element_subclass_trivialcs�G�fdd�dtj���dddddidd	d
d�}|j|jd�|jt|j��d
dddg�dS)Ncs(eZdZi��fdd�Z�S)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcs$t�|�j|d||�dS)N�__)r�rd)rr#r=Zextra)r�r�rrrd!szQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)rrrrdr)r�)r�rr� sr�r�rrNr�r�r�r�r��Zfoo__)rrN)r�r�)r�r�)r�r�)rr?r@r#r�rX)rr�r)r�r�!test_Element_subclass_constructors
'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)rrrr�rrrrr�*sr�r�)rr?r@r�)rr�r�rrr� test_Element_subclass_new_method)sz4ElementTreeTypeTest.test_Element_subclass_new_methodN)rrrr�r�r�r�rrrrr�	s

r�c@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ElementFindTestcCsQtjt�}|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�nexttagr<r�rPr��togz<tag><empty /></tag>�empty)	rrxr�r@ror#�SAMPLE_SECTIONrrr�)rr�rrr�test_find_simple3sz ElementFindTest.test_find_simplecCsd}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]�classrz./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])rrxr@ror=�assertRaisesRegex�SyntaxError)rZ
LINEAR_XMLr�rrr�test_find_xpathJs     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�rFr�r#r�ztog/foorfrDz.//tagr�zsection/tagzsection//tagz	section/*r�Znextsectionz
section//*zsection/.//*z*/*z*//*z*/tagz*/./tagz./tagz././tagz.//tag[@class]r�z.//tag[@class="a"]z.//tag[@class="b"]z.//tag[@id]z.//section[tag]z.//section[element]z../tagzsection/../tagz	section//)rrxr�r�r@r'rq)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�)rrxr5r@r'rq)rr�rrr�test_test_find_with_ns�sz&ElementFindTest.test_test_find_with_nscCs�tjd�}ddi}|jt|jdd|��d�|jt|jdd|��d�ddi}|jt|jdd|��d	�|jt|jdd|��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�rN)rrxr@rArq)rr��nsmaprrr�test_findall_different_nsmaps�s	%%%z-ElementFindTest.test_findall_different_nsmapsc	Cs:tjt�}|jtd��|jd�WdQRXdS)Nzcannot use absolute pathz/tag)rrxr�r�r�rq)rr�rrr�
test_bad_find�szElementFindTest.test_bad_findcCs�tjt�}|jtj|�jd�jd�|jtj|�jd�d�|jttj|�j	d��dgd�|jttj|�j	d��dgd�dS)Nr#r<r�z//tagr�)
rrxr�r@r
ror#rrr'rq)rr�rrr�test_find_through_ElementTree�s%"!!z-ElementFindTest.test_find_through_ElementTreeN)
rrrr�r�r�r�rrrrrrrr�2s,
r�c@sgeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dS)�ElementIterTestNcCst|j|��S)N)r'ru)rrr#rrr�_ilist�szElementIterTest._ilistcCs�tjd�}|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d
tj
��}|jttj|d|��dd�tjd�}|jt|j�tjd�}|jdj|j	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>r/r�r�rPzthis is a paragraph...zthis is a paragraph.z
this is a rFrr�r�r�z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)rrxr@rror�rur#r�rvr"r�r�r�r
r�r�)rrBZ
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)Nrr�r�r�rNr)rr?r@rr�)rrr�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��shedrf)rrxr@rr'ru)rrB�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>r	r�r
r�r#r�rrf)rrxr@r'rw)rrBrrrr�test_getiterator	s	z ElementIterTest.test_getiteratorc	CsCtjd�}|j�}|jt��tj|�WdQRXdS)Nr)rr?rur�rwr�)rrrdrrrr�%	szElementIterTest.test_copycCsmtjd�}|j�}xKttjd�D]6}|jttjf��tj	||�WdQRXq/WdS)NrrN)
rr?rur�r.r�r�rwr1r/)rrrdr8rrrr�+	s
zElementIterTest.test_pickle)
rrrrrrr
rr�r�rrrrr�src@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dS)�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)Nr/r<rNrZdivr�r;)r@r#r<r;r=rBrA)rr�Zchildrenr�rrr�_check_sample1_element;	s
z&TreeBuilderTest._check_sample1_elementcCs�Gdd�d�}Gdd�d|�}tjd|��}|j|j�|j|j�d�tjd|��}|j|j�|j|j�d�tjdt��}|j|j�|j|j��dS)Nc@seZdZdd�ZdS)z<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuildercSsdS)Nr�r)rrrrr�J	szBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeN)rrrr�rrrr�BaseDummyBuilderI	src@s$eZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdS)Nr)rrrr�<lambda>N	szATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)rrrr�r�r�rrrr�DummyBuilderM	srr�r�)rr�r��sample1r@r��objectr�)rrrr�rrr�test_dummy_builderH	sz"TreeBuilderTest.test_dummy_buildercCsKtjdtjdd��}|j|j�|j�}|j|�dS)Nr�r�)rr�r�r�rr�r)rr�r�rrr�$test_treebuilder_elementfactory_none\	sz4TreeBuilderTest.test_treebuilder_elementfactory_nonecCszGdd�dtj�}|�}|j|jd�d�tjd|�}|j|j�|j�}|j|�dS)Nc@seZdZdd�ZdS)z4TreeBuilderTest.test_subclass.<locals>.MyTreeBuildercSs|dS)Nr�r)rrHrrr�foobard	sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN)rrrrrrrr�
MyTreeBuilderc	srr�r�r�)	rr�r@rr�r�rr�r)rr�tbr�r�rrr�
test_subclassb	s	zTreeBuilderTest.test_subclasscsmg��fdd�}tjd|�}tjd|�}|j|j�|j�|j�dg�dS)Ncs�j|�tj||�S)N)rjrr?)r#r=)�lstrr�	myfactoryr	s
z7TreeBuilderTest.test_element_factory.<locals>.myfactoryr�r�Ztoplevel)rr�r�r��sample2r�r@)rrrr�r)rr�test_element_factoryp	s
z$TreeBuilderTest.test_element_factorycCsatjd|�}tjd|�}|j|j�|j�}|j||�|j|�dS)Nr�r�)rr�r�r�rr�r>r)rr+rr�r�rrr�_check_element_factory_class~	sz,TreeBuilderTest._check_element_factory_classcCs*Gdd�dtj�}|j|�dS)Nc@seZdZdS)z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementN)rrrrrrrr��	sr�)rr?r )rr�rrr�test_element_factory_subclass�	sz-TreeBuilderTest.test_element_factory_subclasscCsFtj}|j|jd�Gdd�d|t�}|j|�dS)Nzxml.etree.ElementTreec@seZdZdS)zLTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementN)rrrrrrrr��	sr�)rZ_Element_Pyr@rr�r )r�baser�rrr�)test_element_factory_pure_python_subclass�	s	z9TreeBuilderTest.test_element_factory_pure_python_subclasscCsRGdd�d�}tjd|��}|j|j�|j|j�d�dS)Nc@s.eZdZdZdd�Zdd�ZdS)z3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNcSs|||f|_dS)N)�_doctype)rr5�pubid�systemrrr�doctype�	sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jS)N)r$)rrrrr��	sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)rrrr$r'r�rrrr�
DoctypeParser�	sr(r�r/�&-//W3C//DTD XHTML 1.0 Transitional//EN�7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r/r)r*)rr�r�rr@r�)rr(r�rrr�test_doctype�	s	zTreeBuilderTest.test_doctypeN)rrrrrrrrrrr r!r#r+rrrrr3	s
	
rc@sveZdZdZdZdZdd�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>cCsE|j|jd�|j|djd�|j|djd�dS)Nr r�lineZ22)r@r#r<)rr�rrr�_check_sample_element�	sz#XMLParserTest._check_sample_elementcCs�tjdtj�d�}|j|j�|j|j��tjdddigdtj��}|j|j�|j|j��dS)Nzutf-8rr/r�)rr�r�r�rr.r�)rr�Zparser2rrr�test_constructor_args�	s	z#XMLParserTest.test_constructor_argscCsIGdd�dtj�}|�}|j|j�|j|j��dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserN)rrrrrrr�MyParser�	sr0)rr�r�rr.r�)rr0r�rrrr�	s	zXMLParserTest.test_subclasscCs�tj�}|jt��|jddd�WdQRX|jd�|j�tj��;tj	dt�tj�}|j|j
�|j�WdQRXdS)Nr/z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdz<html/>�error)rr��assertWarns�DeprecationWarningr'r�r��warnings�catch_warnings�simplefilterr)rr�rrr�test_doctype_warning�	s


z"XMLParserTest.test_doctype_warningcsd�G�fdd�dtj�}|�}|jt��|j|j�WdQRX|j�|j�d
�d��tj	��wtj
dt�G�fdd�d�}|d	|��}|j|j�|j�|j��|j�d�WdQRXdS)Ncs"eZdZ�fdd�ZdS)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs|||f�dS)Nr)rr5r%r&)r$rrr'�	szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN)rrrr'r)r$rr�MyParserWithDoctype�	sr8r/�&-//W3C//DTD XHTML 1.0 Transitional//EN�7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdr1cs"eZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dS)Nr)rr5r%r&)�	_doctype2rrr'�	szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeN)rrrr'r)r;rrr(�	sr(r�)r/r9r:)r/r9r:)rr�r2r3r�rr�r@r4r5r6r�)rr8r�r(r)r$r;r�test_subclass_doctype�	s(	
	



	z#XMLParserTest.test_subclass_doctypecCsdtj��Qtjdt�Gdd�dtj�}|�}|j|j�|j�WdQRXdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)r1c@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeN)rrrrrrr�MyParserWithoutDoctype�	sr=N)	r4r5r6r3rr�r�rr�)rr=r�rrr�test_inherited_doctype�	s
	z$XMLParserTest.test_inherited_doctypecCsutjdtj��}|j|j�|j�}|j|jd�|j|jdd�|j|j	d�dS)Nr�ZmoneyrUu
$£€𐅻)
rr�r�r��sample3r�r@r#r=r<)rr�r�rrr�test_parse_string
szXMLParserTest.test_parse_stringN)
rrrrrr?r.r/rr7r<r>r@rrrrr,�	s
r,c@seZdZdd�ZdS)�NamespaceParseTestcCs�ddddi}tjt�}|jt|jd|��d�|jt|jd|��d�|jt|jd	|��d�dS)
N�hZhellor�r�z{hello}tablerNz.//{hello}tdr�z.//{foo}name)rry�SAMPLE_XML_NS_ELEMSr@rArq)rrrBrrr�test_find_with_namespace
s
""z+NamespaceParseTest.test_find_with_namespaceN)rrrrDrrrrrA
srAc@s�eZdZdd�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%
s	z1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)rZelemlistrrr�
_elem_tags
szElementSlicingTest._elem_tagscCs|jt|��S)N)rFrB)rrrrr�
_subelem_tags
sz ElementSlicingTest._subelem_tagscCs>tjd�}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.

        rza%s)rr?r�r�)rZnumchildrenr�r�rrr�_make_elem_with_children
sz+ElementSlicingTest._make_elem_with_childrencsy|jd��|j�djd�|j�d	jd�|jt�fdd��|jt�fdd��dS)
Nr�rN�a1r��a8cs�dS)N�rr)r�rrr/
sz?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)NrKi�rr)r�rrr0
s���)rHr@r#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)
N�r��a3�a4�a5�rRrNr��a0rIr�)rHr@rF)rr�rrr�test_getslice_range2
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��rNrJZa9r�rTrPZa6rI�@)rHr@rFr-�maxsize)rr�rrr�test_getslice_steps<
s,2,,,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�rNrP�a2rIrTr�r�rWr�rL)rHr@rFr-rX)rr�rrr�test_getslice_negative_stepsF
s2,-1z/ElementSlicingTest.test_getslice_negative_stepscCsc|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�rZrPrNrTrIr�rL)rHr@rG)rr�rrr�
test_delsliceO
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�rNrTrZrPr�r�r�rRrL���)rHrr?r@rGr�rM)rr�rrr�test_setslice_single_indexh
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�cSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%x
s	z:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�rNr�rT�b0�b1rPr�cSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%�
s	Zb2)rHr�r@rGrr?)rr�rrr�test_setslice_rangev
s#%"#z&ElementSlicingTest.test_setslice_rangecCs�|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)NrOcSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%�
s	z:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�rNrRrTr_rZr`rQrRr�cSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%�
s	r�rIrPr�r�rW)
rHr�r@rGr�r�rr?r-rX)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�cSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%�
s	zCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rrNrTr`r_rPr�cSs#g|]}tjd|��qS)zb%s)rr?)r$r�rrrr%�
s	r�rIrZr�r�rWr�r�r�r�)
rHr�r@rGr�r�rr?r-rX)rr�rrr�test_setslice_negative_steps�
s$&%&-%#%'%'z/ElementSlicingTest.test_setslice_negative_stepsN)rrrrFrGrHrNrUrYr[r\r^rarbrcrrrrrE
s
	

	
rEc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZGdd�d�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�IOTestcCstjt�dS)N)r�unlinkr)rrrrr��
szIOTest.tearDownc
Cs�tjd�}d|_|jt|�d�xcdD][}|j|��C|jt|d|�d�|jt|d|j��d�WdQRXq5Wx�d D]{}|j|��c|jt|d|�d|j|��|j�}|jt|d|�d|j|��WdQRXq�Wtjd�}d|_|jt|�d
�|jt|dd�d�|jt|dd�d�x7d!D]/}|jt|d|�d|j|��q�Wtjd�}d|jd<|jt|�d�|jt|dd�d�|jt|dd�d�x7d"D]/}|jt|d|�d|j|��q+Wtjd�}d|_|jt|�d�|jt|dd�d�|jt|dd�d�x7d#D]/}|jt|d|�d|j|��q�Wtjd�}d|jd<|jt|�d�|jt|dd�d�|jt|dd�d�x7d$D]/}|jt|d|�d|j|��qoWdS)%Nr#�abcz<tag>abc</tag>�utf-8�us-asciirs<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>rVz"<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;" />)rgrh)rirjrk)rirjrk)rirjrk)rirjrk)rirjrlrmrk)	rr?r<r@r"rT�upperr�r=)rr�encrnrrrr-�
s|	

	


	


zIOTest.test_encodingc
CsXtjtjd��}|jt�ttd��}|j|j�d�WdQRXdS)Nz<site />r�s<site />)rr
rxrrr�r@r�)rr!r�rrr�test_write_to_filename�
s
zIOTest.test_write_to_filenamecCs�tjtjd��}ttddd��*}|j|dd�|j|j�WdQRXttd��}|j|j	�d�WdQRXdS)Nz<site />r�rzutf-8rr�s<site />)
rr
rxr�rrr�r�r@r�)rr!r�rrr�test_write_to_text_file�
szIOTest.test_write_to_text_filecCs�tjtjd��}ttd��$}|j|�|j|j�WdQRXttd��}|j|j	�d�WdQRXdS)Nz<site />r�r�s<site />)
rr
rxr�rrr�r�r@r�)rr!r�rrr�test_write_to_binary_files
z IOTest.test_write_to_binary_filec Cs
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�rzutf-16r�z0<?xml version='1.0' encoding='utf-16'?>
<site />�	bufferingr)rr
rxr�rrr�r�r@r�r�)rr!r�rrr�"test_write_to_binary_file_with_bom
sz)IOTest.test_write_to_binary_file_with_bomcCsEtj�}tjd�}|j|�|j|j�jd�dS)Nz"<?xml version="1.0"?><site></site>�site)rr
rrr�r@rgr#)rr!r�rrr�test_read_from_stringio s
zIOTest.test_read_from_stringiocCsQtjtjd��}tj�}|j|dd�|j|j�d�dS)Nz<site />rr)rr
rxrrrr@r)rr!r�rrr�test_write_to_stringio&szIOTest.test_write_to_stringiocCsEtj�}tjd�}|j|�|j|j�jd�dS)Ns"<?xml version="1.0"?><site></site>ru)rr
rrr�r@rgr#)rr!�rawrrr�test_read_from_bytesio,s
zIOTest.test_read_from_bytesiocCsKtjtjd��}tj�}|j|�|j|j�d�dS)Nz<site />s<site />)rr
rxrrrr@r)rr!rxrrr�test_write_to_bytesio2s
zIOTest.test_write_to_bytesioc@seZdZdS)zIOTest.dummyN)rrrrrrr�dummy8sr{cCs]tjd�}|j�}|j|_tj�}|j|�|j|j�j	d�dS)Nz"<?xml version="1.0"?><site></site>ru)
rrr{r�rr
r�r@rgr#)rr��readerr!rrr�test_read_from_user_text_reader;s
z&IOTest.test_read_from_user_text_readercCsitjtjd��}tj�}|j�}|j|_|j|dd�|j|j�d�dS)Nz<site />rr)	rr
rxrrr{rr@r)rr!r��writerrrr�test_write_to_user_text_writerCsz%IOTest.test_write_to_user_text_writercCsitjd�}|j�}|j|_tj�}|j|�|j|j�j	d�tj�}dS)Ns"<?xml version="1.0"?><site></site>ru)
rrr{r�rr
r�r@rgr#)rrxr|r!rrr�!test_read_from_user_binary_readerKs
z(IOTest.test_read_from_user_binary_readercCsctjtjd��}tj�}|j�}|j|_|j|�|j|j�d�dS)Nz<site />s<site />)	rr
rxrrr{rr@r)rr!rxr~rrr� test_write_to_user_binary_writerTs
z'IOTest.test_write_to_user_binary_writercCs�tjtjd��}tj�}|j�}|j|_dd�|_|j|_|j|dd�|j	|j
�djd��dS)Nz<site />cSsdS)NTrrrrrraszBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>rzutf-16z0<?xml version='1.0' encoding='utf-16'?>
<site />)rr
rxrrr{r�seekable�tellr@rr�)rr!rxr~rrr�)test_write_to_user_binary_writer_with_bom\sz0IOTest.test_write_to_user_binary_writer_with_bomcCsutjd�}|jtj|d�djtj|d���|jtj|d�djtj|d���dS)Nz<tag>foo</tag>rrPzutf-16r�)rryr@r�r�r�)rr�rrr�test_tostringlist_invarianthsz"IOTest.test_tostringlist_invariantcCsstjd�}|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>Zshort_empty_elementsTFz<tag>a<x></x>b<y></y>c</tag>)rryr@r�)rr�rrr�test_short_empty_elementsqsz IOTest.test_short_empty_elementsN)rrrr�r-rprqrrrtrvrwryrzr{r}rr�r�r�r�r�rrrrrd�
s$E		rdc@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|jtj�t�dS)N)r>rr�r�)rrrrrszParseErrorTest.test_subclasscCsDytj|�Wn,tjk
r?}z	|SWYdd}~XnXdS)N)rryr�)rr�r�rrr�
_get_error�szParseErrorTest._get_errorcCsX|j|jd�jd�|j|jd�jd	�|j|jd�jd
�dS)Nr�rNrz<tag>&foo;</tag>rRzfoobar<rO)rNr)rNrR)rNrO)r@r�Zposition)rrrr�test_error_position�sz"ParseErrorTest.test_error_positioncCs?ddljjj}|j|jd�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errorsZparsersZexpat�errorsr@r��codeZcodesZXML_ERROR_SYNTAX)rZERRORSrrr�test_error_code�szParseErrorTest.test_error_codeN)rrrrr�r�r�rrrrr�~sr�c@seZdZdd�ZdS)�KeywordArgsTestcCswtjd�}|j|jdd�|jdddd��|j|jddd�|jdddddd��|j|jdd�|jdddd��|jt|jdd��t|jdddd���|jtjd�j	i�tjdt
dddd	��tjdd
t
dddd	��tjdt
dd�dd	�tjddddd	�tjdt
dddd	�dddd	�g}xC|D];}|j|jd�|j|j	t
dddd	��q�Wtj|ddd
d
di�}|j|j	d
d�|j
td��tjdd�WdQRX|j
td��tjdd
d�WdQRXdS)Nz
<a>foo</a>r�pathrr�rm�#�idr�r=rrZkey1Zvalue1zmust be dict, not strzI'm not a dict)rrxr@rorrrqrBrpr?r=r2r#r�r�rw)rrH�elementsr�r�rrr�test_issue14818�s0!0
&"zKeywordArgsTest.test_issue14818N)rrrr�rrrrr��sr�c@s(eZdZdd�Zdd�ZdS)�NoAcceleratorTestcCststjd��dS)Nzonly for the Python version)r)�unittest�SkipTest)rrrrr��szNoAcceleratorTest.setUpcCs6|jtjjtj�|jtjjtj�dS)N)r>r)r?rd�types�FunctionTyper�)rrrr�test_correct_import_pyET�sz*NoAcceleratorTest.test_correct_import_pyETN)rrrr�r�rrrrr��sr�c@sCeZdZdZdZddd�Zdd�Zdd	�ZdS)
�CleanContextz1Provide default namespace mapping and path cache.NFcCsUtjjdkrd}dtfdtfdtff}tj|d|�|_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)	r-�flags�optimize�
FutureWarningr3�PendingDeprecationWarningrZcheck_warnings�
checkwarnings)rr�Zdeprecationsrrrrd�szCleanContext.__init__cCs`ddlm}tjj|_|jj�|_|j|_	|j	j�|_|j
j�dS)Nr)r)r
rrr�Z_namespace_map�_nsmapr��_nsmap_copyr��_path_cacher��	__enter__)rrrrrr��szCleanContext.__enter__cGsPddlm}|jj�|jj|j�|j|_|jj	|�dS)Nr)r)
r
rr�rsr�r�r�r�r��__exit__)rr�rrrrr��s

zCleanContext.__exit__)rrr�__doc__r�rdr�r�rrrrr��s

r�cCs�tdddg�a|dkr't}|attttttt	t
ttt
tttttg}ttk	r|jtg�z.tdttk	��tj|�WdQRXWddaaXdS)Nzxml.etree.ElementTreeZblockedZ_elementtreer�)rr)rr	rEr�r�r�rKrdr�rir�r�rrr,rMrvrkr�r�rZrun_unittest)�moduleZtest_classesrrr�	test_main�s8		
r��__main__)Cr�r/rrEr.r-r�r�r4r��	itertoolsrr�rZtest.supportrrrrrr)rr�r��UnicodeEncodeErrorr�r�r�r�r5rCr3ZTestCaser	r"r'r(rKrMrj�format�escapertrirvr�r�r�r��__hash__r�r�r�r�rrr,rArErdr�r�r�rr�r�rrrrr�<module>s�(




#���]�
	








��G]�4)�xc
��$(0