HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //proc/thread-self/root/usr/local/lib/python3.7/test/__pycache__/test_xml_etree.cpython-37.pyc
B

��g���@sDddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZmZmZmZmZdadaeddd�Zye�d�Wnek
r�e�d	��YnXed
dd�Zeddd�ZdZd
ZdZdZ dZ!dZ"dd�dd�Z#Gdd�dej$�Z%dadd�Z&dd�Z'Gdd�d�Z(Gd d!�d!ej$�Z)Gd"d#�d#ej$�Z*iZ+d$e+d%<d&e+d'<d(e+d)<d*e+d+<d,e+d-<d.e+d/<d0e+d1<d2e+d3<d4�,e�-ed��e+d5<iZ.d6e.d7<d8e.d9<Gd:d;�d;ej$�Z/Gd<d=�d=ej$�Z0Gd>d?�d?e(ej$�Z1Gd@dA�dAe(ej$�Z2GdBdC�dCe3�Z4e3j5e4_5GdDdE�dEe3�Z6e3j5e6_5GdFdG�dGe(ej$�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[ej$�ZAGd\d]�d]ej$�ZBdbd^d_�ZCeDd`k�r@eC�dS)c�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>
F)�quietcs��fdd�}|S)Ncs ���fdd�}t�|��|S)Nc	s*tj�d�i���||�WdQRXdS)Nr	)rZcheck_warnings)�args�kwargs)�filtersr	�test��//usr/local/lib/python3.7/test/test_xml_etree.py�newtestgsz1checkwarnings.<locals>.decorator.<locals>.newtest)�	functools�update_wrapper)r
r)rr	)r
r�	decoratorfsz checkwarnings.<locals>.decoratorr)r	rrr)rr	r�
checkwarningsesrc@seZdZdd�Zdd�ZdS)�
ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr)�ElementTree)�ElementInclude)�ElementPath)�	xml.etreerrr)�selfrrrrrr�test_sanitypszModuleTest.test_sanitycCsd}tj|t|dd�dS)N)zxml.etree.ElementTree�_elementtree)Z
HTML_EMPTY)Z	blacklist)rZcheck__all__�ET)r�namesrrr�test_allwszModuleTest.test_allN)�__name__�
__module__�__qualname__rrrrrrrosrT�unicodecKsX|dkrt��}nt��}t�|�}|j|fd|i|��|rF|��S|�d�|SdS)Nr#�encodingr)�io�BytesIO�StringIOrr�write�getvalue�seek)�elem�	to_stringr$�options�file�treerrr�	serialize|s


r0cCsdd�|D�S)NcSsg|]
}|j�qSr)�tag)�.0r+rrr�
<listcomp>�sz"summarize_list.<locals>.<listcomp>r)�seqrrr�summarize_list�sr5c@s(eZdZedd��Zdd�Zdd�ZdS)�ElementTestCasecCstth|_dS)N)�pyETr�modules)�clsrrr�
setUpClass�szElementTestCase.setUpClasscCs�tj|}z�y.|tj|<t�||�}|tj|<t�|�}Wn^tjk
r�}	z>ttdftdfg�}
t	�
d||
�||�|
�||�f�|	�Wdd}	~	XYnXWd|tj|<X|S)NZcETr7z%Failed to round-trip %r from %r to %r)�sysr8�pickle�dumps�loads�
PicklingError�dictrr7rZ
TestFailed�get)r�obj�name�dumper�loader�protoZsave_mZtemp�resultZpeZhumanrrr�pickleRoundTrip�s



*zElementTestCase.pickleRoundTripcCs�|�|tjtjf�|�|tjtjf�|�tt|��tt|���x"t||�D]\}}|�||�qPWt	�
dddd�}|�||�||��dS)Nr1�tail�text�attrib)�assertIsInstancer�Elementr7�assertEqual�len�list�zip�assertEqualElements�operator�
attrgetter)rZalice�bob�x�yZ
propertiesrrrrR�sz#ElementTestCase.assertEqualElementsN)r r!r"�classmethodr:rHrRrrrrr6�sr6c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zedeeff�d d!��Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Z d8S)9�ElementTreeTestcCs|�t|�|�dS)N)rNr0)rr+�expectedrrr�serialize_check�szElementTreeTest.serialize_checkcs��fdd���fdd������fdd��t�d�}�|�t�|�}�|���tjdd	d
�}t�|�}��t|�d�tjdd	d
�}�fdd
���|j��|j��|j��|j	��|j
��|j��|j��|j
��|j��|j��|j��|j��|j��|j��|j��|j��|j��fdd�}||�d��||�d��||�d��||�d����tjtj���tjtj�dS)NcsNt|�x$|D]}�jt|�dd|d�qW|d}|d}|dd�dS)N�z%expected one-character string, got %r)�msg�� r)rOrN)�string�charZ
new_string)rrr�check_string�s
z4ElementTreeTest.test_interface.<locals>.check_stringcsVt|�|��}|��}x|D]}||}qWd|d<�j|ddd|dd�dS)N�value�keyzexpected value string, got %r)r])rO�keys�itemsrN)�mappingrerfrd�item)rrr�
check_mapping�s
z5ElementTreeTest.test_interface.<locals>.check_mappingcs��jt�|�dd�t|�}x8dD]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)r])r1rKrJrIzno %s memberzno %s visible by dir)
�
assertTruerZ	iselement�dir�hasattrZassertInr1rKrJrI)�elementZdirelem�attrr+)�
check_elementrirbrrrro�s







z5ElementTreeTest.test_interface.<locals>.check_elementr1utägrc)rdz^<Element 't\xe4g' at 0x.*>$cs�jt|d�d|d�dS)N�__call__z%s not callable)r])rjrl)�method)rrr�check_method�sz4ElementTreeTest.test_interface.<locals>.check_methodcs�|j�dS)N)�__next__)�it)rrrr�
check_itersz2ElementTreeTest.test_interface.<locals>.check_iter�*)rrMr�getroot�assertRegex�repr�append�extend�insert�remove�getchildren�find�iterfind�findall�findtext�clearrA�setrerf�iter�itertext�getiteratorrN�XML�
fromstring�PI�ProcessingInstruction)rrmr/rur)rorirrrbrr�test_interface�sH	




















zElementTreeTest.test_interfacecCs�t�d�}|�|jd�d|_|�|jd�d|_|�|jd�|�|j�d|_|�|jd�d|_|�|jd�|�|j�d|_|�|jd�d|_|�|jd�|�|ji�dd	d
�|_|�|jdd	d
��ddd
�|_|�|jddd
��dS)Nr1�TagZTAG�TextZTEXTZTailZTAIL�b�d)�a�c�B�D)�A�C)rrMrNr1�assertIsNonerJrIrK)rrmrrr�test_set_attribute
s*
z"ElementTreeTest.test_set_attributec	Cs�t�d�}|�|d�t�d�}|�|�|�|d�|�|�|�|d�|�d|�|�|d�|�|�|�|g�|�|d�|�|�tjddd	�}|�|d
�t�d�}|�|�|�|d�|�d|�|�|d
�|�|�|�|d�|�|�|�|d
�|�t	��}|�|�WdQRX|�
t|j�d�|�|d
�|||g|dd�<|�|dd�|�
|dd�|d|dg�|�
|ddd�|d|dg�|dd�=|�|d
�dS)Nz<body><tag/></body>z<body><tag /></body>�tag2z<body><tag /><tag2 /></body>rz<body><tag2 /><tag /></body>r1rc)rdz<tag key="value" />�subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in listr\z
<subtag />�	�)
rr�r[rMrzr}r|r{�assertRaises�
ValueErrorrN�str�	exception)rr+�ermZ
subelement�cmrrr�test_simpleops(sH









 "
zElementTreeTest.test_simpleopscCs:|�t�d�d�|�t�d�d�|�t�d�d�dS)Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)r[rr�)rrrr�
test_cdataQszElementTreeTest.test_cdatacCs|t�t�d��}tj|d�}|�|�d�jd�|�|�d�jd�tjt	d�}|�|�d�jd�|�|�d�jd�dS)Nzutf-8)r.r1zsection/tagrmzelement/../empty-elementz
empty-element)
r%r&�
SAMPLE_XML�encoderrrNrr1�SIMPLE_XMLFILE)rZ
stringfiler/rrr�test_file_init[szElementTreeTest.test_file_initcCsddlm}t�t�}x(td�D]}t�|��dt|��q Wt	|j
�}x(td�D]}t�|��dt|��qTW|�t	|j
�|�x(td�D]}t�|��dt|��q�W|�t	|j
�|�x(td�D]}t�|��dt|��q�W|�
t	|j
�d�dS)Nr)r�
z./�iXi�)rrrr�r��rangerrr�rO�_cacherNZ
assertGreaterZ
assertLess)rrr+�iZcache_len_10rrr�test_path_cachefs

zElementTreeTest.test_path_cachecCsZddl}t�d�}|�|�}|�|�}d|�d�_|�|d�|�|d�|�|d�dS)Nrz<tag>hello<foo/></tag>�bar�fooz<tag>hello<bar /></tag>z<tag>hello<foo /></tag>)�copyrr�Zdeepcopyrr1r[)rr��e1�e2�e3rrr�	test_copyus


zElementTreeTest.test_copycCs"t�d�}|�d�|�|�dd�d�|�dd�|�|�d�d�tjddd�}|�|�d�d�|�|jddi�ddi}t�d|�}|��|�|�d�d�|�|jddi�ddi}tjd|�}|��|�|�d�d�|�|jddi�tjdddidd�}|�|�d�d�|�|jddi�t�d�}d|_|�d	d
�|�dd�|�t�|�d
�|�t	|�
��d	dg�|�t	|���ddg�|�|jdd�d|jd<d|jd<|�t�|�d�t�d�}|�dd�|�dd�|�dd�|�dd�|�t�|�d�dS)Nr1rd�defaultrc)rd�otherr
Zaa�testa�testval�testb�test2s-<test testa="testval" testb="test2">aa</test>)r�r�)r�r�Ztest1Ztestcs;<test testa="testval" testb="test1" testc="test2">aa</test>r��
r�z
r�z	

 r�z

s@<test a="&#10;" b="&#10;" c="&#09;&#10;&#10; " d="&#10;&#10;" />)r1)rrMrArNr�rKr�rJ�tostring�sortedrerf)rr+rKrrr�test_attrib�sT






zElementTreeTest.test_attribcCs�t�d�}ddi}|�d|�}|j|j|dd�|�|�|�|d�|��|�|d�|�|�|�|d�|�||g�|�|d	�|g|dd�<|�|d�t	|g�|dd�<|�|d�dS)
Nr1rdrcr�zattrib aliasing)r]z!<tag><subtag key="value" /></tag>z<tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
rrMZmakeelementZassertIsNotrKrzr[r�r{�tuple)rr+rK�subelemrrr�test_makeelement�s"


z ElementTreeTest.test_makeelementc	Cs�t�t�}t��}|j|dd�|�|��d�t�t�}t��}|j|dd�|�|��d�t	t��}|�
�}WdQRXt��}|�|j
d�|�|�|�|��d�t��}tj|d�}|�|�|�|��d�dS)Nr#)r$zi<root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>z�<ns0:root xmlns:ns0="namespace">
   <ns0:element key="value">text</ns0:element>
   <ns0:element>text</ns0:element>tail
   <ns0:empty-element />
</ns0:root>z^Expat )�target)r�parser�r%r'r(rNr)�SIMPLE_NS_XMLFILE�open�read�	XMLParserrx�version�feedr[�close�TreeBuilder)rr/�stream�f�data�parserr�rrr�test_parsefile�s,








zElementTreeTest.test_parsefilecCs�t�d�}|�tj|dd�d�t�d�}|�tj|dd�d�dddg}t�|�}|�t�|�d�|�d�t�|��d�|�t�|d	�d
�t�d�\}}|�t	|�d�t�d�\}}|�t	|�d
�|�|dj
d�dS)Nz<html><body>text</body></html>r#)r$z<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>r\�body)rr�rNr�r�Zfromstringlist�join�tostringlistZXMLIDrOr1)rrmZsequence�_Zidsrrr�test_parseliteral�s&



z!ElementTreeTest.test_parseliteralc
Cs@tj}|t�}t|�\}}|�||jfd�|�dd�|D�dddg�|�|jjd�|t�}|�dd�|D�ddd	d
g�d}|t|�}|�dd�|D�g�d}|t|d
�}|�dd�|D�g�d}|t|�}|�dd�|D�ddddddddg�d}|t|�}|�dd�|D�dddddddd	d
dg
�d}|t�	d�|�}dd�|D�}|�|ddg�d }t
td!��2}|�t��}|||�WdQRX|�
|j�WdQRX|�t|j�d"�t�|��:|�t��}|t|�WdQRX|�t|j�d"�~WdQRXt�d#�}	d$}||	|�}|�d%d�|D�d&d'g�t�	d(�}	||	�}
t|
�\}}|�||jfd)�|�tj��}t|
�WdQRX|�t|j�d*�|�tjt�t
td+��}|�d,�WdQRX|t�}
t|
�\}}|�||jfd)�t�|��<|�tj��}t|
�WdQRX|�t|j�d*�~~
WdQRXdS)-N)�endrmcSsg|]\}}||jf�qSr)r1)r2�actionr+rrrr3sz2ElementTreeTest.test_iterparse.<locals>.<listcomp>)r�z
empty-element)r��rootr�cSsg|]\}}||jf�qSr)r1)r2r�r+rrrr3s)r�z{namespace}element)r�z{namespace}empty-element)r�z{namespace}rootrcSsg|]\}}||jf�qSr)r1)r2r�r+rrrr3(s)�eventscSsg|]\}}||jf�qSr)r1)r2r�r+rrrr3,s)�startr�cSsg|]\}}||jf�qSr)r1)r2r�r+rrrr30s)r�r�)r�rm)r�z
empty-element)r�r�zstart-nszend-nscSs*g|]"\}}|dkr||jfn||f�qS))r�r�)r1)r2r�r+rrrr3=s)zstart-ns)r^�	namespace)r�z{namespace}root)r�z{namespace}element)r�z{namespace}empty-element)zend-nsN)zstart-nszend-nsz<root xmlns=''/>cSsg|]\}}|�qSrr)r2r�r+rrrr3Nszstart-nszend-ns)r�r��bogus�rbzunknown event 'bogus's�<?xml version='1.0' encoding='iso-8859-1'?>
<body xmlns='http://&#233;ffbot.org/ns'
      xmlns:cl�='http://effbot.org/ns'>text</body>
)zstart-nscSsg|]\}}||f�qSrr)r2r�r+rrrr3ds)zstart-ns)r^uhttp://éffbot.org/ns)zstart-ns)uclézhttp://effbot.org/nsz<document />junk)r��documentz.junk after document element: line 1, column 12�wbs<document />junk)r�	iterparser��nextrNr1r�r�r%r'r�r�r��assertFalse�closedr�r�rZcheck_no_resource_warningr&�
ParseError�
addCleanup�unlinkrr()rr��contextr�r+r�Zresr�r��sourcertrrr�test_iterparses�





zElementTreeTest.test_iterparsecCs�t�d�}d|_|�|d�dt�|d�_|�|d�d|_|�|d�|�dt�d	��|�|d
�t�dd�|d<|�|d
�dS)Nr1rJz<tag>text</tag>�subtextr�z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r�commentz*text<!--comment--><subtag>subtext</subtag>rdrcz)text<?key value?><subtag>subtext</subtag>)	rrMrJr[�
SubElementr1r|�Commentr�)rr+rrr�test_writefiles
zElementTreeTest.test_writefilec
Cs�tt��}|��}WdQRXGdd�dt�}|�}tj|d�}|�|�|�|dddddddd	g�tt��}|��}WdQRXGd
d�dt�}|�}tj|d�}|�|�|�|ddd
dddddddg
�dS)Nc@s$eZdZdd�Zdd�Zdd�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|�d|f�dS)Nr�)rz)rr1rKrrrr��sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|�d|f�dS)Nr�)rz)rr1rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rrJrrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.dataN)r r!r"r�r�r�rrrr�Builder�sr�)r�)r�r�)r�rm)r�rm)r�z
empty-element)r�z
empty-element)r�r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)z4ElementTreeTest.test_custom_builder.<locals>.BuildercSs|�d|f�dS)Nr�)rz)rr1rKrrrr��sz:ElementTreeTest.test_custom_builder.<locals>.Builder.startcSs|�d|f�dS)Nr�)rz)rr1rrrr��sz8ElementTreeTest.test_custom_builder.<locals>.Builder.endcSsdS)Nr)rrJrrrr��sz9ElementTreeTest.test_custom_builder.<locals>.Builder.datacSs|�d||f�dS)N�pi)rz)rr�r�rrrr��sz7ElementTreeTest.test_custom_builder.<locals>.Builder.picSs|�d|f�dS)Nr�)rz)rr�rrrr��sz<ElementTreeTest.test_custom_builder.<locals>.Builder.commentN)r r!r"r�r�r�r�r�rrrrr��s
)r�r�r�)r�z	 comment )r�z{namespace}root)r�z{namespace}element)r�z{namespace}element)r�z{namespace}empty-element)r�z{namespace}empty-element)r�z{namespace}root)	r�r�r�rPrr�r�rNr�)rr�r�r�Zbuilderr�rrr�test_custom_builder�s@



z#ElementTreeTest.test_custom_builderz@This method will be removed in future versions.  Use .+ instead.c	Cslttd��}t�|�}WdQRX|�dd�|����D�dddggggg�|�dd�|��D�dddggggg�t�t	�}|�t
|���d�|�t
|d���d	�|�|dd�|���|d
}|d}|d	d�=|�t
|���d�|�||d
�|�||d	�||g|d
d�<|�||d
�|�||d	�|�||d
�|�
�|�|��g�dS)Nr�cSsg|]}t|����qSr)r5r~)r2r+rrrr3�sz4ElementTreeTest.test_getchildren.<locals>.<listcomp>rmz
empty-elementcSsg|]}t|����qSr)r5r~)r2r+rrrr3�s�r�r\r)r�r�rr�rNrwr�r�r�r�rOr~�assertNotEqualr�)rr�r/r+Zchild1Zchild2rrr�test_getchildren�s<




z ElementTreeTest.test_getchildrencCs<t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nz<html><body>text</body></html>s<html><body>text</body></html>)rr�rNr�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] }��t�t�||���dS�q�WdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddeg}x"|D]}��ttj||���q@Wdfdgdhdidjdkdldmdndog
}x$|D]}��tjtj||���q|W��ttj�dp��d����ttj�dq��d��dS)sNr^cs>d||f}��t�|�|��j|���t�|�j|�dS)Nz0<?xml version='1.0' encoding='%s'?><xml>%s</xml>)rNrr�r�rJ)r$r��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)r$rrrr�sz*ElementTreeTest.test_encoding.<locals>.xmlcs�|��|�S)N)r�)r$)r�rr�bxmlsz+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^)	rNrr�r�r�r�r�r��LookupError)rr�r�Zsupported_encodingsr$Z&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsr)rr�r�
test_encoding�sR








 


zElementTreeTest.test_encodingcCstt�d�}d|_|�t|�d�|�t|dd�d�|�t|dd�d�|�t|dd�d�|�t|dd�d	�dS)
Nz-<html><link/><script>1 &lt; 2</script></html>�
z/<html><link /><script>1 &lt; 2</script></html>
)rqr��htmlz*<html><link><script>1 < 2</script></html>
rJz1 < 2
)rr�rIrNr0)rr�rrr�test_methods2s

zElementTreeTest.test_methodscCs2t�d�}|�t|�d�|�t|dd�d�dS)Nz(<html><CamelCase>text</CamelCase></html>r-)rq)rr�rNr0)rr�rrr�test_issue18347As


zElementTreeTest.test_issue18347c	Cs�t�d�}|�t|dd�d�|�|d�|�tj��}t�d�WdQRX|�t|j�d�|�tj��}t�t	�WdQRX|�t|j�d�t�
�}d	|jd
<|�t	�|�
�}|�|d�|�tj��}t�t�WdQRX|�t|j�d�dS)
Nz*<document title='&#x8230;'>test</document>zus-ascii)r$s*<document title="&#33328;">test</document>u%<document title="舰">test</document>z<document>&entity;</document>z#undefined entity: line 1, column 10z,undefined entity &entity;: line 5, column 10rJ�entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)rr�rNr0r[r�r�r�r��
ENTITY_XMLr�r0r�r��EXTERNAL_ENTITY_XML)rr�r�r�r�rrr�test_entityHs*


zElementTreeTest.test_entitycCsrt�d�}|�|d�t�d�}|�|d�t�d�}|�|d�t�d�}|�|d�t�t�}|�|d	�dS)
Nz<tag xml:lang='en' />z<tag xml:lang="en" />zC<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' />zC<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />z7<html:html xmlns:html='http://www.w3.org/1999/xhtml' />z7<html:html xmlns:html="http://www.w3.org/1999/xhtml" />zG<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope' />zE<ns0:Envelope xmlns:ns0="http://schemas.xmlsoap.org/soap/envelope" />z�<ns0:body xmlns:ns0="http://effbot.org/ns">
  <ns0:tag>text</ns0:tag>
  <ns0:tag />
  <ns0:section>
    <ns0:tag>subtext</ns0:tag>
  </ns0:section>
</ns0:body>)rr�r[�
SAMPLE_XML_NS)rr+rrr�test_namespacems




zElementTreeTest.test_namespacecCs�t�d�}|�|d�t�t�d��}|�|d�t�t�dd��}|�|d�t�t�dd��}t�|t�dd��}t�|t�dd��}|�|d�|��d|jd	<|�|d
�|��d|jt�d	�<|�|d
�|��d|jd	<|�|d�|��t�d�|jd	<|�|d
�|��t�d�}t�d�|jd<|�|�|�|�|�|d�|�t	t�dd��d�|�t	t�d��d�t�dd�}t�dd�}|�||�t�dd�}|�
||�|�
|d�|�|d�dS)Nz{uri}tagz<ns0:tag xmlns:ns0="uri" />Zurir1Ztag1r�z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>rcz{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)rrMr[�QNamer�r�rKrzrNr�r�)rr+r�Zq1Zq2rrr�
test_qname�sV





zElementTreeTest.test_qnamecCst�d�}dS)Nz�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>)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)rcs ��dd���|�D�|�dS)NcSsg|]\}}|p|�qSrr)r2�opr1rrrr3�szGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>)rNZxpath_tokenizer)�prZ)rrrrr��s
z3ElementTreeTest.test_xpath_tokenizer.<locals>.checkrvztext()rJz()z@name�@rCz@*zpara[1]Zpara�[�1�]zpara[last()]Zlastz*/para�/z/doc/chapter[5]/section[2]�docZchapter�5�section�2z
chapter//paraz//z//paraz//olist/itemZolistrh�.z.//paraz..z../@lang�langzchapter[title]�titlez#employee[@secretary and @assistant]ZemployeeZ	secretaryr^�andZ	assistantz{http://spam}eggz
./spam.eggzspam.eggz.//{http://spam}egg)rr)rr�r)rrr�test_xpath_tokenizer�s2z$ElementTreeTest.test_xpath_tokenizercCsn|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd��d�|�t�t�dd�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&>�?>)rNrr�r�r�)rrrr�test_processinginstruction�sz*ElementTreeTest.test_processinginstructioncCsxxrdD]j}xd||��gD]T}d|}tt�d|�dd�}|�||�tt�d||f�dd�}|�||�qWqWdS)N)
ZAREAZBASEZBASEFONTZBRZCOLZFRAMEZHRZIMGZINPUTZISINDEXZLINKZMETAZPARAMz<%s>z<%s />r-)rqz	<%s></%s>)�lowerr0rr�rN)rrmr+rZZ
serializedrrr�#test_html_empty_elems_serialization
s
z3ElementTreeTest.test_html_empty_elems_serializationN)!r r!r"r[r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�DeprecationWarning�PendingDeprecationWarningr�r�r+r.r/r3r5r8r9rIrJrLrrrrrY�s8X)
5-p9&;%!A#rYc@sVeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�ZdS)�XMLPullParserTestNcCsH|dkr|�|�n0x.tdt|�|�D]}|�||||��q&WdS)Nr)r�r�rO)rr�r��
chunk_sizer�rrr�_feedszXMLPullParserTest._feedcCs"|��}|�dd�|D�|�dS)NcSsg|]\}}||jf�qSr)r1)r2r�r+rrrr3#sz7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>)�read_eventsrN)rr�rZr�rrr�assert_event_tags!sz#XMLPullParserTest.assert_event_tagsc
Cs�x�dD]�}|j|d���t��}|�|g�|�|d|�|�|g�|�|d|�|�|g�|�|d|�|�|dg�|�|d|�|�|d|�|�|dd	g�|�|d
|�|�|dg�|�|���WdQRXqWdS)N)Nr\�)rPz<!-- comment -->
z+<root>
  <element key='value'>text</elementz>
)r�rmz<element>text</element>tail
z<empty-element/>
)r�z
empty-elementz</root>
)r�r�)�subTestr�
XMLPullParserrSrQr�r�)rrPr�rrr�test_simple_xml&s(
z!XMLPullParserTest.test_simple_xmlc	Cs�t��}|��}|�|d�t|�\}}|�||jfd�|�|d�t|�\}}|�||jfd�|�t��t|�WdQRXdS)Nz-<root>
  <element key='value'>text</element>
)r�rmz</root>
)r�r�)	rrVrRrQr�rNr1r��
StopIteration)rr�rtr�r+rrr�test_feed_while_iterating=sz+XMLPullParserTest.test_feed_while_iteratingcCs�t��}|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d�|�|ddg�|�|d	�|�|d
g�|�|���dS)Nz<!-- comment -->
z<root xmlns='namespace'>
z"<element key='value'>text</elementz>
)r�z{namespace}elementz<element>text</element>tail
z<empty-element/>
)r�z{namespace}empty-elementz</root>
)r�z{namespace}root)rrVrSrQr�r�)rr�rrr�test_simple_xml_with_nsIs$z)XMLPullParserTest.test_simple_xml_with_nscCs�tjdd�}|�|d�|�|d�|�t|���dg�|�|d�|�|d�|�|d�|�|d	�|�|d
�|�t|���dg�|�|���dS)N)zstart-nszend-ns)r�z<!-- comment -->
z<root xmlns='namespace'>
)zstart-ns)r^r�z"<element key='value'>text</elementz>
z<element>text</element>tail
z<empty-element/>
z</root>
)zend-nsN)rrVrQrNrPrRr�r�)rr�rrr�test_ns_events^s
z XMLPullParserTest.test_ns_eventscCs�tjdd�}|�|d�|�|g�tjdd�}|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|dg�|�|d�|�|d
dddg�|�|d�|�|���|�|dg�tjdd�}|�|d�|�|g�|�|d�|�|dg�|�|d�|�|d	g�|�|d
�|�|g�|�|d�|�|d
dg�|�|d�|�|���dS)Nr)r�z<root/>
)r�r�z<!-- comment -->
z<root>
)r�r�z"<element key='value'>text</element)r�rmz>
)r�rmz8<element xmlns='foo'>text<empty-element/></element>tail
)r�z{foo}element)r�z{foo}empty-element)r�z{foo}empty-element)r�z{foo}elementz</root>)r�r�)r�)rrVrQrSr�r�)rr�rrr�test_eventsmsLzXMLPullParserTest.test_eventscCslddh}tj|d�}|�|d�|�|ddg�Gdd�d�}tj|�d�}|�|d�|�|ddg�dS)	Nr�r�)r�z<foo>bar</foo>)r�r�)r�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�)rrrrrs�szBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__N)r r!r"r]r^rsrrrr�	DummyIter�sr_)rrVrQrS)rZeventsetr�r_rrr�test_events_sequence�sz&XMLPullParserTest.test_events_sequencec	Cs&|�t��tjdd�WdQRXdS)N)r�r�r�)r�)r�r�rrV)rrrr�test_unknown_event�sz$XMLPullParserTest.test_unknown_event)N)r r!r"rQrSrWrYrZr[r\r`rarrrrrOs
,rOz�<?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)�XIncludeTestr�NcCs@yt|}Wntk
r(td��YnX|dkr<t�|�}|S)Nzresource not foundr�)�XINCLUDE�KeyError�OSErrorrr�)r�hrefr�r$r�rrr�xinclude_loaders
zXIncludeTest.xinclude_loadercCsdS)Nr)rrfr�r$rrr�none_loaderszXIncludeTest.none_loaderc	Cs2|dkr*t|d��}t�|���SQRXndSdS)Nr�r�)r�rr�rw)rrfr�r�rrr�
_my_loader szXIncludeTest._my_loadercCs8ddlm}|�d�}|�||j�|�t|�d�dS)Nr)rzdefault.xmlz�<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)rrrg�includerirNr0)rrrArrr�test_xinclude_default)s


z"XIncludeTest.test_xinclude_defaultc	Csddlm}|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d�}|�||j�|�t|�d�|�d	�}|�||j�|�t|�d
�|�d�}|�t��}|�||j�WdQRX|�t|j	�d�|�t|�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>)
rrrgrjrNr0r�rer�r�)rrr�r�rrr�
test_xinclude7s.










zXIncludeTest.test_xincludec	Cs0ddlm}t�td�}|�|j��}|j||jd�WdQRX|�	t
|j�d�t�td�}|�|j��}|j||jd�WdQRX|�	t
|j�d�t�td�}|�|j��}|j||jd�WdQRX|�	t
|j�d	�t�td
�}|�|j��}|j||jd�WdQRX|�	t
|j�d�dS)Nr)rzC1.xml)rEz%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'))
rrrr�rcr�ZFatalIncludeErrorrjrhrNr�r��XINCLUDE_BAD)rrr�r�rrr�test_xinclude_failuresws*z#XIncludeTest.test_xinclude_failures)r�N)N)	r r!r"rgrhrirkrlrnrrrrrbs
	
	@rbc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Ze�
e��d�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Z d6d7�Z!d8d9�Z"d:S);�BugsTestcs��fdd�}t�d�}||�t�d�}d|_||�t�d�}d|_||�t�d�}|�dd�||�t�d�}|�dd�||�dS)Nc	s4��t��}t|�WdQRX��t|j�d�dS)Nzcannot serialize 123 (type int))r��	TypeErrorr0rNr�r�)r+r�)rrrr��sz-BugsTest.test_bug_xmltoolkit21.<locals>.check�{r+Z123)rrMrJrIr�)rr�r+r)rr�test_bug_xmltoolkit21�s




zBugsTest.test_bug_xmltoolkit21cCs<t�t�}t�|�}|�|�d�d�|�|�d�d�dS)Nr1rJzsection/tagr�)rr�r�rrNr�)rr+r/rrr�test_bug_xmltoolkit25�s

zBugsTest.test_bug_xmltoolkit25cCs<t�d�}|�t|�d��g�|�t|�d��dg�dS)Nz"<doc><table><tbody/></table></doc>z.//theadz.//tbodyZtbody)rr�rNr5r�)rr/rrr�test_bug_xmltoolkit28�s
zBugsTest.test_bug_xmltoolkit28c	Cs<t�d�}t��� }t�|�|�|��d�WdQRXdS)Nz"<doc><table><tbody/></table></doc>z$<doc><table><tbody /></table></doc>
)rr�rZcaptured_stdout�dumprNr))rr/�stdoutrrr�test_bug_xmltoolkitX1�s


zBugsTest.test_bug_xmltoolkitX1cCs�t�d�}|�t�|d�d�t�d�}|�|jddi�|�t�|d�d�t�d�}|�t�|d�d	�t�d
�}|�t�|d�d�t�d�}|�dd�|�t�|d�d�dS)Ns2<?xml version='1.0' encoding='iso-8859-1'?><t�g />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ägr1)rr�rNr�rKrMr�)rr/rrr�test_bug_xmltoolkit39�s




zBugsTest.test_bug_xmltoolkit39cCs2t�d�}|�t|dd�d�|�t|�d�dS)Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>zus-ascii)r$s<doc>&#33328;</doc>u<doc>舰</doc>)rr�rNr0)rr�rrr�test_bug_xmltoolkit54�s
zBugsTest.test_bug_xmltoolkit54c	Cs8|�tj��}t�d�WdQRX|�t|j�d�dS)Ns?<!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>z+undefined entity &ldots;: line 1, column 36)r�rr�r�rNr�r�)rr�rrr�test_bug_xmltoolkit55�szBugsTest.test_bug_xmltoolkit55cCs$Gdd�d�}|�ttj|��dS)Nc@seZdZdd�ZdS)z5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilecSst�dS)N)re)rrVrrrr��sz:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.readN)r r!r"r�rrrr�
ExceptionFile�sr{)r�rerr�)rr{rrr�test_bug_xmltoolkit60�szBugsTest.test_bug_xmltoolkit60cCsHddd�}t��}|j�|�|�d�|��}|�|�d�jd�dS)Nu’u‘)ZrsquoZlsquoaF<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE patent-application-publication SYSTEM "pap-v15-2001-01-31.dtd" []>
<patent-application-publication>
<subdoc-abstract>
<paragraph id="A-0001" lvl="0">A new cultivar of Begonia plant named &lsquo;BCT9801BEG&rsquo;.</paragraph>
</subdoc-abstract>
</patent-application-publication>z.//paragraphu7A new cultivar of Begonia plant named ‘BCT9801BEG’.)	rr�r0�updater�r�rNrrJ)rZENTITIESr��trrr�test_bug_xmltoolkit62s
zBugsTest.test_bug_xmltoolkit62zSkips under coverage.cCsFdd�}|�t�d�}xtd�D]
}|�q"W|�t�d�|�dS)NcSs,t��}|�di�|�d�|�d�dS)Nr1rJ)rr�r�r�r�)r/rrr�xmltoolkit63s
z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63i�)r;�getrefcountr�rN)rr��countr�rrr�test_bug_xmltoolkit63s

zBugsTest.test_bug_xmltoolkit63c	Cs`tjddd�}|�t�|�d�|�t�t�|���d�d�|�t�t�t�|���d�dS)NZSomeTagzdef _f():
  return 3
)rJs0<SomeTag text="def _f():&#10;  return 3&#10;" />rJ)rrMrNr�r�rA)rr�rrr�test_bug_200708_newline#sz BugsTest.test_bug_200708_newlinecCs`t��}|�d�|�|��jd�Gdd�d�}tj|�d�}|�d�|�|��jd�dS)Nz<element>some text</element>rmc@seZdZdd�ZdS)z2BugsTest.test_bug_200708_close.<locals>.EchoTargetcSs
t�d�S)Nrm)rrM)rrrrr�6sz8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closeN)r r!r"r�rrrr�
EchoTarget5sr�)r�)rr�r�rNr�r1)rr�r�rrr�test_bug_200708_close.s

zBugsTest.test_bug_200708_closec	Cs�t�d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t|dd�d�t�d�}t�|d�}t�|d�}|�t��}t|dd�WdQRX|�t|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)	rrMr�rNr0r�r�r�r�)rr��sr�rrr�!test_bug_200709_default_namespace<s 


z*BugsTest.test_bug_200709_default_namespacecCsdt�d�}|�t�|�d�t�dd�t�d�}|�t�|�d�t�d�}|�t�|�d�dS)Nz/{http://namespace.invalid/does/not/exist/}titlesB<ns0:title xmlns:ns0="http://namespace.invalid/does/not/exist/" />r�z(http://namespace.invalid/does/not/exist/sB<foo:title xmlns:foo="http://namespace.invalid/does/not/exist/" />z'{http://purl.org/dc/elements/1.1/}titles8<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/" />)rrMrNr��register_namespace)rr�rrr�"test_bug_200709_register_namespaceSs


z+BugsTest.test_bug_200709_register_namespacecCs`t�d�}|�t�d��|�|djtj�t�d�}|�t�d��|�|djtj�dS)Nr�r�r)rrMrzr�rNr1r�)rr�rrr�test_bug_200709_element_commentbs

z(BugsTest.test_bug_200709_element_commentcCsvt�d�}t�|d�}t�|d�}t�d�}|�d|�|�t|�dddg�|�d|�|�t|�ddddg�dS)Nr�r�r�r�r���)rrMr�r|rNr5)rr�r�r�r�rrr�test_bug_200709_element_insertns

z'BugsTest.test_bug_200709_element_insertcCsJt�d�}t�|d�}t�d�}|�|�|�t|�tj��tjg�dS)Nr�r�zTEST-b)rrMr�r�rzrNr5r�)rr�r�Z	comment_brrr�test_bug_200709_iter_commentxs



z%BugsTest.test_bug_200709_iter_commentcCsDt��}|�d�}|�di�}|�d�}|��}|�t|�d�dS)Nr�r1z<tag />)rr�r�r�r�r�rNr0)rrUr�rrr�test_bug_1534630�s

zBugsTest.test_bug_1534630cCs@t�d�}|�t�|d�d�t�d�}|�t�|d�d�dS)Ns7<?xml version='1.0' encoding='utf-8'?><body>tãg</body>r�s<<?xml version='1.0' encoding='ascii'?>
<body>t&#227;g</body>s;<?xml version='1.0' encoding='iso-8859-1'?><body>t�g</body>)rr�rNr�)rr�rrr�test_issue6233�s

zBugsTest.test_issue6233cCs8t�d�}|�|jd�t�|�}|�t�|�d�dS)Nz+<prefix:localname xmlns:prefix="${stuff}"/>z{${stuff}}localnames&<ns0:localname xmlns:ns0="${stuff}" />)rr�rNr1rr�)rr�r~rrr�test_issue3151�s

zBugsTest.test_issue3151cCsTt�d�}|�t|�dg�t�t�}|dd�|dd�<|�t|�dddg�dS)Nz<body><tag/></body>r1rC)rr�rNr5r�)rr+Znewelemrrr�test_issue6565�s


zBugsTest.test_issue6565cCst�dd�t�dd�dS)NZ	test10777z
http://myuri/)rr�)rrrr�test_issue10777�szBugsTest.test_issue10777cs`G�fdd�d�}t�d��|��_���}t|�}|�||�|��jt�|��jd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_text.<locals>.Textcs
d�_dS)N�changedT)rJ)r)r�rr�__bool__�sz.BugsTest.test_lost_text.<locals>.Text.__bool__N)r r!r"r�r)r�rrr��sr�r1r�)rrMrJr�r�rLr�rN)rr�r�r~r)r�r�test_lost_text�s
zBugsTest.test_lost_textcs|G�fdd�d�}t�d����t�d��|��d_���}t|�}|�||�|��djt�|��djd�dS)NcseZdZ�fdd�ZdS)z%BugsTest.test_lost_tail.<locals>.Textcsd�d_dS)Nr�rT)rI)r)r�rrr��s
z.BugsTest.test_lost_tail.<locals>.Text.__bool__N)r r!r"r�r)r�rrr��sr�r�r1rr�)	rrMrzrIr�r�rLr�rN)rr�r�r~r)r�r�test_lost_tail�s
zBugsTest.test_lost_tailcs�G��fdd�d�}t�d����t�|�����t�d����d��yt��}Wntk
rt|�d�YnX|�|j|�|��djt	�|�
�djd�dS)NcseZdZ��fdd�ZdS)z$BugsTest.test_lost_elem.<locals>.Tagcst�d��d<t��dS)Nr�rT)rrMr�)rr�)r�r�rr�__eq__�sz+BugsTest.test_lost_elem.<locals>.Tag.__eq__N)r r!r"r�r)r�r�rrr��sr�r�r1zgenerators are not reentrantrr�)rrMrzr�r�r�ZskipTestrLr1r�rN)rr�r~r)r�r�r�test_lost_elem�s

zBugsTest.test_lost_elemcCs.d|}t�|�}|�|�d�|�d��dS)Ns<a b="%s"/>r�zutf-8)rr�rNrA�decode)rrJr�r�rrr�check_expat224_utf8_bug�s
z BugsTest.check_expat224_utf8_bugcCs d}|�|�d}|�|�dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r�)rrJrrr�test_expat224_utf8_bug�s
zBugsTest.test_expat224_utf8_bugc	Csnttd��}|��}WdQRXt�|�}|�d�}|�d���}|�dd�}|dd�}|�	|�d�|�dS)Nr�r�zutf-8z
r_����)
r��UTF8_BUG_XMLFILEr�rr�rAr��strip�replacerN)r�fp�rawr�ZxmlattrrJrrr�test_expat224_utf8_bug_file�s

z$BugsTest.test_expat224_utf8_bug_fileN)#r r!r"rrrsrtrwrxryrzr|r�unittestZskipIfr;�gettracer�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrro�s8			

roc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�BasicElementTestcCsJt�d�}|�t|jd�|�t|jt�d�dg�|�t|jdd�dS)N�joer�r�r�r)rrMr�rprzr{r|)rr�rrr�test_augmentation_type_errorss
z.BasicElementTest.test_augmentation_type_errorscCs�Gdd�d�}|�}tjd|d�|_t�|�}~t�|�|��t�d�}|�}||_t�|�}tj|d|d�}~~~t�|�|��t�d�}t�d�}t�d�}|�|�|�|�|�|�t�|�}~~~t�|�|��dS)	Nc@seZdZdS)z.BasicElementTest.test_cyclic_gc.<locals>.DummyN)r r!r"rrrr�Dummysr�r�)rnr�r�r�r�)	rrMZdummyref�weakref�refrr�r�rz)rr�r��wrefr�r�r�r�rrr�test_cyclic_gcs2









zBasicElementTest.test_cyclic_gccsVd��fdd�}t�d�}t�||�}|�|�jd�~|��d�|�|�d�dS)NFcsd�dS)NTr)�w)�flagrr�wref_cb,sz.BasicElementTest.test_weakref.<locals>.wref_cbr�T)rrMr�r�rNr1)rr�r�r�r)r�r�test_weakref*s
zBasicElementTest.test_weakrefcCsBtjddddd�}|�|jddd�d�|�|jd	dd�d�dS)
Nr�r\r�r�)rVrW�zrV�)r�r�)rrMrNrA)rr�rrr�test_get_keyword_args6sz&BasicElementTest.test_get_keyword_argsc	Cs�x�tdtjd�D]�}x�t|jdd�D]�\}}|jddd�}d|_d|_|�|d	��	|�d
��|�	|�d	��|�
d�d�d
d�|�|d|||�}|�
|jd�|�
|jdd�|�
t|�d�|�||�q&WqWdS)Nr�r\)�repeatr��*)r�ztext goes herezopposite of head�childZ
grandchildz
.//grandchildrrnzother valuezxml.etree.ElementTreer�)r�r<�HIGHEST_PROTOCOLrr8rMrJrIr�rzr�r�rHrNr1rKrOrR)rrFrDrEr�r�rrr�test_pickle;s
zBasicElementTest.test_picklec	Cs�x�tdtjd�D]~}xxt|jdd�D]f\}}d}|�|�}t|d�rZ|�|��dd�|�	|d|||�}|�|j
d�|�|d	j
d
�q&WqWdS)Nr�r\)r�z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>�__getstate__r1�groupzxml.etree.ElementTreerZdogs)r�r<r�rr8r�rlrNr�rHr1)rrFrDrEZXMLTEXTr�r�rrr�test_pickle_issue18997Ns


z'BasicElementTest.test_pickle_issue18997N)	r r!r"r�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)�BadElementTestcs~G�fdd�d�}|�g�t�d�}y|���Wntk
rFYnXGdd�d|tj�}|d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z2BadElementTest.test_extend_mutable_list.<locals>.Xcst�d�g�dd�<tjS)N�baz)rrM)r)�Lrr�	__class__`sz<BadElementTest.test_extend_mutable_list.<locals>.X.__class__N)r r!r"�propertyr�r)r�rr�X_sr�r�c@seZdZdS)z2BadElementTest.test_extend_mutable_list.<locals>.YN)r r!r"rrrr�Yksr�rV)rrMr{rp)rr�r�r�r)r�r�test_extend_mutable_list^s


z'BadElementTest.test_extend_mutable_listcs�G�fdd�d�}|�t�d�g�t�d�}y|���Wntk
rNYnXGdd�d|tj�}|d�t�d�g�t�d�}|���dS)NcseZdZe�fdd��ZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.Xcs�dd�=tjS)N)rrM)r)r�rrr�ss
z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__N)r r!r"r�r�r)r�rrr�rsr�r�r�c@seZdZdS)z3BadElementTest.test_extend_mutable_list2.<locals>.YN)r r!r"rrrrr�~sr�r�)rrMr{rp)rr�r�r�r)r�r�test_extend_mutable_list2qs

z(BadElementTest.test_extend_mutable_list2cszG�fdd�dtj�}t�d����|d�g�|�t�jt�d��t�d����t�d�g�|�t�j|d��dS)NcseZdZ�fdd�ZdS)z3BadElementTest.test_remove_with_mutating.<locals>.Xcs�dd�=dS)NFr)r�o)r�rrr��s
z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__N)r r!r"r�r)r�rrr��sr�r�r�r�)rrMr{r�r�r})rr�r)r�r�test_remove_with_mutating�s

z(BadElementTest.test_remove_with_mutatingc
CsDt�d�}t|d|��$|�t��t|�WdQRXWdQRXdS)Nr�r1)rrMrr��RuntimeErrorry)rr�rrr�test_recursive_repr�s
z"BadElementTest.test_recursive_reprcsnG�fdd�dt�}t��}|�di�|�d�|�|d��|�d�|�d�|���|��jd�dS)NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_text.<locals>.Xcs$y
�jWntk
rYnXdS)N)rJ�	NameError)r)r+rr�__del__�s
z7BadElementTest.test_element_get_text.<locals>.X.__del__N)r r!r"r�r)r+rrr��sr�r1�ABCD�EFGH�IJKL�ABCDEFGHIJKL)	r�rr�r�r�r�r�rNrJ)rr�r�r)r+r�test_element_get_text�s


z$BadElementTest.test_element_get_textcs�G�fdd�dt�}t��}|�di�|�di�|�d�|�d�|�|d��|�d�|�d�|���|��djd	�dS)
NcseZdZ�fdd�ZdS)z/BadElementTest.test_element_get_tail.<locals>.Xcs(y�djWntk
r"YnXdS)Nr)rIr�)r)r+rrr��sz7BadElementTest.test_element_get_tail.<locals>.X.__del__N)r r!r"r�r)r+rrr��sr�r�r1r�r�r�rr�)	r�rr�r�r�r�r�rNrI)rr�r�r)r+r�test_element_get_tail�s



z$BadElementTest.test_element_get_tailcCspddgdddd�}t�d�}y|�|�Wntk
rD||_YnX|��}|�t|�|�|�tt|�dS)Nr1rnrIrJ)r1Z	_childrenrKrIrJ)	rrM�__setstate__�AttributeError�__dict__r�ZassertIsr�r�)r�stater�rtrrr�test_element_iter�s
z BadElementTest.test_element_itercs^G�fdd�d�}t�d����t�d���d|����t�d���dd|��dS)NcseZdZ�fdd�ZdS)z%BadElementTest.test_subscr.<locals>.Xcs�dd�=dS)Nr\r)r)r�rr�	__index__�s
z/BadElementTest.test_subscr.<locals>.X.__index__N)r r!r"r�r)r�rrr��sr�r+r�rr�)rrMrz)rr�r)r�r�test_subscr�s
zBadElementTest.test_subscrcsTG�fdd�d�}t�d��x"td�D]}��dt�d��q&Wg�dd|��<dS)NcseZdZ�fdd�ZdS)z)BadElementTest.test_ass_subscr.<locals>.Xcsg�dd�<dS)Nr\r)r)r�rrr��sz3BadElementTest.test_ass_subscr.<locals>.X.__index__N)r r!r"r�r)r�rrr��sr�r+r�rr�)rrMr�r|)rr�r�r)r�r�test_ass_subscr�s

zBadElementTest.test_ass_subscrcCsHdd�}tj|d�}|�di�|�d�|�t|jdi�~t�dS)NcSsgS)Nr)rVrWrrr�element_factory�sz>BadElementTest.test_treebuilder_start.<locals>.element_factory)r�r1r�r�)rr�r�r�r�r�r)rr�r�rrr�test_treebuilder_start�s
z%BadElementTest.test_treebuilder_startcCsFdd�}tj|d�}|�di�|�d�|�t|jd�~t�dS)NcSsgS)Nr)rVrWrrrr��sz<BadElementTest.test_treebuilder_end.<locals>.element_factory)r�r1r�)rr�r�r�r�r�r�r)rr�r�rrr�test_treebuilder_end�s
z#BadElementTest.test_treebuilder_endN)r r!r"r�r�r�r�r�r�r�r�r�r�r�rrrrr�]s

r�c@seZdZdd�Zdd�ZdS)�MutatingElementPathcGstj|f|��}||_|S)N)r��__new__r+)r9r+r
rrrrr�	szMutatingElementPath.__new__cCs|jdd�=dS)NT)r+)rr�rrrr�
szMutatingElementPath.__eq__N)r r!r"r�r�rrrrr�sr�c@seZdZdd�ZdS)�BadElementPathcCsdd�dS)Nr\rr)rr�rrrr�szBadElementPath.__eq__N)r r!r"r�rrrrr�sr�csXeZdZ�fdd�Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
�ZS)�BadElementPathTestcs(t���ddlm}|j|_i|_dS)Nr)r)�super�setUprrr��
path_cache)rr)r�rrr�s
zBadElementPathTest.setUpcs"ddlm}|j|_t���dS)Nr)r)rrr�r�r��tearDown)rr)r�rrr�szBadElementPathTest.tearDowncCs0t�d�}|�t�d�g�|�t|d��dS)Nr�r�rV)rrMr{rr�)rr�rrr�test_find_with_mutating#s
z*BadElementPathTest.test_find_with_mutatingcCsHt�d�}|�t�d�g�y|�td��Wntk
rBYnXdS)Nr�r�rV)rrMr{rr��ZeroDivisionError)rr�rrr�test_find_with_error(s
z'BadElementPathTest.test_find_with_errorcCs0t�d�}|�t�d�g�|�t|d��dS)Nr�r�rV)rrMr{r�r�)rr�rrr�test_findtext_with_mutating0s
z.BadElementPathTest.test_findtext_with_mutatingcCsHt�d�}|�t�d�g�y|�td��Wntk
rBYnXdS)Nr�r�rV)rrMr{r�r�r�)rr�rrr�test_findtext_with_error5s
z+BadElementPathTest.test_findtext_with_errorcCs0t�d�}|�t�d�g�|�t|d��dS)Nr�r�rV)rrMr{r�r�)rr�rrr�test_findall_with_mutating=s
z-BadElementPathTest.test_findall_with_mutatingcCsHt�d�}|�t�d�g�y|�td��Wntk
rBYnXdS)Nr�r�rV)rrMr{r�r�r�)rr�rrr�test_findall_with_errorBs
z*BadElementPathTest.test_findall_with_error)r r!r"r�r�r�r�r�r�r�r��
__classcell__rr)r�rr�sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�ElementTreeTypeTestcCsX|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�|�tjt�dS)N)	rLrr��typer7rrMr�r�)rrrr�test_istypeLszElementTreeTypeTest.test_istypecCsZGdd�dtj�}|d�}|�|tj�|�||�|�|jd�d|_|�|jd�dS)Nc@seZdZdS)zDElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementN)r r!r"rrrr�	MyElementUsr�r�r�)rrMrLrNr1rJ)rr��myerrr�test_Element_subclass_trivialTsz1ElementTreeTypeTest.test_Element_subclass_trivialcsZG�fdd�dtj���dddd�ddd	�}|�|jd
�|�t|���ddd
dg�dS)Ncs"eZdZif��fdd�	Z�ZS)zHElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementcst�|�j|d|f|�dS)N�__)r�r])rr1rKZextra)r�r�rrr]cszQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__)r r!r"r]r�r)r�)r�rr�bsr�r�r\r�)r�r�r��)r�r�Zfoo__)r�r\)r�r�)r�r�)r�r�)rrMrNr1r�rf)rr�r)r�r�!test_Element_subclass_constructoras
z5ElementTreeTypeTest.test_Element_subclass_constructorcCs.Gdd�dtj�}|d�}|�|��d�dS)Nc@seZdZdd�ZdS)zGElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementcSs|jS)N)r1)rrrr�	newmethodmszQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethodN)r r!r"r�rrrrr�lsr�r�)rrMrNr�)rr�r�rrr� test_Element_subclass_new_methodksz4ElementTreeTypeTest.test_Element_subclass_new_methodcCs�Gdd�dtj�}t�d�}d|_|d�}d|_|�|�|�|�d�d�|�|�d�jd�t|�	d��}|�t
|�d|�|�|djd�dS)	Nc@seZdZdS)zAElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementN)r r!r"rrrrr�tsr�r�rJr�r�r\r)rrMrJrzrNr�rr1rPr�rO)rr�r��sub�foundrrr�test_Element_subclass_findss

z.ElementTreeTypeTest.test_Element_subclass_findN)r r!r"r�r�r�r�r�rrrrr�Ks


r�c@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�ElementFindTestcCs�t�t�}|�|�d�jd�|�|�d�jd�|�|�d�jd�t�t�|d<|�|�d�jd�|�|�d�d�|�|�d�d�|�|�d�d	�|�|�dd
�d	�|�|�d��|�|�dd
�d
�|�t�d��d
�d	�dS)Nr1zsection/tagz./tagr�zsection/nexttag�nexttagrJr�r^r��togz<tag><empty /></tag>�empty)	rr�r�rNrr1�SAMPLE_SECTIONr�r�)rr�rrr�test_find_simple�s
z ElementFindTest.test_find_simplecCs�d}t�|�}|�|�d�jdd�|�|�d�jdd�|�|�d�jdd�|�|�d	�jdd
�|�|�d�jdd�|�td|jd
�|�td|jd�|�td|jd�|�td|jd�dS)Nz�
        <body>
            <tag class='a'/>
            <tag class='b'/>
            <tag class='c'/>
            <tag class='d'/>
        </body>z./tag[1]�classr�z./tag[2]r�z
./tag[last()]r�z./tag[last()-1]r�z./tag[last()-2]ZXPathz./tag[0]z	./tag[-1]z./tag[last()-0]z./tag[last()+1])rr�rNrrK�assertRaisesRegex�SyntaxError)rZ
LINEAR_XMLr�rrr�test_find_xpath�s
zElementFindTest.test_find_xpathcCst�t�}t�t�|d<|�t|�d��dg�|�t|�d��ddg�|�t|�d��g�|�t|�d��g�|�t|�d��dddg�|�t|�d	��dgd
�|�t|�d��dg�|�t|�d��dgd�|�t|�d
��dddg�|�t|�d��ddddg�|�t|�d��ddddg�|�t|�d��dddg�|�t|�d��ddddg�|�t|�d��dg�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dgd�|�t|�d��dg�|�t|�d��dg�|�t|�d��g�|�t|�d��g�|�t|�d ��dgd�|�|�d!�|�d��|�t|�d"��dg�|�t|�d#��dg�|�t|�d$��dg�|�t|�d%��dg�|�t|�d&��dg�|�t|�d'��dg�|�t|�d(��dg�|�t|�d)��dg�|�t|�d*��dg�|�t|�d+��dg�|�t|�d,��g�|�t|�d-��g�|d|d.<|�t|�d%��ddg�|�t|�d+��ddg�dS)/Nr�rEr�r1r�ztog/foorvrCz.//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//z.//section[tag='subtext']z.//section[tag ='subtext']z.//section[tag= 'subtext']z.//section[tag = 'subtext']z.//section[ tag = 'subtext' ]z.//tag[.='subtext']z.//tag[. ='subtext']z.//tag[.= "subtext"]z.//tag[ . = "subtext" ]z.//tag[. = 'subtext']z.//tag[. = 'subtext ']z.//tag[.= ' subtext']r\)rr�r�rrNr5r�)rr�rrr�test_findall�s�

zElementFindTest.test_findallcCs\t�t�}|�t|�d��g�|�t|�d��dgd�|�t|�d��dgd�dS)Nr1z{http://effbot.org/ns}tagr�z.//{http://effbot.org/ns}tagr�)rr�r4rNr5r�)rr�rrr�test_test_find_with_ns�s
z&ElementFindTest.test_test_find_with_nscCs�t�d�}ddi}|�t|jd|d��d�|�t|jd|d��d�ddi}|�t|jd|d��d	�|�t|jd|d��d�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�r\)rr�rNrOr�)rr��nsmaprrr�test_findall_different_nsmaps	sz-ElementFindTest.test_findall_different_nsmapsc	Cs0t�t�}|�td��|�d�WdQRXdS)Nzcannot use absolute pathz/tag)rr�r�rrr�)rr�rrr�
test_bad_find	s
zElementFindTest.test_bad_findc	Cs�t�t�}|�t�|��d�jd�|�t�|��d�d�|�tt�|��	d��dgd�d}|�
t|��t�|��	d�}WdQRX|�t|�dgd�dS)Nr1rJr�z�This search is broken in 1.3 and earlier, and will be fixed in a future version.  If you rely on the current behaviour, change it to '.+'z//tagr�)rr�r�rNrrr1r�r5r��assertWarnsRegex�
FutureWarning)rr�r]rtrrr�test_find_through_ElementTree	s
z-ElementFindTest.test_find_through_ElementTreeN)
r r!r"rrrrr
rrrrrrr��sM
r�c@sReZdZddd�Zdd�Zdd�Zdd	�Zed
ef�dd��Z	d
d�Z
dd�ZdS)�ElementIterTestNcCst|�|��S)N)r5r�)rr+r1rrr�_ilist+	szElementIterTest._ilistcCs6t�d�}|�|�|�dddg�|�|�|�d��ddg�|�t|���jd�|�d�|�	��d�|�d�|�d��	��d�|�t|�	��d�t
|d	d
�}|�tt�|��dd�t
|d	d
�}tjt�
�d
�}|�ttj||d��dd�t�d�}|�t|j�t�d�}|�d�|�	��d�dS)Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>r-r�r�r^zthis 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&)rr�rNrrr�r�r1r�r�r0r�r�r�rr�r�)rrAZ
sourcefiler�r/rrr�
test_basic.	s$


zElementIterTest.test_basiccCs�t�d�}|�|�|�dg�t�|d�}|�|�|�ddg�t�|d�}|�|�|�dddg�t�|d�}|�|�|�ddddg�|d|d<|d=|�|�|�ddg�dS)Nr�r�r�r�r\r)rrMrNrr�)rr�r�r�r�rrr�test_cornersI	s
zElementIterTest.test_cornerscCs�t�d�}|�|�|d�dgd�|�|�|d�dgd�|�t|jdd��dgd�dddddddg}|�t|���|�|�|�|�|�|�|�|d	�|�dS)
NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>�roomr��houser�)r1r��shedrv)rr�rNrr5r�)rrA�all_tagsrrr�test_iter_by_tag_	s
z ElementIterTest.test_iter_by_tagz@This method will be removed in future versions.  Use .+ instead.cCs�t�d�}|�t|�d��dgd�|�t|�d��dgd�|�t|jdd��dgd�dddddddg}|�t|���|�|�t|�d��|�|�t|�d	��|�dS)
NaJ
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>rr�rr�)r1r�rrv)rr�rNr5r�)rrArrrr�test_getiterator}	s
z ElementIterTest.test_getiteratorc	Cs6t�d�}|��}|�t��t�|�WdQRXdS)Nr�)rrMr�r�rpr�)rr�rtrrrr��	s
zElementIterTest.test_copyc
CsVt�d�}|��}x>ttjd�D],}|�ttjf��t�	||�WdQRXq"WdS)Nr�r\)
rrMr�r�r<r�r�rpr?r=)rr�rtrFrrrr��	s

zElementIterTest.test_pickle)N)r r!r"rrrrrrNrr�r�rrrrr*	s
 rc@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�|�|jd�|�|jd�|�|jd�|�|ji�t|�}|�t|�d�|d}|�|jd�|�|jd�|�|jd�|�|ji�dS)Nr-rJr\rZdivr�rI)rNr1rJrIrKrPrO)rr�Zchildrenr�rrr�_check_sample1_element�	sz&TreeBuilderTest._check_sample1_elementcCs�Gdd�d�}Gdd�d|�}tj|�d�}|�|j�|�|��d�tj|�d�}|�|j�|�|��d�tjt�d�}|�|j�|�|���dS)Nc@seZdZdd�ZdS)z<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuildercSsdS)Nr�r)rrrrr��	szBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeN)r r!r"r�rrrr�BaseDummyBuilder�	src@seZdZdd�ZZZdS)z8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuildercWsdS)Nr)r�rrr�<lambda>�	r�zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>N)r r!r"r�r�r�rrrr�DummyBuilder�	sr)r�r�)rr�r��sample1rNr��objectr�)rrrr�rrr�test_dummy_builder�	sz"TreeBuilderTest.test_dummy_buildercCs6tjtjdd�d�}|�|j�|��}|�|�dS)N)r�)r�)rr�r�r�rr�r)rr�r�rrr�$test_treebuilder_elementfactory_none�	sz4TreeBuilderTest.test_treebuilder_elementfactory_nonecCsXGdd�dtj�}|�}|�|�d�d�tj|d�}|�|j�|��}|�|�dS)Nc@seZdZdd�ZdS)z4TreeBuilderTest.test_subclass.<locals>.MyTreeBuildercSs|dS)Nr�r)rrVrrr�foobar�	sz;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobarN)r r!r"r"rrrr�
MyTreeBuilder�	sr#r�r�)r�)	rr�rNr"r�r�rr�r)rr#�tbr�r�rrr�
test_subclass�	szTreeBuilderTest.test_subclasscsNg��fdd�}tj|d�}tj|d�}|�|j�|��|��dg�dS)Ncs��|�t�||�S)N)rzrrM)r1rK)�lstrr�	myfactory�	s
z7TreeBuilderTest.test_element_factory.<locals>.myfactory)r�)r�Ztoplevel)rr�r�r��sample2r�rN)rr'r$r�r)r&r�test_element_factory�	sz$TreeBuilderTest.test_element_factorycCsFtj|d�}tj|d�}|�|j�|��}|�||�|�|�dS)N)r�)r�)rr�r�r�rr�rLr)rr9r$r�r�rrr�_check_element_factory_class�	sz,TreeBuilderTest._check_element_factory_classcCs Gdd�dtj�}|�|�dS)Nc@seZdZdS)z@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementN)r r!r"rrrrr�
sr�)rrMr*)rr�rrr�test_element_factory_subclass
sz-TreeBuilderTest.test_element_factory_subclasscCs4tj}|�|jd�Gdd�d|t�}|�|�dS)Nzxml.etree.ElementTreec@seZdZdS)zLTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementN)r r!r"rrrrr�
sr�)rZ_Element_PyrNr!r�r*)r�baser�rrr�)test_element_factory_pure_python_subclass
sz9TreeBuilderTest.test_element_factory_pure_python_subclasscCs<Gdd�d�}tj|�d�}|�|j�|�|��d�dS)Nc@s eZdZdZdd�Zdd�ZdS)z3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNcSs|||f|_dS)N)�_doctype)rrC�pubid�systemrrr�doctype
sz;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctypecSs|jS)N)r.)rrrrr�
sz9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close)r r!r"r.r1r�rrrr�
DoctypeParser
sr2)r�)r-z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)rr�r�rrNr�)rr2r�rrr�test_doctype
s
	
zTreeBuilderTest.test_doctypec
Cs�Gdd�d�}tj|�d�x4dD],}|�t|��tj||�d�WdQRXq"Wtj|td�d�x:dD]2}tj||td�d�}|�|j�|�|���qjWdS)Nc@s"eZdZdefdd�Zdd�ZdS)zBTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNcSs||_||_dS)N)�raise_in�what)rr4r5rrrr]%
szKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__cSs"||jkr|�|j��dd�}|S)NcWsdS)Nr)r
rrr�handle,
sz^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handle)r4r5)rrCr6rrr�__getattr__)
s
zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__)r r!r"r�r]r7rrrr�RaisingBuilder$
sr8)r�)r�r�r�r�r�)r5)	rr�rr�r�r�rr�r�)rr8Zeventr�rrr�test_builder_lookup_errors#
s

z*TreeBuilderTest.test_builder_lookup_errorsN)r r!r"rr(rr r!r%r)r*r+r-r3r9rrrrr�	s
	
rc@sPeZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�ZdS)�
XMLParserTests<file><line>22</line></file>s�<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>uX<?xml version="1.0" encoding="iso-8859-1"?>
<money value="$£€𐅻">$£€𐅻</money>cCs6|�|jd�|�|djd�|�|djd�dS)Nr.r�lineZ22)rNr1rJ)rr�rrr�_check_sample_elementF
sz#XMLParserTest._check_sample_elementc	Cst|�td��t�dt��d�}WdQRX|�|j�|�|���tjdt��d�}|�|j�|�|���dS)Nz\bhtml\bzutf-8)r$r�)	rrMrr�r�r�rr<r�)rr�Zparser2rrr�test_constructor_argsK
sz#XMLParserTest.test_constructor_argscCs6Gdd�dtj�}|�}|�|j�|�|���dS)Nc@seZdZdS)z-XMLParserTest.test_subclass.<locals>.MyParserN)r r!r"rrrr�MyParserZ
sr>)rr�r�rr<r�)rr>r�rrrr%Y
szXMLParserTest.test_subclassc	Cs~t��}|�t��|�ddd�WdQRX|�d�|��t���.t�	dt�t��}|�|j
�|��WdQRXdS)Nr-z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdz<html/>�error)rr��assertWarnsrMr1r�r��warnings�catch_warnings�simplefilterr()rr�rrr�test_doctype_warning`
s

z"XMLParserTest.test_doctype_warningc	s�d�G�fdd�dtj�}|�}|�t��|�|j�WdQRX|��|��d�d��t�	��Zt�
dt�G�fdd�d�}||�d�}|�|j�|��|���|��d�WdQRXdS)NcseZdZ�fdd�ZdS)z@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypecs|||f�dS)Nr)rrCr/r0)r.rrr1q
szHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeN)r r!r"r1r)r.rr�MyParserWithDoctypep
srE)r-z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtdr?cseZdZ�fdd�ZdS)z:XMLParserTest.test_subclass_doctype.<locals>.DoctypeParsercs|||f�dS)Nr)rrCr/r0)�	_doctype2rrr1�
szBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypeN)r r!r"r1r)rFrrr2�
sr2)r�)rr�r@rMr�r(r�rNrArBrCr�)rrEr�r2r)r.rFr�test_subclass_doctypen
s$

z#XMLParserTest.test_subclass_doctypec	CsPt���>t�dt�Gdd�dtj�}|�}|�|j�|��WdQRXdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)r?c@seZdZdS)zDXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeN)r r!r"rrrr�MyParserWithoutDoctype�
srHN)	rArBrCrMrr�r�r(r�)rrHr�rrr�test_inherited_doctype�
s
z$XMLParserTest.test_inherited_doctypecCsVtjt��d�}|�|j�|��}|�|jd�|�|jdd�|�|j	d�dS)N)r�Zmoneyrcu
$£€𐅻)
rr�r�r��sample3r�rNr1rKrJ)rr�r�rrr�test_parse_string�
szXMLParserTest.test_parse_stringN)
r r!r"rr(rJr<r=r%rDrGrIrKrrrrr:=
s
r:c@seZdZdd�ZdS)�NamespaceParseTestcCs`ddd�}t�t�}|�t|�d|��d�|�t|�d|��d�|�t|�d|��d�dS)	NZhellor�)�hr�z{hello}tabler\z.//{hello}tdr�z.//{foo}name)rr��SAMPLE_XML_NS_ELEMSrNrOr�)rr	rArrr�test_find_with_namespace�
s


z+NamespaceParseTest.test_find_with_namespaceN)r r!r"rOrrrrrL�
srLc@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)r1)r2r�rrrr3�
sz1ElementSlicingTest._elem_tags.<locals>.<listcomp>r)rZelemlistrrr�
_elem_tags�
szElementSlicingTest._elem_tagscCs|�t|��S)N)rQrP)rr+rrr�
_subelem_tags�
sz ElementSlicingTest._subelem_tagscCs0t�d�}x t|�D]}t�|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)rrMr�r�)rZnumchildrenr�r�rrr�_make_elem_with_children�
s
z+ElementSlicingTest._make_elem_with_childrencsZ|�d��|��djd�|��djd�|�t�fdd��|�t�fdd��dS)	Nr�r\�a1����a8cs�dS)N�rr)r�rrr�
r�z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>cs�dS)Ni�rr)r�rrr�
r�)rSrNr1r��
IndexError)rr)r�r�test_getslice_single_index�
s

z-ElementSlicingTest.test_getslice_single_indexcCs�|�d�}|�|�|dd��dddg�|�|�|dd��dddg�|�|�|dd��dddg�|�|�|dd��ddg�|�|�|dd��ddg�|�|�|dd	��d
dg�dS)Nr�r��a3�a4�a5�rTr�r��a0rT)rSrNrQ)rr�rrr�test_getslice_range�
s
   z&ElementSlicingTest.test_getslice_rangec	Cs�|�d�}|�|�|ddd��ddg�|�|�|ddd��ddd	dg�|�|�|ddd��ddg�|�|�|ddd��d
dg�|�|�|ddtj��dg�|�|�|ddtjd>��dg�dS)Nr��r\rVZa9r�r^rZZa6rT�@)rSrNrQr;�maxsize)rr�rrr�test_getslice_steps�
s
 $   z&ElementSlicingTest.test_getslice_stepsc	Cs�|�d�}|�|�|ddd��ddddg�|�|�|ddd��ddg�|�|�|ddtj��dg�|�|�|ddtjd	��dg�|�|�|ddtjd
>��dg�dS)Nr�r�rZ�a2rTr^rUr�r\ra)rSrNrQr;rb)rr�rrr�test_getslice_negative_steps�
s
$ "&z/ElementSlicingTest.test_getslice_negative_stepscCs�|�d�}|dd�=|�|�|�ddg�|�d�}|dd�=|�|�|�g�|�d�}|ddd�=|�|�|�g�|�d�}|ddd�=|�|�|�ddg�|�d�}|d	dd�=|�|�|�ddg�|�d�}|ddd�=|�|�|�d
g�dS)Nr�rr�rdrZr�rUr^r\rT)rSrNrR)rr�rrr�
test_delslice�
s$







z ElementSlicingTest.test_delslicec	Cs�|�d�}t�d�|d<|�|�|�ddddg�t�d�|d<|�|�|�ddddg�|�t��t�d	�|d
<WdQRX|�t��t�d	�|d<WdQRX|�|�|�ddddg�dS)Nr�r�r\r^rdrZr�rUr�rT���)rSrrMrNrRr�rX)rr�rrr�test_setslice_single_index�
s
z-ElementSlicingTest.test_setslice_single_indexcCs�|�d�}dd�td�D�|dd�<|�|�|�ddd	d
g�|�d�}t�d�g|dd�<|�|�|�ddd
g�|�d�}dd�td�D�|dd�<|�|�|�ddd	d
d
g�dS)Nr�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr3
sz:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>r�r\r�r^�b0�b1rZr�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr3sZb2)rSr�rNrRrrM)rr�rrr�test_setslice_ranges


z&ElementSlicingTest.test_setslice_rangec	Csd|�d�}dd�td�D�|ddd�<|�|�|�ddd	d
ddg�|�d�}|�t��t�d
�g|ddd�<WdQRX|�t��"dd�td�D�|ddd�<WdQRX|�t��g|ddd�<WdQRX|�|�|�ddd	dddg�|�d�}t�d
�g|ddtj	�<|�|�|�dd
d	dg�t�d�g|ddtj	d>�<|�|�|�ddd	dg�dS)Nr�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr3sz:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>r�r\rTr^rirdrjr[r\r�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr3sr�rTrZr�r�ra)
rSr�rNrRr�r�rrMr;rb)rr�rrr�test_setslice_stepss 

 &
z&ElementSlicingTest.test_setslice_stepsc	Cs�|�d�}dd�td�D�|ddd�<|�|�|�ddd	d
g�|�d�}|�t��t�d�g|ddd�<WdQRX|�t��"dd�td
�D�|ddd�<WdQRX|�t��g|ddd�<WdQRX|�|�|�dddd
g�|�d�}t�d�g|ddtj	�<|�|�|�dddd
g�t�d�g|ddtj	d�<|�|�|�dddd
g�t�d�g|ddtj	d>�<|�|�|�dddd
g�dS)Nr�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr3+szCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>r�rr�r^rjrirZr�cSsg|]}t�d|��qS)zb%s)rrM)r2r�rrrr32sr�rTrdr\r�r�ra)
rSr�rNrRr�r�rrMr;rb)rr�rrr�test_setslice_negative_steps)s$

 &
z/ElementSlicingTest.test_setslice_negative_stepsN)r r!r"rQrRrSrYr_rcrerfrhrkrlrmrrrrrP�
s
	

	
rPc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZGdd�d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�IOTestc
Cs�t�d�}d|_|�t|�d�xNdD]F}|�|��2|�t||d�d�|�t||��d�d�WdQRXq&WxfdD]^}|�|��J|�t||d�d|�|��|��}|�t||d�d|�|��WdQRXqvWt�d�}d	|_|�t|�d
�|�t|dd�d�|�t|d
d�d�x,dD]$}|�t||d�d|�|���q&Wt�d�}d	|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�x,dD]$}|�t||d�d|�|���q�Wt�d�}d|_|�t|�d�|�t|dd�d�|�t|d
d�d�x,dD]$}|�t||d�d|�|���qWt�d�}d|jd<|�t|�d�|�t|dd�d�|�t|d
d�d�x,dD]$}|�t||d�d|�|���q�WdS)Nr1�abcz<tag>abc</tag>)zutf-8zus-ascii)r$s<tag>abc</tag>)z
iso-8859-1zutf-16zutf-32z2<?xml version='1.0' encoding='%s'?>
<tag>abc</tag>z<&"'>z<tag>&lt;&amp;"'&gt;</tag>zutf-8s<tag>&lt;&amp;"'&gt;</tag>zus-asciiz><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>rdz"<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;" />)z
iso-8859-1zutf-16zutf-16lezutf-16bezutf-32u@<?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	rrMrJrNr0rU�upperr�rK)rr+�encrprrrr+As|












zIOTest.test_encodingc	CsR|�tjt�t�t�d��}|�t�ttd��}|�	|�
�d�WdQRXdS)Nz<site />r�s<site />)r�rr�rrrr�r(r�rNr�)rr/r�rrr�test_write_to_filename�s

zIOTest.test_write_to_filenamec	Cs||�tjt�t�t�d��}ttddd�� }|j|dd�|�	|j
�WdQRXttd��}|�|��d�WdQRXdS)Nz<site />r�zutf-8)r$r#r�s<site />)
r�rr�rrrr�r�r(r�r�rNr�)rr/r�rrr�test_write_to_text_file�szIOTest.test_write_to_text_filec	Cst|�tjt�t�t�d��}ttd��}|�|�|�	|j
�WdQRXttd��}|�|��d�WdQRXdS)Nz<site />r�r�s<site />)
r�rr�rrrr�r�r(r�r�rNr�)rr/r�rrr�test_write_to_binary_file�s
z IOTest.test_write_to_binary_filec	Cs�|�tjt�t�t�d��}ttd�� }|j|dd�|�	|j
�WdQRXttd��}|�|��d�
d��WdQRXttddd�� }|j|dd�|�	|j
�WdQRXttd��}|�|��d�
d��WdQRXdS)	Nz<site />r�zutf-16)r$r�z0<?xml version='1.0' encoding='utf-16'?>
<site />r)�	buffering)r�rr�rrrr�r�r(r�r�rNr�r�)rr/r�rrr�"test_write_to_binary_file_with_bom�s 

z)IOTest.test_write_to_binary_file_with_bomcCs2t��}t�d�}|�|�|�|��jd�dS)Nz"<?xml version="1.0"?><site></site>�site)rrr%r'r�rNrwr1)rr/r�rrr�test_read_from_stringio�s

zIOTest.test_read_from_stringiocCs:t�t�d��}t��}|j|dd�|�|��d�dS)Nz<site />r#)r$)rrr�r%r'r(rNr))rr/r�rrr�test_write_to_stringio�szIOTest.test_write_to_stringiocCs2t��}t�d�}|�|�|�|��jd�dS)Ns"<?xml version="1.0"?><site></site>rw)rrr%r&r�rNrwr1)rr/r�rrr�test_read_from_bytesio�s

zIOTest.test_read_from_bytesiocCs6t�t�d��}t��}|�|�|�|��d�dS)Nz<site />s<site />)rrr�r%r&r(rNr))rr/r�rrr�test_write_to_bytesio�s
zIOTest.test_write_to_bytesioc@seZdZdS)zIOTest.dummyN)r r!r"rrrr�dummy�sr|cCsBt�d�}|��}|j|_t��}|�|�|�|��j	d�dS)Nz"<?xml version="1.0"?><site></site>rw)
r%r'r|r�rrr�rNrwr1)rr��readerr/rrr�test_read_from_user_text_reader�s

z&IOTest.test_read_from_user_text_readercCsJt�t�d��}t��}|��}|j|_|j|dd�|�|��d�dS)Nz<site />r#)r$)	rrr�r%r'r|r(rNr))rr/r��writerrrr�test_write_to_user_text_writer�sz%IOTest.test_write_to_user_text_writercCsJt�d�}|��}|j|_t��}|�|�|�|��j	d�t��}dS)Ns"<?xml version="1.0"?><site></site>rw)
r%r&r|r�rrr�rNrwr1)rr�r}r/rrr�!test_read_from_user_binary_reader�s

z(IOTest.test_read_from_user_binary_readercCsFt�t�d��}t��}|��}|j|_|�|�|�|��d�dS)Nz<site />s<site />)	rrr�r%r&r|r(rNr))rr/r�rrrr� test_write_to_user_binary_writer�s
z'IOTest.test_write_to_user_binary_writercCsbt�t�d��}t��}|��}|j|_dd�|_|j|_|j|dd�|�	|�
�d�d��dS)Nz<site />cSsdS)NTrrrrrr�r�zBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>zutf-16)r$z0<?xml version='1.0' encoding='utf-16'?>
<site />)rrr�r%r&r|r(�seekable�tellrNr)r�)rr/r�rrrr�)test_write_to_user_binary_writer_with_bom�s

z0IOTest.test_write_to_user_binary_writer_with_bomc	CsRt�d�}|�t�|d�d�t�|d���|�t�|d�d�t�|d���dS)Nz<tag>foo</tag>r#r^zutf-16r�)rr�rNr�r�r�)rr�rrr�test_tostringlist_invariant�s


z"IOTest.test_tostringlist_invariantcCsRt�d�}|�t�|d�d�|�tj|ddd�d�|�tj|ddd�d�dS)Nz<tag>a<x />b<y></y>c</tag>r#z<tag>a<x />b<y />c</tag>T)Zshort_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)rr�rNr�)rr�rrr�test_short_empty_elementss

z IOTest.test_short_empty_elementsN)r r!r"r+rrrsrtrvrxryrzr{r|r~r�r�r�r�r�r�rrrrrn@s"E				rnc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�ParseErrorTestcCs|�t��t�dS)N)rLrr�r)rrrrr%szParseErrorTest.test_subclassc
Cs8yt�|�Wn$tjk
r2}z|Sd}~XYnXdS)N)rr�r�)rr�r�rrr�
_get_errorszParseErrorTest._get_errorcCs@|�|�d�jd�|�|�d�jd�|�|�d�jd�dS)Nr�)r\rz<tag>&foo;</tag>)r\rTzfoobar<)r\r�)rNr�Zposition)rrrr�test_error_positionsz"ParseErrorTest.test_error_positioncCs8ddlmmm}|�|�d�j|j|j�dS)Nrr�)	Zxml.parsers.expat.errors�parsersZexpat�errorsrNr��codeZcodesZXML_ERROR_SYNTAX)rZERRORSrrr�test_error_code szParseErrorTest.test_error_codeN)r r!r"r%r�r�r�rrrrr�sr�c@seZdZdd�ZdS)�KeywordArgsTestc
Cs�t�d�}|�|�dd�|jddd��|�|�ddd�|jdddd��|�|�dd�|jddd��|�t|�dd��t|jddd���|�t�d�j	i�t�dt
ddd��tjdt
ddd�d�tjdt
dd	�dd
�tjdddd�tjdt
ddd�ddd�g}x2|D]*}|�|jd�|�|j	t
ddd���qWtj|ddd
did�}|�|j	d
d�|�
td��t�dd�WdQRX|�
td��tjddd�WdQRXdS)Nz
<a>foo</a>r�)�pathr)r�r�r�#r�)rf�id)rK)rf)r�rr"Zkey1Zvalue1zmust be dict, not strzI'm not a dict)rr�rNrr�r�rPr�rMrKr@r1r�rrp)rrV�elementsr�r�rrr�test_issue14818)s0

zKeywordArgsTest.test_issue14818N)r r!r"r�rrrrr�&sr�c@seZdZdd�Zdd�ZdS)�NoAcceleratorTestcCstst�d��dS)Nzonly for the Python version)r7r��SkipTest)rrrrr�KszNoAcceleratorTest.setUpcCs(|�tjjtj�|�tjjtj�dS)N)rLr7rMr]�types�FunctionTyper�)rrrr�test_correct_import_pyETPsz*NoAcceleratorTest.test_correct_import_pyETN)r r!r"r�r�rrrrr�Jsr�cCs�tddgd�a|dkrt}|attttttt	t
ttt
tttttg}ttk	rV|�tg�ddlm}tjj}|��}|j}|��|_ztj|�Wdddlm}|��|�|�||_daaXdS)Nzxml.etree.ElementTreer)Zblockedr)r)rr7rrrPr�r�r�rYrnr�rbr�r�rrr:rOror{r�rrr�Z_namespace_mapr�r�rZrun_unittestr�r})�moduleZtest_classesrr	Z
nsmap_copyr�rrr�	test_mainZsH


r��__main__)Tr#)N)Er�rr-r%rSr<r;r�r�rAr��	itertoolsrr
rZtest.supportrrrrrr7rr�r��UnicodeEncodeErrorr�r�r�r�rr4rNr1r2rZTestCaserr0r5r6rYrOrc�format�escapermrbror�r�r�r��__hash__r�r�r�r�rrr:rLrPrnr�r�r�r�r rrrr�<module>s�





#n	
	h],48(c
R$
;