Your IP : 216.73.216.196


Current Path : /opt/alt/python310/lib64/python3.10/test/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/test/__pycache__/test_minidom.cpython-310.opt-2.pyc

o

$�iY�@s�ddlZddlZddlZddlZddlmZddlZddlZddlZ	ddlm
Z
mZmZm
Z
mZmZddlmZddlmZejddd�Zd	Zdd
d�Zdd
�Zdd�ZGdd�dej�Zedkrge��dSdS)�N)�support)�parse�Attr�Node�Document�Element�parseString)�getDOMImplementation)�
ExpatErrorztest.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��dd|�S)N�doc)r	�createDocument)�doctype�r�8/opt/alt/python310/lib64/python3.10/test/test_minidom.py�create_doc_without_doctype�rcCsxt��ddd�}g|j_g|j_tjj�ddd�}|jj�	|�tjj�
dddd�}d|_d|_d|_
|jj�	|�|S)	Nrzmy-notationz"http://xml.python.org/notations/myz	my-entityz!http://xml.python.org/entities/myz1.0�utf-8�us-ascii)r	ZcreateDocumentType�entitiesZ_seq�	notations�xml�dom�minidomZNotation�appendZEntity�version�encoding�actualEncoding)r
Znotation�entityrrr�create_nonempty_doctype!s ��rcCs.t�}t|�}||j�d�_||j�d�_|S�Nr)rrr�item�
ownerDocumentr)r
rrrr�create_doc_with_doctype1s
r"c@s�eZdZ�d$dd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Ze�d�dd��Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�Z d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:dodp�Z;dqdr�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdd��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�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�ZzGd�d�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��d�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��d�d�Z��d�d �Z��d!�d"�Z��d#S(%�MinidomTest�TestcCs|�||�dS�N)�
assertTrue)�self�testZtestnamerrr�confirm9rzMinidomTest.confirmcCs"|j}|�||kd||f�dS)Nzlooking for %r, found %r)�	wholeTextr))r'�node�s�trrr�checkWholeText<szMinidomTest.checkWholeTextcCs"t�}|�|j�|�tj�dSr%)r�assertFalseZasync_�r'rrrr�testDocumentAsyncAttr@sz!MinidomTest.testDocumentAsyncAttrcCsPttd��}t|�}|��|�t|t��Wd�dS1s!wYdS)N�rb��open�tstfiler�unlinkr)�
isinstancer�r'�filerrrr�testParseFromBinaryFileEs
"�z#MinidomTest.testParseFromBinaryFilecCsTttddd��}t|�}|��|�t|t��Wd�dS1s#wYdS)N�rz
iso-8859-1)rr3r8rrr�testParseFromTextFileKs
"�z!MinidomTest.testParseFromTextFilecCsJtdddd�}|�|jd�|�|jd�|�|jd�|�|jd�dS)N�qName�namespaceURI�	localName�prefix�r�assertEqual�namer>r@r?�r'�attrrrr�testAttrModeSetsParamsAsAttrsQs
z)MinidomTest.testAttrModeSetsParamsAsAttrscCsLtdddd�}|�|jd�|�|jd�|�|jd�|�|j|j�dS)Nr=r>r@rArDrrr� testAttrModeSetsNonOptionalAttrsXs
z,MinidomTest.testAttrModeSetsNonOptionalAttrscCs0tt�}|�|�d�|j�d�k�|��dS)NZLI)rr5r)�getElementsByTagName�documentElementr6�r'rrrr�testGetElementsByTagName_s

�z$MinidomTest.testGetElementsByTagNamecCs�td�}|j}|jd}|�d�}|�||�|�t|j�dkoS|jjdkoS|jd|uoS|j�d�|uoS|jd|uoS|j�d�|uoS|j	|uoS|j
|uoS|��dkd�|�d�}|�|d�|�t|j�dko�|jjdko�|jd|uo�|j�d�|uo�|jd|uo�|j�d�|uo�|j
|uo�|j|uo�|��d	kd�|�d
�}|�||�|�t|j�dko�|jjdko�|jd|uo�|j�d�|uo�|jd|uo�|j�d�|uo�|j
|uo�|j|uo�|��dkd�|��dS)
N�<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>)rrI�
childNodes�
createElement�insertBeforer)�len�lengthr �
firstChild�	lastChild�toxml�previousSibling�nextSiblingr6)r'r�root�elemZnelemZnelem2rrr�testInsertBeforees�


�������
�


�������
�


���������zMinidomTest.testInsertBeforecCsrtd�}|�d�}|�d�}|�d�}|�d�}|j�|�|��}|�|�|�|�|�|�||||||fS)N�<doc/>Zoriginal�foorQZbat)r�createTextNoderI�appendChildZcreateDocumentFragment�r'rZorigZc1Zc2Zc3Zfragrrr�_create_fragment_test_nodes�s






z'MinidomTest._create_fragment_test_nodescCs�|��\}}}}}}|j�|d�|�t|jj�||||fkd�|��|��|��\}}}}}}|j�||�|�t|jj�||||fkd�|��|��dS)NzinsertBefore(<fragment>, None)zinsertBefore(<fragment>, orig))rerIrUr)�tuplerSr6rdrrr�testInsertBeforeFragment�s$
��
��z$MinidomTest.testInsertBeforeFragmentcCsVtt�}|j�|�d��|�|jjdjdk�|�|jjdjdk�|�	�dS)NZHello���z#comment)
rr5rIrc�
createCommentr)rS�nodeName�datar6rJrrr�testAppendChild�s
zMinidomTest.testAppendChildZcpucsrt�}|�ddd���j}�fdd�tdd�D�}|}t��}|D]	}|�|�|}q!t��}|�||d�dS)NZsome_tagcsg|]
}��d|����qS)zchild-)rT)�.0�i�Znewdocrr�
<listcomp>�szDMinidomTest.testAppendChildNoQuadraticComplexity.<locals>.<listcomp>rOi�rR)r	rrI�range�time�	monotonicrcZ
assertLess)r'�implZtop_element�childrenrM�start�child�endrror�$testAppendChildNoQuadraticComplexity�s
z0MinidomTest.testAppendChildNoQuadraticComplexitycCs6td�}td�}d|_|�|�|�|�d�d�dS)Nr(�idztest-id)rr�value�setAttributeNoderB�getAttribute)r'r^rErrr�(testSetAttributeNodeWithoutOwnerDocument�s

z4MinidomTest.testSetAttributeNodeWithoutOwnerDocumentcCsT|��\}}}}}}|j�|�|�t|jj�||||fkd�|��|��dS)NzappendChild(<fragment>))rerIrcr)rfrSr6rdrrr�testAppendChildFragment�s
��z#MinidomTest.testAppendChildFragmentcCs\|��\}}}}}}|j�||�|��|�t|jj�|||fkd�|��|��dS)NzreplaceChild(<fragment>))rerI�replaceChildr6r)rfrSrdrrr�testReplaceChildFragment�s�z$MinidomTest.testReplaceChildFragmentcCs�t�}|�d�}|�d�}|�tjj|j|�|�|�|�tjj|j||�|�tjj|j	||�|j
}|�tjj|j|�|�tjj|j|�|�|�|�
�dS)NrM�text)rrTrb�assertRaisesrr�HierarchyRequestErrrcrUr��
attributesZsetNamedItemZsetNamedItemNSr6)r'rr^r�Znodemaprrr�testLegalChildren�s(


����
zMinidomTest.testLegalChildrencCs�t�}|�d�}|j}d|d<|�d�}|�|j|ud�|�|j|ud�|�|jdkd�|�|jdkd�|�	�|�	�dS)	NrMrQrarz-NamedNodeMap.__setitem__() sets ownerDocumentz,NamedNodeMap.__setitem__() sets ownerElementz%NamedNodeMap.__setitem__() sets valuez)NamedNodeMap.__setitem__() sets nodeValue)
rrTr�r r)r!�ownerElementr{�	nodeValuer6)r'rr^�attrs�arrr�testNamedNodeMapSetItem�s&

����z#MinidomTest.testNamedNodeMapSetItemcCsBtt�}|�|�|�|�d��|�|jdj�|��dS)Nrarh)rr5r)rcrirSr6rJrrr�testNonZeros

zMinidomTest.testNonZerocCs,tt�}|�|j�|��|�|j�dSr%)rr5r&rSr6r/rJrrr�
testUnlinkszMinidomTest.testUnlinkcCsDtt��}|�|j�Wd�n1swY|�|j�dSr%)rr5r&rSr/rJrrr�testContexts
�zMinidomTest.testContextcCs.t�}|�|�d��|�|j�|��dS�N�abc)rrcrTr)rIr6rJrrr�testElementszMinidomTest.testElementcCsjtd�}|j}|�dd�|�|��dkd�|�d�}|�|j|ud�|�|j|jud�|��dS)N�<abc/>�spam�jam2�<abc spam="jam2"/>�testAAAz!setAttribute() sets ownerDocumentz setAttribute() sets ownerElement)	rrI�setAttributer)rZ�getAttributeNoder!r�r6)r'r�elr�rrrr�#s
��zMinidomTest.testAAAcCsFtd�}|j}|�dd�|�dd�|�|��dkd�|��dS)Nr�r��jamr�r��testAAB)rrIr�r)rZr6�r'rr�rrrr�/szMinidomTest.testAABcCs�t�}|�|�d��}|�dd�|�|�d�dk�|�|jdjdk�|�dd�|�|�d�dk�|�|jdjdk�|�t|j�dk�|�dd�|�|�d�dk�|�|jdjdk�|�t|j�dk�|�	�dS)Nr��def�ghiZjklZmnorNZnewval)
rrcrTr�r)r}r�r{rVr6�r'rrwrrr�testAddAttr7szMinidomTest.testAddAttrcCsrt�}|�|�d��}|�t|j�dk�|�dd�|�t|j�dk�|jd=|�t|j�dk�|��dS)Nr�rr�r�rO)rrcrTr)rVr�r�r6r�rrr�testDeleteAttrLszMinidomTest.testDeleteAttrcCstt�}|�|�d��}|�dd�|�t|j�dk�|�tj	j
|jd�|�d�|�t|j�dk�|��dS)Nr�r�r�rOrar)
rrcrTr�r)rVr�r�rr�NotFoundErrZremoveAttributer6r�rrr�testRemoveAttrWs
zMinidomTest.testRemoveAttrcCs�t�}|�|�dd��}|�ddd�|�ddd�|�tjj|jdd�|�	t
|j�dk�|�dd�|�	t
|j�d	k�|��dS)
N�http://www.python.org�
python:abc�http://www.w3.org�xmlns:pythonzpython:abcattrrarNZabcattrrO)
rrc�createElementNS�setAttributeNSr�rrr�ZremoveAttributeNSr)rVr�r6r�rrr�testRemoveAttrNSbs
���zMinidomTest.testRemoveAttrNScCs�t�}|�|�d��}|�dd�|�t|j�dk�|�d�}|�t	j
j|jd�|�
||�|��|�t|j�dkoB|�d�du�t�}|�|�d��}|�d�}|�t	j
j|j|�|��dS)Nrar�r�rOr)rrcrTr�r)rVr�r�r�rrr�ZremoveAttributeNode�assertIsr6)r'rrwr+�dom2�child2Znode2rrr�testRemoveAttributeNodeps&
��
�z#MinidomTest.testRemoveAttributeNodecCs6t�}|�|�d��}|�dd�|�|�d��dS)Nrar�r�)rrcrTr�r)ZhasAttributer�rrr�testHasAttribute�szMinidomTest.testHasAttributecCs�td�}|j}|�dd�|�t|j�dk�|�dd�|�d�|�t|j�dkoG|jdjdkoG|jdjdkoG|�	d�dkoG|�
d�j�d|jd<|�t|j�dkos|jdjdkos|jdjdkos|�	d�dkos|jdj�|�dd�|�t|j�dko�|jdjdko�|jdjdko�|�	d�dko�|jdjdko�|jdjdko�|�	d�dk�d	|jd<|�t|j�dko�|jdjdko�|jdjdko�|�	d�dko�|jdjd	ko�|jdjd	ko�|�	d�d	k�|��dS)
Nr�r�r�rOZbamZhamZspam2rNZbam2)
rrIr�r)rVr��setIdAttributer{r�r}r��isIdr6r�rrr�testChangeAttr�sl
���
�
���
�������
������zMinidomTest.testChangeAttrcC�dSr%r�r'rrr�testGetAttrList��zMinidomTest.testGetAttrListcCr�r%rr�rrr�testGetAttrValues�r�zMinidomTest.testGetAttrValuescCr�r%rr�rrr�testGetAttrLength�r�zMinidomTest.testGetAttrLengthcCs.t�}|�|�dd��}|�|�d�d�dS)Nr�r��missing�)rrcr�rBr}r�rrr�testGetAttribute�s

�zMinidomTest.testGetAttributecCsvt�}|�|�dd��}|�ddd�|�|�dd�d�|�|�dd�d�|�|�d��}|�|�dd	�d�dS)
Nr�r�r�r�Zpython�otherr�r�r�)rrcr�r�rBZgetAttributeNSrT)r'rrwr�rrr�testGetAttributeNS�s"
�����zMinidomTest.testGetAttributeNScCr�r%rr�rrr�testGetAttributeNode��z MinidomTest.testGetAttributeNodecCs|d}t|�}|�dd�}|�t|�dko6|djdko6|djdko6|djdko6|djdko6|djdk�|�	�dS)NzZ<foo xmlns:minidom='http://pyxml.sf.net/minidom'>
        <minidom:myelem/>
        </foo>zhttp://pyxml.sf.net/minidomZmyelemrOrrzminidom:myelem)
r�getElementsByTagNameNSr)rVr>r?r@�tagNamerjr6)r'�drZelemsrrr�testGetElementsByTagNameNS�s"������z&MinidomTest.testGetElementsByTagNameNScCs"|�||�}|�t|�dk�dSr)r�r)rV)r'rZnsuriZlnameZnodelistrrr�5get_empty_nodelist_from_elements_by_tagName_ns_helper�szAMinidomTest.get_empty_nodelist_from_elements_by_tagName_ns_helpercCshtd�}|�|dd�|�|dd�|�|dd�td�}|�|dd�|�|dd�|�|d	d
�dS)Nr`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�r0rrr�+testGetEmptyNodeListFromElementsByTagNameNS�s(������z7MinidomTest.testGetEmptyNodeListFromElementsByTagNameNScC�@t�}|�|�d��}t|�}t|�}|�||k�|��dSr��rrcrT�repr�strr)r6�r'rr�Zstring1Zstring2rrr�testElementReprAndStr��z!MinidomTest.testElementReprAndStrcCr�r�r�r�rrr�testElementReprAndStrUnicode�r�z(MinidomTest.testElementReprAndStrUnicodecCsPt�}|�|�dd��}t|�}t|�}|�||k�|�d|v�|��dS)Nzhttp://www.slashdot.orgz	slash:abc)rrcr�r�r�r)r6r�rrr�testElementReprAndStrUnicodeNSs
�z*MinidomTest.testElementReprAndStrUnicodeNScCsDt�}|�|�d��}|�dd�}|�t|�t|�k�|��dS)Nr�r�)rrcrTr�r)r�r�r6)r'rr�r+rrr�testAttributeReprs
zMinidomTest.testAttributeReprcCr�r%rr�rrr�testTextNodeReprr�zMinidomTest.testTextNodeReprcCs.d}t|�}|��}|��|�||k�dS)Nz <?xml version="1.0" ?><a b="c"/>)rrZr6r)�r'r�rZdomstrrrr�testWriteXMLs
zMinidomTest.testWriteXMLcCs:d}t|�}|jdd�}|��|�||�dd�k�dS)Nz"<?xml version="1.0" ?>
<a b="c"/>
z
)Znewl�
)r�toprettyxmlr6r)�replacer�rrr�testAltNewlines
zMinidomTest.testAltNewlinecCs�d}|�td���|d�|�td���|d�|�td���|d�|�td���|d	�|�td
���|d�dS)N�<?xml version="1.0" ?>
�<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>
)rBrr�)r'�declrrr� test_toprettyxml_with_text_nodes#s �����z,MinidomTest.test_toprettyxml_with_text_nodescCsVt�}|�d�}|�|�d��|�|�d��|�|�d}|�|��|d�dS)Nr^ZTEXTr�z<elem>
	TEXT
	TEXT
</elem>
)rrTrcrbrBr�)r'rr^r�rrr�)test_toprettyxml_with_adjacent_text_nodes1s


�z5MinidomTest.test_toprettyxml_with_adjacent_text_nodescCsVdD]&}t|�}t|���}|�|�d�djd��|�d�djd���qdS)N)r�z<A><B>C</B></A>�Br)rr�rBrHrSrZ)r'r�rr�rrr�/test_toprettyxml_preserves_content_of_text_node<s��z;MinidomTest.test_toprettyxml_preserves_content_of_text_nodecCs�td�}|jj}|�|jdkoE|jdkoE|jdkoE|jtj	koE|j
duoE|��oEt|j
�dkoE|jduoE|jduoE|jduoE|jtjjk�dS)Nz<e><?mypi 	
 data 	
 ?></e>Zmypizdata 	
 r)rrIrXr)�targetrkrj�nodeTyper�PROCESSING_INSTRUCTION_NODEr��
hasChildNodesrVrSrYr?r>rr�EMPTY_NAMESPACE)r'r�pirrr�testProcessingInstructionEs.��
������	�
�z%MinidomTest.testProcessingInstructioncCr�r%rr�rrr�testProcessingInstructionReprTr�z)MinidomTest.testProcessingInstructionReprcCr�r%rr�rrr�testTextReprVr�zMinidomTest.testTextReprcCr�r%rr�rrr�
testWriteTextXr�zMinidomTest.testWriteTextcCr�r%rr�rrr�testDocumentElementZr�zMinidomTest.testDocumentElementcCs:td�}|�d�}|�tjj|j|�|��|��dS)Nr`Zextra)rrTr�rrr�rcr6�r'rr^rrr�testTooManyDocumentElements\s

z'MinidomTest.testTooManyDocumentElementscCr�r%rr�rrr�testCreateElementNSdr�zMinidomTest.testCreateElementNScCr�r%rr�rrr�testCreateAttributeNSfr�z!MinidomTest.testCreateAttributeNScCr�r%rr�rrr�	testParsehr�zMinidomTest.testParsecCr�r%rr�rrr�testParseStringjr�zMinidomTest.testParseStringcCr�r%rr�rrr�testCommentlr�zMinidomTest.testCommentcCr�r%rr�rrr�testAttrListItemnr�zMinidomTest.testAttrListItemcCr�r%rr�rrr�testAttrListItemspr�zMinidomTest.testAttrListItemscCr�r%rr�rrr�testAttrListItemNSrr�zMinidomTest.testAttrListItemNScCr�r%rr�rrr�testAttrListKeystr�zMinidomTest.testAttrListKeyscCr�r%rr�rrr�testAttrListKeysNSvr�zMinidomTest.testAttrListKeysNScCsPtd�}|j}|j}|�d�}|�d�}|�|�|��|�tj	j
|jd�dS)Nz<doc a=''/>r�)rrIr�r�ZremoveNamedItemr)�
isSameNoder�rrr��r'rr�r��a1�a2rrr�testRemoveNamedItemxs

zMinidomTest.testRemoveNamedItemcCsVtd�}|j}|j}|�dd�}|�dd�}|�|�|��|�tj	j
|jdd�dS)Nz.<doc xmlns:a='http://xml.python.org/' a:b=''/>zhttp://xml.python.org/�b)rrIr��getAttributeNodeNSZremoveNamedItemNSr)r�r�rrr�r�rrr�testRemoveNamedItemNS�s�z!MinidomTest.testRemoveNamedItemNScCr�r%rr�rrr�testAttrListValues�r�zMinidomTest.testAttrListValuescCr�r%rr�rrr�testAttrListLength�r�zMinidomTest.testAttrListLengthcCr�r%rr�rrr�testAttrList__getitem__�r�z#MinidomTest.testAttrList__getitem__cCr�r%rr�rrr�testAttrList__setitem__�r�z#MinidomTest.testAttrList__setitem__cCr�r%rr�rrr�testSetAttrValueandNodeValue�r�z(MinidomTest.testSetAttrValueandNodeValuecCr�r%rr�rrr�testParseElement�r�zMinidomTest.testParseElementcCr�r%rr�rrr�testParseAttributes�r�zMinidomTest.testParseAttributescCr�r%rr�rrr�testParseElementNamespaces�r�z&MinidomTest.testParseElementNamespacescCr�r%rr�rrr�testParseAttributeNamespaces�r�z(MinidomTest.testParseAttributeNamespacescCr�r%rr�rrr�testParseProcessingInstructions�r�z+MinidomTest.testParseProcessingInstructionscCr�r%rr�rrr�testChildNodes�r�zMinidomTest.testChildNodescCr�r%rr�rrr�testFirstChild�r�zMinidomTest.testFirstChildcCs<td�}|j}|�|���td�}|j}|�|���dS)NrLr`)rrIr&r�r/)r'rrr��doc2rrr�testHasChildNodes�szMinidomTest.testHasChildNodescCs�|j}|j}t|���}t|���}|��|��|�||kd�tt|��D]5}|�|�}	|�|�}
|�|	|
uoQ|	j|
jkoQ|	j	|
j	koQ|	j
|
j
koQ|	j|
jkd�|�|
j|ud�q(dS)Nz(clone of element has same attribute keysz3clone of attribute node has proper attribute valuesz'clone of attribute node correctly owned)
r��list�keys�sortr)rqrVr r{r�r>r?r�)r'�e1�e2r(Zattrs1Zattrs2Zkeys1Zkeys2rnr�r�rrr�!_testCloneElementCopiesAttributes�s0


�
�
�
���z-MinidomTest._testCloneElementCopiesAttributescCs^td�}|j}|�|�}|�||d|rdpd�d|_|_|�dd�|�dd	�||fS)
Nz<doc attr='value'><foo/></doc>ZtestCloneElementZDeepZShallowZMODIFIEDrEz	NEW VALUEZaddedZVALUE)rrI�	cloneNoderr�rjr�)r'�deeprr]�clonerrr�_setupCloneElement�s
�zMinidomTest._setupCloneElementcC�R|�d�\}}|�t|j�dko |jjdko |jduo |��dkd�|��dS)Nrz<doc attr="value"/>�testCloneElementShallow�rr)rVrSrW�
parentNoderZr6�r'rrrrrr��
��
�z#MinidomTest.testCloneElementShallowcCr)NrOz<doc attr="value"><foo/></doc>�testCloneElementDeeprrrrrr�rz MinidomTest.testCloneElementDeepcCs&td�}|�d�}|�|dud�dS)N��<?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!)rrr)�r'rrrrr�testCloneDocumentShallow�s


�z$MinidomTest.testCloneDocumentShallowcCs�td�}|�d�}|�|�|�p|�|�d�|�t|j�t|j�kd�|�|jjtj	kd�|�|jj
�|�d�|�|j�|j�d�|jduro|�|jjtjkd�|�|jj
�|��|�|j�|j��dSdS)	NrrOz4testCloneDocumentDeep: 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)
rrr)r�rVrSrIr�rZELEMENT_NODEr!r
�DOCUMENT_TYPE_NODErrrr�testCloneDocumentDeep�s0
�����
��z!MinidomTest.testCloneDocumentDeepcCs�t�}|�d�}|�|duoV|j|jkoV|j|jkoV|j|jkoV|j|jkoVt|j�t|j�koV|j�	t|j��duoVt|j
�t|j
�koV|j
�	t|j
��duoVt|j�dk�tt|j��D]G}|j�	|�}|j�	|�}|�|�
|�o�|�
|�o�|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jko�|j|jk�q_tt|j
��D]/}|j
�	|�}|j
�	|�}|�|�
|�o�|�
|�o�|j|jko�|j|jko�|j|jk�q�dS)NrOr)rrr)rjrC�publicId�systemIdrVrr rrSrqr��notationNamerrr)r'r
rrnZseZceZsnZcnrrr�testCloneDocumentTypeDeepOksl

�
�
�
�����	�

�
�
�
�
�
�
�
�	
�
�
�
��z'MinidomTest.testCloneDocumentTypeDeepOkcC�&t�}|j�d�}|�|dud�dS)NrO�testCloneDocumentTypeDeepNotOk�r"r
rr)�r'rrrrrr($�z*MinidomTest.testCloneDocumentTypeDeepNotOkcCs�t�}|�d�}|�|duoJ|j|jkoJ|j|jkoJ|j|jkoJ|j|jkoJt|j�dkoJ|j�	d�duoJt|j
�dkoJ|j
�	d�duoJt|j�dk�dSr)rrr)rjrCr#r$rVrr rrS)r'r
rrrr�testCloneDocumentTypeShallowOk)s*

�
�
�
�����	�z*MinidomTest.testCloneDocumentTypeShallowOkcCr')Nr�!testCloneDocumentTypeShallowNotOkr)r*rrrr-7r+z-MinidomTest.testCloneDocumentTypeShallowNotOkcCs*td�}td�}|�tjj|j||�dS)Nr`)rr�rr�NotSupportedErr�
importNode)r'r�testNameZdoc1rrrr�check_import_document<sz!MinidomTest.check_import_documentcC�|�dd�dS)Nr�testImportDocumentShallow�r1r�rrrr3Arz%MinidomTest.testImportDocumentShallowcCr2)NrO�testImportDocumentDeepr4r�rrrr5Drz"MinidomTest.testImportDocumentDeepcC�(t�}t�}|�tjj|j|jd�dSr�r"rr�rrr.r/r
�r'�srcr�rrr�testImportDocumentTypeShallowG�
�z)MinidomTest.testImportDocumentTypeShallowcCr6�NrOr7r8rrr�testImportDocumentTypeDeepMr;z&MinidomTest.testImportDocumentTypeDeepcCs�td�}|j�d�}|�|d�|�|�}|�|�|��|�|�|��|�|jdu|d�|�|j�|j�|d�|�|j	|d�dS)Nz<doc attr='value'/>rEz: ownerElement should be Nonez: ownerDocument does not matchz.: cloned attribute must have specified == True)
rrIr�ZassertNotEqualrr)r�r�r!Z	specified)r'rr0rrErrrr�check_clone_attributeUs
���z!MinidomTest.check_clone_attributecCr2)Nr�testCloneAttributeShallow�r>r�rrrr?crz%MinidomTest.testCloneAttributeShallowcCr2)NrO�testCloneAttributeDeepr@r�rrrrAfrz"MinidomTest.testCloneAttributeDeepcCsJtd�}|j}|�|jtj�|�|�}|�|j|jko!|j	|j	k�dS)Nz<?target data?><doc/>)
rrXrBr�rr�rr)r�rk)r'rr0rr�rrrr�check_clone_piis

�zMinidomTest.check_clone_picCr2)Nr�testClonePIShallow�rBr�rrrrCqrzMinidomTest.testClonePIShallowcCr2)NrO�testClonePIDeeprDr�rrrrEtrzMinidomTest.testClonePIDeepc
Cstjj�d���}Gdd�d�}|�}|j}|jd}|�dd|�|r?|jdd�}|�	|j
jjd	�tjj
j}|jjd}	n't�|d
d��|jdd�}Wd�n1sWwYtjj
j}|jd}	|�	|j|�|�	|jd�|�	|jd�|�|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"||_||_||_||_||_dSr%)�	operation�keyrkr9�dst�r'rFrGrkr9rHrrr�handle�s

z;MinidomTest.check_clone_node_entity.<locals>.Handler.handleN)�__name__�
__module__�__qualname__rJrrrr�Handler�srNZsmilerGrkT)ru%Don't let entities make you frown ☺r!)rrrr�stripr
r�setUserDatarrBrIrXr*�UserDataHandlerZ
NODE_IMPORTEDrZ	swap_attrZNODE_CLONEDrFrGrkr�r9rH)
r'Zclone_documentZdocumentrN�handlerr
rrrFrHrrr�check_clone_node_entityws2
�	
�
�

z#MinidomTest.check_clone_node_entitycCs|�d�|�d�dS)NFT)rSr�rrr�testCloneNodeEntity�s
zMinidomTest.testCloneNodeEntitycCs�td�}|j}|�|�d��|�|�d��|�t|j�dko%|jjdkd�|��|�t|j�dkoF|jjdkoF|j	|j
uoF|j	jdkd�|��td�}|j}|�|�d	��|��|�t|j�d
kon|jjd
kd�|��dS)Nr`�first�secondrNztestNormalize -- preparationrO�firstsecondztestNormalize -- resultr�rz*testNormalize -- single empty node removed)
rrIrcrbr)rVrSrW�	normalizerXrYrkr6�r'rr]rrr�
testNormalize�s6
�
�
�
�
�zMinidomTest.testNormalizecCs�td�}|j}|�|�d��|�|�d��|�|�d��|�t|j�dko-|jjdkd�|�	�|�t|j�dkoh|jjdkoh|j
jdkoh|j
|juoh|j
j
|juoh|j
jduoh|jj|j
uoh|jj
dud	�|��dS)
Nr`rUrVrnrPz1testNormalizeCombineAndNextSibling -- preparationrNrWz-testNormalizeCombinedAndNextSibling -- result)rrIrcrbrTr)rVrSrWrXrXrkrYr\r[r6rYrrr�"testNormalizeCombineAndNextSibling�s6
�
�
�
��
��
�	z.MinidomTest.testNormalizeCombineAndNextSiblingcCs�td�}|j}|�|�d��|�|�d��|�t|j�dko%|jjdkd�|��|�t|j�dkoR|jjdkoR|j	j
dkoR|j	|juoR|j	jduoR|j	j
dud�|��dS)Nr`rUr�rNz1testNormalizeDeleteWithPrevSibling -- preparationrOz,testNormalizeDeleteWithPrevSibling -- result�rrIrcrbr)rVrSrWrXrXrkrYr\r[r6rYrrr�"testNormalizeDeleteWithPrevSibling��,
�
�
�
�
�
�z.MinidomTest.testNormalizeDeleteWithPrevSiblingcCs�td�}|j}|�|�d��|�|�d��|�t|j�dko%|jjdkd�|��|�t|j�dkoR|jjdkoR|j	j
dkoR|j	|juoR|j	jduoR|j	j
dud�|��dS)Nr`r�rVrNz1testNormalizeDeleteWithNextSibling -- preparationrOz,testNormalizeDeleteWithNextSibling -- resultr\rYrrr�"testNormalizeDeleteWithNextSibling�r^z.MinidomTest.testNormalizeDeleteWithNextSiblingcCs�td�}|j}|�|�d��|�|�d��|�|�d��|�t|j�dko-|jjdkd�|�	�|�t|j�dkob|jjdkob|j
|juob|j
j|juob|j
j
duob|jj
|j
uob|jjdud�|��dS)Nr`rnr�rPz1testNormalizeDeleteWithTwoSiblings -- preparationrNz,testNormalizeDeleteWithTwoSiblings -- result)rrIrcrTrbr)rVrSrWrXrXrYr\r[r6rYrrr�)testNormalizeDeleteWithTwoNonTextSiblings�s2
�
�
��
��
�z5MinidomTest.testNormalizeDeleteWithTwoNonTextSiblingscCs�td�}|j}|�|�d��|�|�d��|�|�d��|�|�d��|�|�d��|�t|j�dko=|jjdkd�|��|�t|j�dkoj|jjdkoj|j	|j
uoj|j	jdkoj|j	jduoj|j	j
dud	�|��dS)
Nr`r�rVZfourth�z,testNormalizeDeleteAndCombine -- preparationrOZsecondfourthz'testNormalizeDeleteAndCombine -- result)rrIrcrbr)rVrSrWrXrXrYrkr[r\r6rYrrr�testNormalizeDeleteAndCombines2
�
�
�
�
�
�z)MinidomTest.testNormalizeDeleteAndCombinecCstd�}|j}|jd�|�d��|jd�|�d��|jdjd�|�d��|jd�|�d��|�|�d��|�t|j�dko�|jjdko�t|jdj�d	ko�|jdjjd	ko�t|jdj�dko�|jdjjdko�t|jdjdj�d
ko�|jdjdjjd
kd�|��|�t|j�d
ko�|jjd
ko�t|jdj�d
ko�|jdjjd
ko�t|jdj�d
ko�|jdjjd
ko�t|jdjdj�dko�|jdjdjjdkd�|�|jdjdj	d
k�o	|jdjdjdj	dk�o	|jdjdj	dkd�|�|jdjdj
du�o�|jdjdj|jdjdu�o�|jdjdjdu�o�|jdjdj
|jdjdu�o�|jdjdj
du�o�|jdjdj|jdjdu�o�|jdjdjdu�o�|jdjdj
|jdjdud�|��dS)Nz)<doc><o><i/>t</o><o><o>t2</o>t3</o></doc>rr��xrOZx2Zx3rPrRrNztestNormalize2 -- preparationz$testNormalize2 -- childNodes lengthsZtxZt2x2Zt3x3z$testNormalize2 -- joined text fieldsz"testNormalize2 -- sibling pointers)
rrIrSrcrbr)rVrWrXrkr\r[r6rYrrr�testNormalizeRecursion%s�
�������	
�������	����������	�
��
z"MinidomTest.testNormalizeRecursioncCs8td�}|jjd}|�|jtj�|��|��dS)Nz<o>text</o>r)	rrIrSrBr�r�	TEXT_NODErXr6)r'rr�rrr�testBug0777884ds
zMinidomTest.testBug0777884cCs>td�}|j}d|jd_|��|�|jdjdud�dS)Nz<o><i/>t</o>r�rOrhz)Final child's .nextSibling should be None)rrIrSr�rXr)r\�r'rr+rrr�testBug1433694ls�zMinidomTest.testBug1433694cCsjtd�}|j}|j\}}}|�|j|uo,|jduo,|j|uo,|j|uo,|jduo,|j|ud�|��dS)Nz<doc><?pi?>text?<elm/></doc>�testSiblings)rrIrSr)r\r[r6)r'rr]r�r�Zelmrrrrits����
�zMinidomTest.testSiblingscCsrtd�}|j}|jd}|j\}}|jd}|�|j|uo0|j|uo0|j|uo0|j|uo0|j|ud�|��dS)Nz3<doc><elm1><elm2/><elm2><elm3/></elm2></elm1></doc>r�testParents)rrIrSr)rr6)r'rr]Zelm1Zelm2aZelm2bZelm3rrrrj�s"�


���
�zMinidomTest.testParentscCs�td�}|j}|d}|�|d|�d�uo>|�d�duo>|j�d�|jduo>|j�d�|jduo>|j�d�j�d�dud�|��dS)Nz<doc><e/><e/></doc>rrOztest NodeList.item())rrSr)r r6)r'rruZdocelemrrr�testNodeListItem�s����zMinidomTest.testNodeListItemcCs�td�}|�|��d�|�|�d�d�|�|�d�d�|�|�d�d�|�|�d	�d
�d	��tjdkrG|�ttd�|�ttd
�n	|�ttftd�|�	�dS)N�<foo>&#x20ac;</foo>�$<?xml version="1.0" ?><foo>€</foo>rs4<?xml version="1.0" encoding="utf-8"?><foo>€</foo>ziso-8859-15s8<?xml version="1.0" encoding="iso-8859-15"?><foo>�</foo>rs;<?xml version="1.0" encoding="us-ascii"?><foo>&#8364;</foo>zutf-16u5<?xml version="1.0" encoding="utf-16"?><foo>€</foo>)rNrRras<fran�ais></fran�ais>s.<franais>Comment �a va ? Tr�s bien ?</franais>s0<fran�ais>Comment �a va ? Tr�s bien ?</fran�ais>)
rrBrZ�encode�pyexpat�version_infor�r
�UnicodeDecodeErrorr6r0rrr�
testEncodings�s8
�����
���zMinidomTest.testEncodingscCsttd�}|�|��d�|�|jdd�d�|�|jdd�d�|�|jdd�d�|�|�dd�d	�|��dS)
Nrlrm)Z
standaloneTu4<?xml version="1.0" standalone="yes"?><foo>€</foo>Fu3<?xml version="1.0" standalone="no"?><foo>€</foo>rsE<?xml version="1.0" encoding="utf-8" standalone="yes"?><foo>€</foo>)rrBrZr6r0rrr�testStandalone�s"
�����zMinidomTest.testStandalonec@seZdZdZdd�ZdS)zMinidomTest.UserDataHandlerrcCs*|�||d|�|�|dd�d|_dSr<)rP�calledrIrrrrJ�s
z"MinidomTest.UserDataHandler.handleN)rKrLrMrtrJrrrrrQ�srQcCs$t�}|�d�}|�|�d�du�|�ddd�|�|�d�du�|�ddd�|�ddd�|�|�d�dk�|�|�d�dk�|�ddd�|�|�d�du�|�|�d�dk�|��}|�dd|�|�d�}|�|jo�|�d�duo�|�d�dk�|��|��|��dS)Nr�ra�rQ�
rO)	rrTr)ZgetUserDatarPrQrrtr6)r'r�nrR�crrr�testUserData�s.


��zMinidomTest.testUserDatacCs@|�tjj|j|dd�td�}|�tjj|j|tjjd�dS)N�http://xml.python.org/nsz	xmlns:foor`ra)r�rr�NamespaceErr�
renameNoderZWrongDocumentErrr�)r'rr+rrrr� checkRenameNodeSharedConstraints�s��z,MinidomTest.checkRenameNodeSharedConstraintscCsLtd�}|j}|j}|jd}|�|tjjd�}|�|jdko[|j	dko[|j
duo[|jtjjko[|jduo[|j
dko[|�d�duo[|�d��|�o[|d�|�o[|j�|�o[|j�|��|�|dd�}|�|jdko�|j	dko�|j
dko�|jdko�|jduo�|j
dko�|�d�duo�|�d�duo�|�d��|�o�|�dd��|�o�|d�|�o�|d�|��|�|dd	�}|�|jd	k�o!|j	d	k�o!|j
d
k�o!|jdk�o!|jdk�o!|j
dk�o!|�d�du�o!|�d�du�o!|�d�du�o!|�dd�du�o!|�d	��|��o!|�dd
��|��o!|d	�|��o!|d�|��|�|tjjd
�}|�|jd
k�o�|j	d
k�o�|j
du�o�|jtjjk�o�|jdu�o�|j
dk�o�|�d�du�o�|�d�du�o�|�d�du�o�|�d	�du�o�|�dd�du�o�|�d
��|��o�|d
�|��|�tjj|j|dd�|�||�|��dS)Nz<doc a='v'/>r�r��vrzrx)rzrx�http://xml.python.org/ns2zp:dr��p)rr�r�Zxmlns)rrIr�r|rrr�r)rCrjr?r>r@r{r�r�r!r�r�r�r{r}r6)r'rr^ZattrmaprErrr�testRenameAttribute�s�
��������
	�

�
��������	������������	����������������	�
����
��zMinidomTest.testRenameAttributecCs~td�}|j}|�|tjjd�}|�|jdko2|jdko2|j	duo2|j
tjjko2|jduo2|j�
|��|�|dd�}|�|jdko[|jdko[|j	dko[|j
dko[|jduo[|j�
|��|�|dd�}|�|jdko�|jdko�|j	dko�|j
dko�|jdko�|j�
|��|�|tjjd	�}|�|jd	ko�|jd	ko�|j	duo�|j
tjjko�|jduo�|j�
|��|�||�|��dS)
Nr`r�rzr�rzp:crxr�r�)rrIr|rrr�r)r�rjr?r>r@r!r�r}r6r�rrr�testRenameElement<sh����
�����
�����
�����
�zMinidomTest.testRenameElementcCsLtjj���tjjdd�}|�d�}|�tjj|j	|tjjd�|�
�dS)Nr��commentra)rrrr	rr�rir�r.r|r6rgrrr�testRenameOthergs
�
�zMinidomTest.testRenameOthercCs:td�}|j}|jd}|�|jtj�|�|d�|�|�	d��|�|d�|�
|�d�|�|�|d�|�d�}|�|�|�	d	�}|�|�|�|d�|�|d	�|�
d
�}|�||�|}|�|d�|�|d	�|�dd�}|�||�|}|�|d�|�|d	�|�|�|�|d
�|�|d
�dS)Nz<doc>a</doc>rr�r�Zabrx�cabr�r�rc�y�zZcabd)rrIrSrBr�rrer.rcrbrU�createCDATASectionrirTr��createProcessingInstruction�removeChild)r'rr^r��splitter�text2rcrrr�
testWholeTextqs8






zMinidomTest.testWholeTextcCsHtd�}|j}|j}|�|j|ud�|�||�|�|j|ud�dS)Nz<doc><e/></doc>zBefore replaceChild()zAfter replaceChild())rrIrXr)rr�)r'rr^r�rrr�testPatch1094164�szMinidomTest.testPatch1094164cCs�dd�}|�\}}}}}|�d�}|�|d�|�|d�|�t|j�dk�|�\}}}}}|�d�}|�|d�|�|d�|�t|j�dk�|�\}}}}}|�d�}|�|d�|�|duoit|j�d	k�dS)
NcSsRtd�}|j}|j}|j}|j}|�|�d�|�|�|�d�|�|||||fS)Nz<doc>a<e/>d</doc>r�rx)rrIrXrYr\rUrbr�)rr^�text1r�r�rrr�setup�sz/MinidomTest.testReplaceWholeText.<locals>.setupznew contentr�rPr�rar�rN)ZreplaceWholeTextr.r)rVrS)r'r�rr^r�r�r�r�rrr�testReplaceWholeText�s"



�z MinidomTest.testReplaceWholeTextcCsvtd�}|j}|j}|�|jduo|jtjjk�d�	�}|D]}|�
|�}|j}|�t|d�o6|jtjjk�qdS)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 nmsrC)rrIZ
schemaTyper)rC�	namespacerrr��splitr��hasattr)r'rr^r-�namesrCr�rrr�testSchemaType�s ��
��zMinidomTest.testSchemaTypecCs6td�}|j}|�d�}|�d�}|�|�d�duo!|jo!|j�|�d�|�|�|�d��o8|jo8|j�|�d�|�|�|�d��oV|�|�d��oV|joV|j�|�d�}d|_	|�
|�|�|�d�duo�|�|�d��o�|jo�|jo�|j�|�|tj
jd�|�|�|�d��o�|j�dS)Nz<doc a1='v' a2='w'/>r�r�r~�w�an)rrIr�r)�getElementByIdr�r�r�ZcreateAttributer{r|r|rrr�)r'rr�r�r��a3rrr�testSetIdAttribute�sN

��
��
���

�����zMinidomTest.testSetIdAttributecCspd}d}td|d|d�}|j}|�|d�}|�|d�}|�|�d�duo/|jo/|j�|�|d�|�|�|�d��oG|joG|j�|�|d�|�|�|�d��of|�|�d	��of|jof|j�|�|d�}d|_	|�
|�|�|�|�d	���|�|j�|�|j�|�|j�|�|�d�du�|�|tj
jd
�|�|�|�d	��o�|j�dS�Nzhttp://xml.python.org/ns1rz<doc xmlns:ns1='z
' xmlns:ns2='z' ns1:a1='v' ns2:a2='w'/>r�r�r~r�r�)rrIr�r)r�r�ZsetIdAttributeNSr��createAttributeNSr{r|r|rrr��r'ZNS1ZNS2rr�r�r�r�rrr�testSetIdAttributeNS�sZ�����������
�z MinidomTest.testSetIdAttributeNScCsld}d}td|d|d�}|j}|�|d�}|�|d�}|�|�d�duo/|jo/|j�|�|�|�|�|�d��oF|joF|j�|�|�|�|�|�d��od|�|�d	��od|jod|j�|�|d�}d|_	|�
|�|�|�|�d	���|�|j�|�|j�|�|j�|�|�d�du�|�|tj
jd
�|�|�|�d	��o�|j�dSr�)rrIr�r)r�r�ZsetIdAttributeNoder�r�r{r|r|rrr�r�rrr�testSetIdAttributeNodesZ������
��
���
�z"MinidomTest.testSetIdAttributeNodecCs||fg}|�r	|��\}}|�|j|j�|�t|j�t|j��|�|j|j�|�|�|��|�|�|��|jtj	kr�t|j
�t|j
�t|j�t|j�|�t|j
�t|j
��|�t|j�t|j��tt|j��D]-}|j�
|�}|j�
|�}|�|j|j�|�|j|j�|�|j|j�|�||f�qstt|j
��D]-}|j
�
|�}	|j
�
|�}
|�|	j|
j�|�|	j|
j�|�|	j|
j�|�|	|
f�q�|jtjkr�|�|j�|��|�|j�|��tt|j��D]}|�|j||j|f�q�|sdSdSr%)�poprBr�rVrSrjr/r�rr!rrrqr rCr#r$rr%Z
DOCUMENT_NODEr&r!)r'rr�stackZn1Zn2rnZno1Zno2rrrrr�assert_recursive_equalCsF




�z"MinidomTest.assert_recursive_equalcCsDtt�}tdtjd�D]}t�||�}t�|�}|�||�qdS)NrNrO)r�samplerq�pickleZHIGHEST_PROTOCOL�dumps�loadsr�)r'r�protor,rrrr�testPickledDocumenths
�zMinidomTest.testPickledDocumentcCs"tt�}t�|�}|�||�dSr%)rr��copyZdeepcopyr�rrrr�testDeepcopiedDocumentos
z"MinidomTest.testDeepcopiedDocumentcCs(t�}|�|�d��|�t|j�dS)Nzfoo--bar)rrcrir��
ValueErrorrZr0rrr�(testSerializeCommentNodeWithDoubleHyphentsz4MinidomTest.testSerializeCommentNodeWithDoubleHyphencCs,td�}t|���}|�|jtjjk�dS)Nz$<element xmlns=''>
<foo/>
</element>)rrZr)r>rrr�rrrr�testEmptyXMLNSValuezszMinidomTest.testEmptyXMLNSValuecCs>|�ttfd��
td�Wd�dS1swYdS)Nz#(syntax error)|(Unsupported syntax)zE<element xmlns:abc="http:abc.com/de f g/hi/j k"><abc:foo /></element>)ZassertRaisesRegexr�r
rr�rrr�!testExceptionOnSpacesInXMLNSValue�s
"�z-MinidomTest.testExceptionOnSpacesInXMLNSValuecCsftt�}|j�d�d}|�tjj|j|�t	|j
�}|�|j
d�t	|j
�}|�||dk�dS)NZTITLErrO)rr5rIrHr�rrr�r�rVrSr&)r'rZ	title_tagZnum_children_beforeZnum_children_afterrrr�testDocRemoveChild�s

zMinidomTest.testDocRemoveChildcCstt�}|�dd�}d|_dS)Nr�r�Zcrash)rr5r�r�)r'rr�rrr�"testProcessingInstructionNameError�s
z.MinidomTest.testProcessingInstructionNameErrorcCs2d}t|�}t��}|�|�|�|��|�dS�N�E<?xml version="1.0" ?><curriculum status="public" company="example"/>)r�io�StringIOZwritexmlrB�getvalue)r'�xml_strr�outputrrr�test_minidom_attribute_order�s

z(MinidomTest.test_minidom_attribute_ordercCs d}t|�}|�|��|�dSr�)rrBrZ�r'r�rrrr�"test_toxml_with_attributes_ordered�sz.MinidomTest.test_toxml_with_attributes_orderedcC� d}t|�}|�|��d�dS)Nr�zG<?xml version="1.0" ?>
<curriculum status="public" company="example"/>
�rrBr�r�rrr�(test_toprettyxml_with_attributes_ordered��

�z4MinidomTest.test_toprettyxml_with_attributes_orderedcCr�)N�C<?xml version="1.0" ?><root><node><![CDATA[</data>]]></node></root>zH<?xml version="1.0" ?>
<root>
	<node><![CDATA[</data>]]></node>
</root>
r�r�rrr�test_toprettyxml_with_cdata�r�z'MinidomTest.test_toprettyxml_with_cdatacCsLd}t|�}|�|�d�djd�t|���}|�|�d�djd�dS)Nr�r+rz</data>)rr.rHrXr�)r'r�Zdom1r�rrr�test_cdata_parsing�s
zMinidomTest.test_cdata_parsingN)r$)�rKrLrMr)r.r1r:r<rFrGrKr_rergrlrZrequires_resourceryr~rr�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�rrrrrrrrrr	r
rrrrrr r"r&r(r,r-r1r3r5r:r=r>r?rArBrCrErSrTrZr[r]r_r`rbrdrfrhrirjrkrrrsrQryr}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr#8s$+

		&
		
		"/?M+
$
	!$$%		r#�__main__r%)r�r�rrr�r(rZunittestroZxml.dom.minidomrrrrrrrr	Zxml.parsers.expatr
Zfindfiler5r�rrr"ZTestCaser#rK�mainrrrr�<module>sB 
�