
    <e}                    l   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
Z
d dlZd dlZd dlZd dlmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZ d dlmZ d d	lmZ dada ed
d          Z 	 e !                    d           n# e"$ r  ej#        d          w xY w edd          Z$ edd          Z%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dddZ-d Z. G d dej/                  Z0dod Z1d! Z2 G d" d#          Z3 G d$ d%ej/                  Z4 G d& d'ej/                  Z5i Z6d(e6d)<   d*e6d+<   d,e6d-<   d.e6d/<   d0e6d1<   d2e6d3<   d4e6d5<   d6e6d7<   d87                     ej8        e d                    e6d9<   d:e6d;<   i Z9d<e9d=<   d>e9d?<   d@e6dA<   dBe6dC<   dDe6dE<    G dF dGej/                  Z: G dH dIej/                  Z; G dJ dKe3ej/                  Z< G dL dMe3ej/                  Z= G dN dOe>          Z?e>j@        e?_@         G dP dQe>          ZAe>j@        eA_@         G dR dSe3ej/                  ZB G dT dUej/                  ZC G dV dWej/                  ZD G dX dYej/                  ZE G dZ d[ej/                  ZF G d\ d]ej/                  ZG G d^ d_ej/                  ZH G d` daej/                  ZI G db dcej/                  ZJ G dd deej/                  ZK G df dgej/                  ZL G dh diej/                  ZMdj ZN G dk dlej/                  ZOdpdmZPeQdnk    r eP             dS dS )q    N)partial)productislice)support)	os_helper)warnings_helper)findfile
gc_collect	swap_attr	swap_item)import_fresh_module)TESTFNz
simple.xmlxmltestdatasubdirutf-8z!filename is not encodable to utf8zsimple-ns.xmlzexpat224_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>
z<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Foo [
<!ELEMENT foo (bar*)>
<!ELEMENT bar (#PCDATA)*>
<!ATTLIST bar xml:lang CDATA "eng">
<!ENTITY qux "quux">
]>
<foo>
<bar>&qux;</bar>
</foo>
F)quietc                       fd}|S )Nc                 B      fd}t          j        |            |S )Nc                  l    t          j        di5   | i | d d d            d S # 1 swxY w Y   d S )Nr   )r   check_warnings)argskwargsfiltersr   tests     */usr/lib/python3.11/test/test_xml_etree.pynewtestz1checkwarnings.<locals>.decorator.<locals>.newtest}   s     /FFF & &d%f%%%& & & & & & & & & & & & & & & & & &s   	)--)	functoolsupdate_wrapper)r   r   r   r   s   ` r   	decoratorz checkwarnings.<locals>.decorator|   sA    	& 	& 	& 	& 	& 	& 	& 	 $///     )r   r   r    s   `` r   checkwarningsr#   {   s*          r!   c                 f    |                      dt          j                                                  S )N   
)replaceoslinesepencode)datas    r   convlinesepr+      s$    <<rz0022333r!   c                       e Zd Zd Zd ZdS )
ModuleTestc                 *    ddl m} ddl m} ddl m} d S )Nr   )ElementTreeElementIncludeElementPath)	xml.etreer/   r1   r3   )selfr/   r1   r3   s       r   test_sanityzModuleTest.test_sanity   s@     	*))))),,,,,,))))))))r!   c                 D    d}t          j        | t          |d           d S )N)xml.etree.ElementTree_elementtree)
HTML_EMPTY)not_exported)r   check__all__ET)r5   namess     r   test_allzModuleTest.test_all   s'    9T2u?KKKKKKr!   N)__name__
__module____qualname__r6   r?   r"   r!   r   r-   r-      s7        * * *L L L L Lr!   r-   Tunicodec                 
   |dk    rt          j                    }nt          j                    }t                              |           } |j        |fd|i| |r|                                S |                    d           |S )NrC   encodingr   )ioBytesIOStringIOr=   r/   writegetvalueseek)elem	to_stringrE   optionsfiletrees         r   	serializerQ      s    9z||{}}>>$DDJt22h2'222 }}		!r!   c                     d | D             S )Nc                     g | ]	}|j         
S r"   tag.0rL   s     r   
<listcomp>z"summarize_list.<locals>.<listcomp>   s    %%%DH%%%r!   r"   )seqs    r   summarize_listrZ      s    %%%%%%r!   c                   0    e Zd Zed             Zd Zd ZdS )ElementTestCasec                 ,    t           t          h| _        d S N)pyETr=   modules)clss    r   
setUpClasszElementTestCase.setUpClass   s    Rjr!   c                     	 t          t          j        ||          5  t          j        ||          }d d d            n# 1 swxY w Y   t          t          j        ||          5  t          j        |          }d d d            n# 1 swxY w Y   n|# t          j        $ rj}t          t          dft          dfg          }	t          j        d|d|	                    ||          d|	                    ||                    |d }~ww xY w|S )NcETr_   zFailed to round-trip z from z to )r   sysr`   pickledumpsloadsPicklingErrordictr=   r_   r   
TestFailedget)
r5   objnamedumperloaderprototempresultpehumans
             r   pickleRoundTripzElementTestCase.pickleRoundTrip   s   	L3;f55 0 0|C//0 0 0 0 0 0 0 0 0 0 0 0 0 0 03;f55 , ,d++, , , , , , , , , , , , , , ,# 	L 	L 	L2u+f~677E$$(+(-		&&(A(A(A(A(-		&&(A(A(A&C D D JLL	L s\   B ?B AB AB %B:B B

B B
B D!A%DDc                     |                      |t          j        t          j        f           |                      |t          j        t          j        f           |                     t          t          |                    t          t          |                               t          ||          D ]\  }}|                     ||           t          j
        dddd          }|                      ||           ||                     d S )NrU   tailtextattrib)assertIsInstancer=   Elementr_   assertEquallenlistzipassertEqualElementsoperator
attrgetter)r5   alicebobxy
propertiess         r   r   z#ElementTestCase.assertEqualElements   s    ebj$,%?@@@cBJ#=>>>T%[[))3tCyy>>:::sOO 	+ 	+DAq$$Q****(II
E**JJsOO<<<<<r!   N)r@   rA   rB   classmethodrb   rv   r   r"   r!   r   r\   r\      sK        ! ! [!  = = = = =r!   r\   c                      e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d  Z"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d' Z)d( Z*d) Z+d* Z,d+ Z-d, Z.d- Z/d.S )/ElementTreeTestc                 L    |                      t          |          |           d S r^   )r}   rQ   )r5   rL   expecteds      r   serialize_checkzElementTreeTest.serialize_check   s$    4(33333r!   c                 F     fdt                               d          } |           t                               |          } |                                           t                               dd          }t                               |          }                     t          |          d           t                               dd          } fd |j                    |j                    |j                    |j	                    |j
                    |j                    |j                    |j                    |j                    |j                    |j                    |j                    |j                    |j                    |j                   fd} ||                    d                      ||                    d	                      ||                    d                      ||                    d	                                          t           j        t           j                                        t           j        t           j                   d S )
Nc                 P                        t                              |           d           t          |           }dD ]E}                     t	          | |          d|z                                 ||d|z             F                    | j        t                                         | j	        t                     | j                             | j        t                     | j                             | j        t                     | D ]} |           d S )Nznot an elementmsg)rU   rz   ry   rx   zno %s memberzno %s visible by dir)
assertTruer=   	iselementdirhasattrassertInr{   rU   strrz   rj   ry   rx   )elementdirelemattrrL   check_elementr5   s       r   r   z5ElementTreeTest.test_interface.<locals>.check_element   s9   OOBLL117GOHHH'llG7 ; ; 6 6*T1   3 3 3dG2T9  ; ; ; ; !!'+s333!!'.$777|'%%glC888|'%%glC888 $ $d####$ $r!   rU      tägvaluekeyz^<Element 't\xe4g' at 0x.*>$c                 X                         t          | d          d| z             d S )N__call__z%s not callabler   )r   r   )methodr5   s    r   check_methodz4ElementTreeTest.test_interface.<locals>.check_method   s<    OOGFJ77)F2  4 4 4 4 4r!   c                 (     | j                    d S r^   )__next__)itr   s    r   
check_iterz2ElementTreeTest.test_interface.<locals>.check_iter  s    L%%%%%r!   *)r=   r|   r/   getrootassertRegexreprappendextendinsertremovefinditerfindfindallfindtextclearrl   setkeysitemsiteritertextr}   XML
fromstringPIProcessingInstruction)r5   r   rP   r   r   r   s   `   @@r   test_interfacezElementTreeTest.test_interface   s   	$ 	$ 	$ 	$ 	$ 	$$ **U##g~~g&&dllnn%%%**X7*33~~g&&g(GHHH**U*00	4 	4 	4 	4 	4 	W^$$$W^$$$W^$$$W^$$$W\"""W%&&&W_%%%W%&&&W]###W[!!!W[!!!W\"""W]###W\"""W%&&&	& 	& 	& 	& 	& 	
7##E**+++
7##C(()))
4==''(((
4==%%&&& 	/// 899999r!   c                 F   t                               d          }|                     |j        d           d|_        |                     |j        d           d|_        |                     |j        d           |                     |j                   d|_        |                     |j        d           d|_        |                     |j        d           |                     |j                   d|_        |                     |j        d           d|_        |                     |j        d           |                     |j        i            dd	d
|_        |                     |j        dd	d
           ddd|_        |                     |j        ddd           d S )NrU   TagTAGTextTEXTTailTAILbd)acBD)AC)r=   r|   r}   rU   assertIsNonery   rx   rz   )r5   r   s     r   test_set_attributez"ElementTreeTest.test_set_attribute  s   **U##e,,,e,,,e,,,','''v...v...','''v...v...,,,"--s)=)=>>>"--s)=)=>>>>>r!   c                    t                               d          }|                     |d           t                               d          }|                    |           |                     |d           |                    |           |                     |d           |                    d|           |                     |d           |                    |           |                    |g           |                     |d           |                    |           |                    t          |g                     |                     |d           |                    |           t                               dd	          }|                     |d
           t                               d          }|                    |           |                     |d           |                    d|           |                     |d           |                    |           |                     |d           |                    |           |                     |d
           | 	                    t                    5 }|                    |           d d d            n# 1 swxY w Y   |                     t          |j                  d           |                     |d
           |||g|dd<   |                     |d         d           |                     |dd         |d         |d         g           |                     |d dd         |d         |d         g           |dd= |                     |d           d S )N<body><tag/></body><body><tag /></body>tag2z<body><tag /><tag2 /></body>r   z<body><tag2 /><tag /></body>rU   r   r   z<tag key="value" />subtagz!<tag key="value"><subtag /></tag>z+<tag key="value"><subtag /><subtag /></tag>zlist.remove(x): x not in list   z
<subtag />	      )r=   r   r   r|   r   r   r   r   r   assertRaises
ValueErrorr}   r   	exception)r5   rL   er   
subelementcms         r   test_simpleopszElementTreeTest.test_simpleops)  s    vv+,,T#9:::JJvAT#ABBBAT#9:::AqT#ABBBAQCT#ABBBAD!IIT#ABBBA**U*00W&;<<<ZZ))
z"""W&IJJJq*%%%W=	? 	? 	?z"""W&IJJJz"""W&;<<<z** 	'bNN:&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'R\**,KLLLW&;<<<"J
;!WQZ6661
GAJ'?@@@!AWQZ(@AAAAaCLW=	? 	? 	? 	? 	?s   J&&J*-J*c                    |                      t                              d          d           |                      t                              d          d           |                      t                              d          d           d S )Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)r   r=   r   r5   s    r   
test_cdatazElementTreeTest.test_cdataU  s     	RVV$677"	$ 	$ 	$RVV$OPP"	$ 	$ 	$RVV$BCC"	$ 	$ 	$ 	$ 	$r!   c                 D   t          j        t                              d                    }t                              |          }|                     |                    d          j        d           |                     |                    d          j        d           t                              t                    }|                     |                    d          j        d           |                     |                    d          j        d           d S )Nr   )rO   rU   section/tagr   zelement/../empty-elementempty-element)
rF   rG   
SAMPLE_XMLr)   r=   r/   r}   r   rU   SIMPLE_XMLFILE)r5   
stringfilerP   s      r   test_file_initzElementTreeTest.test_file_init_  s    Z
 1 1' : :;;
~~:~..5))-u555=115u===~~>~229--19===#=>>B	! 	! 	! 	! 	!r!   c                    ddl m} t                              t                    }t          d          D ]?}t                              |                              dt          |          z              @t          |j
                  }t          d          D ]?}t                              |                              dt          |          z              @|                     t          |j
                  |           t          d          D ]?}t                              |                              dt          |          z              @|                     t          |j
                  |           t          d          D ]?}t                              |                              dt          |          z              @|                     t          |j
                  d           d S )Nr   r2   
   z./   iX  i  )r4   r3   r=   r   r   ranger/   r   r   r~   _cacher}   assertGreater
assertLess)r5   r3   rL   icache_len_10s        r   test_path_cachezElementTreeTest.test_path_cachej  s    	*)))))vvj!!rBBABNN40055d3q66kBBBB;-..rBBABNN40055d3q66kBBBB[/00,???rBBABNN40055d3q66kBBBB3{122LAAAsCCAR^^D1166tCFF{CCCCK.//55555r!   c                 :   dd l }t                              d          } |j         |          } |j        |          }d|                    d          _        |                     |d           |                     |d           |                     |d           d S )Nr   z<tag>hello<foo/></tag>barfooz<tag>hello<bar /></tag>z<tag>hello<foo /></tag>)copyr=   r   deepcopyr   rU   r   )r5   r   e1e2e3s        r   	test_copyzElementTreeTest.test_copyy  s     	VV,--TYr]]T]2"R!:;;;R!:;;;R!:;;;;;r!   c                 l   t                               d          }|                    d           |                     |                    dd          d           |                    dd           |                     |                    d          d           t                               dd          }|                     |                    d          d           |                     |j        ddi           ddi}t                               d|          }|                                 |                     |                    d          d           |                     |j        ddi           ddi}t          j        di |}|                                 |                     |                    d          d           |                     |j        ddi           t                               dddid          }|                     |                    d          d           |                     |j        ddi           t                               d          }d|_        |                    d	d
           |                    dd           |                     t                               |          d           |                     t          |
                                          d	dg           |                     t          |                                          ddg           |                     |j        d         d           d|j        d<   d|j        d<   |                     t                               |          d           t                               d          }|                    dd           |                    dd           |                    dd           |                    dd           |                     t                               |          d           d S )NrU   r   defaultr   r   otherr   aatestatestvaltestbtest2s-   <test testa="testval" testb="test2">aa</test>)r  r  )r  r  test1testcs;   <test testa="testval" testb="test1" testc="test2">aa</test>r   r   
r   z	
 r   z

		  s[   <test a="&#13;" b="&#13;&#10;" c="&#09;&#10;&#13; " d="&#10;&#10;&#13;&#13;&#09;&#09;  " />rT   )r=   r|   rl   r}   r   rz   r   ry   tostringsortedr   r   )r5   rL   rz   s      r   test_attribzElementTreeTest.test_attrib  s    zz%  %33Y???   %'222zz%Wz--%'222ug&6777!zz%((%'222ug&6777!z**6**%'222ug&6777zz%%!1wz??%'222ug&6777zz&!!	)$$$'"""T**@	B 	B 	B		,,w.@AAA

--%'9:	< 	< 	<W-w777&G&GT**N	P 	P 	P zz&!!dfi   &'''T**n	p 	p 	p 	p 	pr!   c                    t                               d          }ddi}|                    d|          }|                     |j        |d           |                    |           |                     |d           |                                 |                     |d           |                    |           |                     |d           |                    ||g           |                     |d	           |g|d d <   |                     |d           t          |g          |d d <   |                     |d           d S )
NrU   r   r   r   zattrib aliasingr   z!<tag><subtag key="value" /></tag><tag />zM<tag><subtag key="value" /><subtag key="value" /><subtag key="value" /></tag>)
r=   r|   makeelementassertIsNotrz   r   r   r   r   tuple)r5   rL   rz   subelems       r   test_makeelementz ElementTreeTest.test_makeelement  sX    zz%  !""8V445FGGGGT#FGGG

T9---GT#FGGGWg&'''T[	] 	] 	])QQQT#FGGG	""QQQT#FGGGGGr!   c                    t                               t                    }t          j                    }|                    |d           |                     |                                d           t                               t                    }t          j                    }|                    |d           |                     |                                d           t          t                    5 }|
                                }d d d            n# 1 swxY w Y   t                                           }|                     |j        d           |                    |           |                     |                                d           t                                           }t                               |          }|                    |           |                     |                                d           d S )NrC   rE   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   rF   rH   rI   r}   rJ   SIMPLE_NS_XMLFILEopenread	XMLParserr   versionfeedr   closeTreeBuilder)r5   rP   streamfr*   parserr  s          r   test_parsefilezElementTreeTest.test_parsefile  s    xx''

6I
...**	 	 	 xx)**

6I
...**	 	 	 .!! 	Q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 444DV\\^^	 	 	 !!V,,DV\\^^	 	 	 	 	s   7DDDc                    t                               d          }|                     t                               |d          d           t                               d          }|                     t                               |d          d           g d}t                               |          }|                     t                               |          d           |                     d                    t                               |                    d           |                     t                               |d          d           t                               d          \  }}|                     t          |          d	           t                               d
          \  }}|                     t          |          d           |                     |d         j
        d           d S )N<html><body>text</body></html>rC   r  )z<html><body>ztext</boz
dy></html>   <html><body>text</body></html>r!   asciisE   <?xml version='1.0' encoding='ascii'?>
<html><body>text</body></html>r   z(<html><body id='body'>text</body></html>r   body)r=   r   r}   r	  r   fromstringlistjointostringlistXMLIDr~   rU   )r5   r   sequence_idss        r   test_parseliteralz!ElementTreeTest.test_parseliteral  s   &&9::WyAA0	2 	2 	2-- @AAWyAA0	2 	2 	2===##H--W--1	3 	3 	3"//'":":;;1	3 	3 	3Wg662	3 	3 	3 :;;3S1%%%DEE3S1%%%V&11111r!   c                    t           j        } |t                    }t          |          \  }}|                     ||j        fd           |                     d |D             g d           |                     |j        j        d            |t                    }|                     d |D             g d           d} |t          |          }|                     d |D             g            d} |t          |	          }|                     d
 |D             g            d} |t          |          }|                     d |D             g d           d} |t          |          }|                     d |D             g d           d} |t          j	        d          |          }d |D             }|                     |ddg           d}t          t          d          5 }|                     t                    5 } |||           d d d            n# 1 swxY w Y   |                     |j                   d d d            n# 1 swxY w Y   |                     t          |j                  d           t#          j        |           5  |                     t                    5 } |t          |           d d d            n# 1 swxY w Y   |                     t          |j                  d           ~d d d            n# 1 swxY w Y   t          j        d          }	d} ||	|          }|                     d |D             ddg           t          j	        d          }	 ||	          }
t          |
          \  }}|                     ||j        fd           |                     t           j                  5 }t          |
           d d d            n# 1 swxY w Y   |                     t          |j                  d            |                     t,          j        t0                     t          t0          d!          5 }|                    d"           d d d            n# 1 swxY w Y    |t0                    }
t          |
          \  }}|                     ||j        fd           t#          j        |           5  |                     t           j                  5 }t          |
           d d d            n# 1 swxY w Y   |                     t          |j                  d            ~~
d d d            n# 1 swxY w Y   t#          j        |           5   |t0                    }
~
d d d            n# 1 swxY w Y   |                     t4                    5   |d#           d d d            d S # 1 swxY w Y   d S )$Nendr   c                 &    g | ]\  }}||j         fS r"   rT   rW   actionrL   s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>  #    III648,IIIr!   )r2  r3  r   r3  rootr:  c                 &    g | ]\  }}||j         fS r"   rT   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>$  r7  r!   )r3  {namespace}elementr<  r3  {namespace}empty-elementr3  {namespace}rootr"   c                 &    g | ]\  }}||j         fS r"   rT   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>-  r7  r!   eventsc                 &    g | ]\  }}||j         fS r"   rT   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>1  r7  r!   startr3  c                 &    g | ]\  }}||j         fS r"   rT   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>5  r7  r!   rG  r:  rG  r   r2  rK  r2  )rG  r   r8  r9  )rG  r3  start-nsend-nsc                 6    g | ]\  }}|d v r	||j         fn||fS )rF  rT   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>B  sH     7 7 7*fd 17:J0J0J648,,394.7 7 7r!   )
rL  ) 	namespacerG  rA  rG  r=  r<  rS  r<  rG  r?  r>  r@  rM  NrL  rM  z<root xmlns=''/>c                     g | ]\  }}|S r"   r"   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>S  s    222,&$v222r!   rL  rM  rG  r3  bogusrbzunknown 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>
)rL  c                     g | ]	\  }}||f
S r"   r"   r5  s      r   rX   z2ElementTreeTest.test_iterparse.<locals>.<listcomp>i  s     EEE\VT64.EEEr!   )rL  )rP  u   http://éffbot.org/ns)rL  )u   cléhttp://effbot.org/nsz<document />junk)r3  documentz.junk after document element: line 1, column 12wbs   <document />junknonexistent)r=   	iterparser   nextr}   rU   r:  r  rF   rH   r  r   r   assertFalseclosedr   r   r   check_no_resource_warningrG   
ParseError
addCleanupr   unlinkr   rI   FileNotFoundError)r5   r`  contextr6  rL   rD  resr!  r   sourcer   s              r   test_iterparsezElementTreeTest.test_iterparse  s    L	)N++G}}&$(+-?@@@IIIII L L L 	 	 	
 	)6222)-..IIIII L L L 	 	 	 )NF33IIIII2NNN)N6:::IIIII2NNN!)NF33IIIII 	L 	L 	L 		 		 		 8)-v66 7 7.57 7 79 9 9	 	 	 ()BK(;<<fEE22'222z84555*.$'' 	'1"":.. %"	!V$$$% % % % % % % % % % % % % % %QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	R\**,CDDD6t<< 	 	"":.. 2"	.&1112 2 2 2 2 2 2 2 2 2 2 2 2 2 2S..0GHHH		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 GH H )FF++EEWEEE=@H 	 	 	
 /00YvBxx&$(+-@AAAr}-- 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	R\**@	B 	B 	B 		(&111&$ 	)1GG'(((	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)YvBxx&$(+-@AAA6t<< 	 	""2=11 RR              S..DF F FB	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 6t<< 	 	6""B	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 011 	% 	%Im$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s   ,IH I H$	$I'H$	(IIIL3KLK	LK	,LLLO))O-0O-Q88Q<?Q< U6TUT	UT	-UUU2VVV5WWWc                 
   t                               d          }d|_        |                     |d           dt                               |d          _        |                     |d           d |_        |                     |d           |                    dt                               d	                     |                     |d
           t                               dd          |d<   |                     |d           d S )NrU   ry   z<tag>text</tag>subtextr   z'<tag>text<subtag>subtext</subtag></tag>ztext<subtag>subtext</subtag>r   commentz*text<!--comment--><subtag>subtext</subtag>r   r   z)text<?key value?><subtag>subtext</subtag>)	r=   r|   ry   r   
SubElementrU   r   Commentr   r5   rL   s     r   test_writefilezElementTreeTest.test_writefile  s    zz%  	T#4555-6dH%%*T#LMMM T#ABBBArzz),,---T<	> 	> 	> %%w''QT#NOOOOOr!   c                    t          t                    5 }|                                }d d d            n# 1 swxY w Y    G d dt                    } |            }t                              |          }|                    |           |                     |g d           t          t                    5 }|                                }d d d            n# 1 swxY w Y    G d dt                    } |            }t                              |          }|                    |           |                     |g d           d S )Nc                        e Zd Zd Zd Zd ZdS )4ElementTreeTest.test_custom_builder.<locals>.Builderc                 4    |                      d|f           d S NrG  r   r5   rU   rz   s      r   rG  z:ElementTreeTest.test_custom_builder.<locals>.Builder.start      WcN+++++r!   c                 4    |                      d|f           d S Nr3  ry  r5   rU   s     r   r3  z8ElementTreeTest.test_custom_builder.<locals>.Builder.end      UCL)))))r!   c                     d S r^   r"   r5   ry   s     r   r*   z9ElementTreeTest.test_custom_builder.<locals>.Builder.data      r!   N)r@   rA   rB   rG  r3  r*   r"   r!   r   Builderrv    sA        , , ,* * *    r!   r  r  rI  c                   8    e Zd Zd Zd Zd Zd Zd Zd Zd Z	dS )	rv  c                 4    |                      d|f           d S rx  ry  rz  s      r   rG  z:ElementTreeTest.test_custom_builder.<locals>.Builder.start  r{  r!   c                 4    |                      d|f           d S r}  ry  r~  s     r   r3  z8ElementTreeTest.test_custom_builder.<locals>.Builder.end  r  r!   c                     d S r^   r"   r  s     r   r*   z9ElementTreeTest.test_custom_builder.<locals>.Builder.data  r  r!   c                 6    |                      d||f           d S )Npiry  )r5   r  r*   s      r   r  z7ElementTreeTest.test_custom_builder.<locals>.Builder.pi  s!    T64011111r!   c                 4    |                      d|f           d S )Nro  ry  )r5   r*   s     r   ro  z<ElementTreeTest.test_custom_builder.<locals>.Builder.comment  s    Y-.....r!   c                 6    |                      d||f           d S )NrL  ry  )r5   prefixuris      r   start_nsz=ElementTreeTest.test_custom_builder.<locals>.Builder.start_ns  s!    Z566666r!   c                 4    |                      d|f           d S NrM  ry  r5   r  s     r   end_nsz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_ns      Xv./////r!   N)
r@   rA   rB   rG  r3  r*   r  ro  r  r  r"   r!   r   r  z4ElementTreeTest.test_custom_builder.<locals>.Builder  s}        , , ,* * *  2 2 2/ / /7 7 70 0 0 0 0r!   ))r  r  r*   )ro  	 comment )rL  rP  rQ  rR  rS  r<  rS  r<  rT  r>  r@  rM  rP  )	r  r   r  r   r=   r  r  r}   r  )r5   r!  r*   r  builderr"  s         r   test_custom_builderz#ElementTreeTest.test_custom_builder  s    .!! 	Q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 		 	 	 	 	d 	 	 	 '))W--D 	# 	# 	# 		 		 		 #$$ 	6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 		0 	0 	0 	0 	0d 	0 	0 	0 '))W--D # # # 	 	 	 	 	s   6:::CC"Cc                      G d dt                     } |            }t                              |          }|                    t	          j        d                     |                     |g d           d S )Nc                       e Zd Zd ZdS )@ElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builderc                 4    |                      d|f           d S r  ry  r  s     r   r  zGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_ns  r  r!   N)r@   rA   rB   r  r"   r!   r   r  r    s#        0 0 0 0 0r!   r  r  a              <?pi data?>
            <!-- comment -->
            <root xmlns='namespace' xmlns:p='pns' xmlns:a='ans'>
               <a:element key='value'>text</a:element>
               <p:element>text</p:element>tail
               <empty-element/>
            </root>
            ))rM  r   )rM  pr  )r   r=   r  r  textwrapdedentr}   )r5   r  r  r"  s       r   test_custom_builder_only_end_nsz/ElementTreeTest.test_custom_builder_only_end_ns  s    	0 	0 	0 	0 	0d 	0 	0 	0 '))W--HO %   	 	 	 	 # # # 	 	 	 	 	r!   c                    t                               d           }|                     |j        t           j                   t                                           }|                     |j        t           j                   d S )Nr  )r=   r  r{   r  r  )r5   r"  parser2s      r   %test_initialize_parser_without_targetz5ElementTreeTest.test_initialize_parser_without_target  s^    T**fmR^<<< ,,..gnbn=====r!   c                    t          t          d          5 }t                              |          }d d d            n# 1 swxY w Y   |                     d |                                                                D             g dg g g g           |                     d |                                D             g dg g g g           t                              t                    }|                     t          t          |                    d           |                     t          t          |d                             d           |                     |d d          t          |                     |d         }|d         }|dd= |                     t          t          |                    d           |                     ||d                    |                     ||d                    ||g|dd<   |                     ||d                    |                     ||d                    |                     ||d                    |                                 |                     t          |          g            d S )	NrZ  c                 ,    g | ]}t          |          S r"   rZ   rV   s     r   rX   z1ElementTreeTest.test_children.<locals>.<listcomp>  s0     = = =" ).. = = =r!   )r   r   r   c                 ,    g | ]}t          |          S r"   r  rV   s     r   rX   z1ElementTreeTest.test_children.<locals>.<listcomp>  s0     3 3 3" ).. 3 3 3r!      r   r   r   )r  r   r=   r  r}   r   r   r   r   r~   r   assertNotEqualr   )r5   r!  rP   rL   child1child2s         r   test_childrenzElementTreeTest.test_children  s    .$'' 	188A;;D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 = =&*llnn&9&9&;&;= = =777	?	 	 	 	 3 3&*iikk3 3 3777	5	 	 	 vvj!!T$ZZ!,,,T$q']]++Q///aaa$t**---aa1IT$ZZ!,,,a)))a)))V$QqS	a)))a)))FDG,,,

dR(((((s   =AAc                 &   t                               d          }|                     t                               |          d           t                               d          }|                     t                               |          d           d S )Nr%  r&  )r=   r   r}   r	  r   rr  s     r   test_writestringz ElementTreeTest.test_writestring  sr    vv677T**,MNNN}}=>>T**,MNNNNNr!   c                    t                               d          }t                               |           |                     t                               |          d           t                               d          }t                               |           |                     t                               |          d           t                               d          }t                               |           |                     t                               |          d           t                               d          }t                               |           |                     t                               |          d           t                               d          }t                               |           |                     t                               |          d	           t                               d
          }t                               |           |                     t                               |          d           d S )Nz<root></root>s   <root />r%  s"   <html>
  <body>text</body>
</html>z!<html> <body>text</body>  </html>z"<html><body>text</body>tail</html>s%   <html>
  <body>text</body>tail</html>z=<html><body><p>par</p>
<p>text</p>	<p><br/></p></body></html>s^   <html>
  <body>
    <p>par</p>
    <p>text</p>
    <p>
      <br />
    </p>
  </body>
</html>8<html><body><p>pre<br/>post</p><p>text</p></body></html>sJ   <html>
  <body>
    <p>pre<br />post</p>
    <p>text</p>
  </body>
</html>r=   r   indentr}   r	  rr  s     r   test_indentzElementTreeTest.test_indent$  s   vvo&&
		$T**K888vv677
		$T**,STTTvv9::
		$T**,STTTvv:;;
		$T**,UVVVvvWXX
		$KK	
 	
 	
 vvPQQ
		$KK	
 	
 	
 	
 	
r!   c                    t                               d          }t                               |d           |                     t                               |          d           t                               d          }t                               |d           |                     t                               |          d           d S )Nr  	)spacesD   <html>
	<body>
		<p>pre<br />post</p>
		<p>text</p>
	</body>
</html>rP  s>   <html>
<body>
<p>pre<br />post</p>
<p>text</p>
</body>
</html>r  rr  s     r   test_indent_spacez!ElementTreeTest.test_indent_spaceP  s    vvPQQ
		$d	###KK	
 	
 	
 vvPQQ
		$b	!!!KK	
 	
 	
 	
 	
r!   c                    t                               d          }t                               |           |                     d |                                D             h d           |                     d |                                D             h d           |                     t          d |                                D                       t          d |                                D                                  d S )Nz@<html><body><p>par</p><p>text</p><p><br/></p><p /></body></html>c                     h | ]	}|j         
S r"   rx   rW   els     r   	<setcomp>z<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>m      +++RW+++r!   >   N

  
    c                     h | ]	}|j         
S r"   ry   r  s     r   r  z<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>q  r  r!   >   N
      parry   r  r  c                     h | ]	}|j         
S r"   r  r  s     r   r  z<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>u  s    ///R///r!   c                 6    h | ]}t          |j                  S r"   )idrx   r  s     r   r  z<ElementTreeTest.test_indent_space_caching.<locals>.<setcomp>v  s     333BG333r!   )r=   r   r  r}   r   r~   rr  s     r   test_indent_space_cachingz)ElementTreeTest.test_indent_space_cachingi  s   vvXYY
		$++tyy{{+++***	
 	
 	
 	++tyy{{+++???	
 	
 	
 	//499;;///0033tyy{{33344	
 	
 	
 	
 	
r!   c                    t                               d          }|                     t                    5  t                               |d           d d d            n# 1 swxY w Y   |                     t                               |          d           t                               |d           |                     t                               |          d           t                               d          }t                               |dd	           |                     t                               |          d
           d S )Nr  )levels9   <html><body><p>pre<br />post</p><p>text</p></body></html>r   s^   <html>
      <body>
        <p>pre<br />post</p>
        <p>text</p>
      </body>
    </html>r    )r  r  sI   <html>
  <body>
   <p>pre<br />post</p>
   <p>text</p>
  </body>
 </html>)r=   r   r   r   r  r}   r	  rr  s     r   test_indent_levelz!ElementTreeTest.test_indent_levely  sc   vvPQQz** 	& 	&IId"I%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&KKH	
 	
 	

 			$a	   KK	
 	
 	
 vvPQQ
		$as	+++KK	
 	
 	
 	
 	
s   AA"%A"c                     t                               d          }|                     t                               |d          d           |                     t                               |dd          d           d S )N0<body xmlns="http://effbot.org/ns"><tag/></body>rC   r  A<ns0:body xmlns:ns0="http://effbot.org/ns"><ns0:tag /></ns0:body>r\  rE   default_namespace1<body xmlns="http://effbot.org/ns"><tag /></body>r=   r   r}   r	  rr  s     r   test_tostring_default_namespacez/ElementTreeTest.test_tostring_default_namespace  s    vvHIIKKyK11O	
 	
 	
 	KKyDZK[[?	
 	
 	
 	
 	
r!   c                     t                               d          }|                     t                               |dd          d           d S )Nr  rC   foobarr  zP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>r  rr  s     r   3test_tostring_default_namespace_different_namespacezCElementTreeTest.test_tostring_default_namespace_different_namespace  sN    vvHIIKKyHKMM^	
 	
 	
 	
 	
r!   c                     t                               d          }d}|                     t          |          5  t                               |dd           d d d            d S # 1 swxY w Y   d S )Nr   z>^cannot use non-qualified names with default_namespace option$rC   r  r  )r=   r   assertRaisesRegexr   r	  )r5   rL   EXPECTED_MSGs      r   5test_tostring_default_namespace_original_no_namespacezEElementTreeTest.test_tostring_default_namespace_original_no_namespace  s    vv+,,W##J== 	N 	NKKyHKMMM	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	N 	Ns   A##A'*A'c                     t                               d          }|                     t                               |d          d           d S )Nr   rC   r  r   r  rr  s     r    test_tostring_no_xml_declarationz0ElementTreeTest.test_tostring_no_xml_declaration  sL    vv+,,KKyK11"	
 	
 	
 	
 	
r!   c                     t                               d          }|                     t                               |dd          d           d S )Nr   utf8TrE   xml_declarations:   <?xml version='1.0' encoding='utf8'?>
<body><tag /></body>r  rr  s     r   test_tostring_xml_declarationz-ElementTreeTest.test_tostring_xml_declaration  sN    vv+,,KKvtKDDJ	
 	
 	
 	
 	
r!   c                     t                               d          }|                     t                               |dd          d           d S )Nr   rC   Tr  ;<?xml version='1.0' encoding='utf-8'?>
<body><tag /></body>r  rr  s     r   .test_tostring_xml_declaration_unicode_encodingz>ElementTreeTest.test_tostring_xml_declaration_unicode_encoding  sN    vv+,,KKy$KGGJ	
 	
 	
 	
 	
r!   c           	         t                               d          }g d}|D ]j\  }}}|                     d| d|           5  |                     t                               |||          |           d d d            n# 1 swxY w Y   kd S )N   <body><tag>ø</tag></body>))   <body><tag>&#248;</tag></body>NN)   <body><tag>ø</tag></body>UTF-8N)r  US-ASCIIN)E   <?xml version='1.0' encoding='ISO-8859-1'?>
<body><tag></tag></body>
ISO-8859-1N)r  rC   N)r  NF)r  r  F)r  r  F)s   <body><tag></tag></body>r  F)r  rC   F)sH   <?xml version='1.0' encoding='us-ascii'?>
<body><tag>&#248;</tag></body>NT)sA   <?xml version='1.0' encoding='UTF-8'?>
<body><tag>ø</tag></body>r  T)sH   <?xml version='1.0' encoding='US-ASCII'?>
<body><tag>&#248;</tag></body>r  T)r  r  T)uA   <?xml version='1.0' encoding='utf-8'?>
<body><tag>ø</tag></body>rC   Tz	encoding=z xml_declaration=r  )r=   r   subTestr}   r	  )r5   rL   	TESTCASESexpected_retvalrE   r  s         r   #test_tostring_xml_declaration_casesz3ElementTreeTest.test_tostring_xml_declaration_cases  s   vv233
 
 
	< ;D 
	 
	6OX C( C C1@C C D D 	 	  KK!)(7    
 $  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	
	 
	s   2B  B	B	c           	      H   t                               d          }|                     d                    t                               |d                    d           |                     d                    t                               |dd                    d           d S )	Nr  rP  rC   r  r  r\  r  r  )r=   r   r}   r*  r+  rr  s     r   #test_tostringlist_default_namespacez3ElementTreeTest.test_tostringlist_default_namespace  s    vvHIIGGBOOD9O==>>O	
 	
 	
 	GGBOOD9PfOgghh?	
 	
 	
 	
 	
r!   c                 J   t                               d          }|                     d                    t                               |d                    d           |                     d                    t                               |d                    d	           t                               |dd
          }|                     d                    |          d           |                     |d         d           |                     g d|dd                     d S )Nr   rP  rC   r  r   r!   T)r  s>   <?xml version='1.0' encoding='us-ascii'?>
<body><tag /></body>r  r  r   z%^<\?xml version='1.0' encoding='.+'?>)z<body>z<tagz />z</body>r   )r=   r   r}   r*  r+  r   )r5   rL   
stringlists      r   !test_tostringlist_xml_declarationz1ElementTreeTest.test_tostringlist_xml_declaration  s   vv+,,GGBOOD9O==>>"	
 	
 	
 	HHR__T4_@@AAN	
 	
 	

 __TIt_TT
GGJJ	
 	
 	
 	A(PQQQAAA:abb>RRRRRr!   c           
      X    d fd	} |dd            |dd            |dd            |dd	            |d
d            |dd           d fd}g d}|D ]Q}                      t                              t                               ||                              d           Rg d}|D ]1}                     t
          t          j         ||                     2g d}|D ]6}                     t          j        t          j         ||                     7                     t
          t          j         d                              d                                          t          t          j         d                              d                     d S )NrP  c                    d| d|d}                     t                              |                    |                     j        |                                t                              |          j        |           d S )Nz<?xml version='1.0' encoding='z'?><xml>z</xml>)r}   r=   r   r)   ry   )rE   r(  xmlr5   s      r   checkz,ElementTreeTest.test_encoding.<locals>.check  ss     HHddd$CRVVCJJx$8$899>EEERVVC[[-t44444r!   r'  r   us-ascii
iso-8859-1   ½ziso-8859-15u   €cp437u   √	mac-romanu   ˚c                     d| z  S )Nz*<?xml version='1.0' encoding='%s'?><xml />r"   r  s    r   r  z*ElementTreeTest.test_encoding.<locals>.xml  s    ?(JJr!   c                 @     |                                |           S r^   )r)   )rE   r  s    r   bxmlz+ElementTreeTest.test_encoding.<locals>.bxml  s    3x==''111r!   )Cr'  r   z	utf-8-sigutf-16utf-16beutf-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-16r   cp720cp737cp775cp850cp852cp855cp856cp857cp858cp860cp861cp862cp863cp865cp866cp869cp874cp1006cp1125cp1250cp1251cp1252cp1253cp1254cp1255cp1256cp1257cp1258zmac-cyrillicz	mac-greekzmac-icelandz
mac-latin2r  zmac-turkishz
iso2022-jpziso2022-jp-1ziso2022-jp-2ziso2022-jp-2004ziso2022-jp-3ziso2022-jp-extzkoi8-rzkoi8-tzkoi8-ukz1048hzptcp154s   <xml />)big5	big5hkscscp932cp949cp950zeuc-jpzeuc-jis-2004zeuc-jisx0213zeuc-krgb2312gbkgb18030z
iso2022-krjohabz	shift-jiszshift-jis-2004zshift-jisx0213zutf-7)
cp037cp424cp500cp864cp875cp1026cp1140utf_32	utf_32_be	utf_32_le	undefinedxxx)rP  )	r}   r=   r	  r   r   r   re  r)   LookupError)r5   r  r  supported_encodingsrE   &unsupported_ascii_compatible_encodings(unsupported_ascii_incompatible_encodingsr  s   `      @r   test_encodingzElementTreeTest.test_encoding  s   	5 	5 	5 	5 	5 	5
 	gsj#lF###mX&&&gx   k8$$$	K 	K 	K	2 	2 	2 	2 	2
 
 
" , 	N 	NHR[[X)?)?@@*MMMM2
 2
 2
. ? 	B 	BHj"&$$x..AAAA4
 4
 4
0 A 	E 	EHbmRVTT(^^DDDD*bfcc+.>.>.E.Eg.N.NOOO+rvss5zz/@/@/I/IJJJJJr!   c                    t                               d          }d|_        |                     t	          |          d           |                     t	          |d           d           |                     t	          |d          d           |                     t	          |d          d           |                     t	          |d          d	           d S )
Nz-<html><link/><script>1 &lt; 2</script></html>r  z/<html><link /><script>1 &lt; 2</script></html>
r   r  htmlz*<html><link><script>1 < 2</script></html>
ry   z1 < 2
)r=   r   rx   r}   rQ   r5   r   s     r   test_methodszElementTreeTest.test_methodsK  s     FFBCC1B	D 	D 	D1T222B	D 	D 	D1U333B	D 	D 	D1V444=	? 	? 	?1V444i@@@@@r!   c                     t                               d          }|                     t          |          d           |                     t          |d          d           d S )Nz(<html><CamelCase>text</CamelCase></html>rC  rB  r=   r   r}   rQ   rD  s     r   test_issue18347zElementTreeTest.test_issue18347Z  sk    FF=>>1:	< 	< 	<1V444:	< 	< 	< 	< 	<r!   c                 h   t                               d          }|                     t          |d          d           |                     |d           |                     t           j                  5 }t                               d           d d d            n# 1 swxY w Y   |                     t          |j                  d           |                     t           j                  5 }t                               t                     d d d            n# 1 swxY w Y   |                     t          |j                  d           t           
                                }d	|j        d
<   |                    t                     |                                }|                     |d           |                     t           j                  5 }t                               t                     d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )Nz*<document title='&#x8230;'>test</document>r  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 10ry   entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r=   r   r}   rQ   r   r   re  r   r   
ENTITY_XMLr  rJ  r  r  EXTERNAL_ENTITY_XML)r5   r   r   r"  r:  s        r   test_entityzElementTreeTest.test_entitya  s   
 FF?@@1z:::=	? 	? 	?Q JKKK r}-- 	4FF2333	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4R\**5	7 	7 	7 r}-- 	FF:	 	 	 	 	 	 	 	 	 	 	 	 	 	 	R\**>	@ 	@ 	@
 "(hJ||~~T#>??? r}-- 	(FF&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(R\**>	@ 	@ 	@ 	@ 	@s6   5BB #B . DD!D G??HHc                    t                               d          }|                     |d           t                               d          }|                     |d           t                               d          }|                     |d           t                               d          }|                     |d           t                               t                    }|                     |d	           d S )
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>)r=   r   r   SAMPLE_XML_NSrr  s     r   test_namespacezElementTreeTest.test_namespace  s   
 vv-..T#:;;; vv[\\TQ	S 	S 	S vvOPPTE	G 	G 	G vv_``TS	U 	U 	U vvm$$T	 	 	 	 	r!   c                 J   t                               d          }|                     |d           t                               t                               d                    }|                     |d           t                               t                               dd                    }|                     |d           t                               t                               dd                    }t                               |t                               dd                    }t                               |t                               dd                    }|                     |d           |                                 d|j        d	<   |                     |d
           |                                 d|j        t                               d	          <   |                     |d
           |                                 d|j        d	<   |                     |d           |                                 t                               d          |j        d	<   |                     |d           |                                 t                               d          }t                               d          |j        d<   |                    |           |                    |           |                     |d           |                     t          t                               dd                    d           |                     t          t                               d                    d           t                               dd          }t                               dd          }|                     ||           t                               dd          }| 
                    ||           | 
                    |d           |                     |d           d S )Nz{uri}tagz<ns0:tag xmlns:ns0="uri" />r  rU   tag1r   z;<ns0:tag xmlns:ns0="uri"><ns0:tag1 /><ns0:tag2 /></ns0:tag>r   z{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-tagzns:tag)r=   r|   r   QNamerp  r   rz   r   r}   r   r  )r5   rL   r  q1q2s        r   
test_qnamezElementTreeTest.test_qname  s|   
 zz*%%T#@AAAzz"((:..//T#@AAAzz"((5%0011T#@AAAzz"((5%0011--bhhuf&=&=>>--bhhuf&=&=>>TI	K 	K 	K
 	

")JT9	; 	; 	; 	

,3BHHZ(()T9	; 	; 	; 	

".JT>	@ 	@ 	@ 	

"$((<"8"8JT=	? 	? 	? 	

**U##&(hh}&=&={#GGT	 	 	 	RXXdE2233Y???RXXi00119===XXdE""XXdE""R   XXdK((B###B)))Y'''''r!   c                 :    t                               d          }d S )Nz<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html>text</html>)r=   r   rr  s     r   test_doctype_publicz#ElementTreeTest.test_doctype_public  s      vv $ % %r!   c                     ddl m d> fd	} |ddg            |dddg            |dd	d
g            |dd	dg            |dg d            |dg d            |dg d            |dg d            |dg d            |dddg            |dg d            |ddg            |dg d            |ddg            |dg d             |d!g d"            |d#g d$            |d%d	d&g            |d'd'g            |d(g d)            |d*g d+            |d,d,g            |d-d-g            |d.d.g            |d/d/g            |d0g d1            |d2g d3d4d5i            |d6d7gd8d5i            |d9d	d7gd4d5i            |d:d	d6gd8d5i            |d;d	d<gd8d5i            |d%d	d&gd5d5d=           d S )?Nr   r2   c                 p                         d                     | |          D             |           d S )Nc                     g | ]	\  }}|p|
S r"   r"   )rW   oprU   s      r   rX   zGElementTreeTest.test_xpath_tokenizer.<locals>.check.<locals>.<listcomp>  s6     Y Y Y")"c !iC Y Y Yr!   )r}   xpath_tokenizer)r  r   
namespacesr3   r5   s      r   r  z3ElementTreeTest.test_xpath_tokenizer.<locals>.check  sY     Y Y-8-H-HJ-W-WY Y Y%' ' ' ' 'r!   r   ztext()ry   ()z@name@rn   z@*zpara[1])para[1]zpara[last()])rb  rc  lastr`  re  z*/para)r   /rb  z/doc/chapter[5]/section[2])rg  docrg  chapterrc  5re  rg  sectionrc  2re  zchapter//para)ri  //rb  z//pararm  rb  z//olist/item)rm  olistrg  item.z.//para)rp  rm  rb  ..z../@lang)rq  rg  ra  langzchapter[title])ri  rc  titlere  z#employee[@secretary and @assistant])
employeerc  ra  	secretaryrP  andrP  ra  	assistantre  z	@{ns}attrz{ns}attr{http://spam}eggz
./spam.egg)rp  rg  zspam.eggz.//{http://spam}egg)rp  rm  rx  z{ns}*{}*{*}tag{*}*z	.//{*}tag)rp  rm  rz  z
./xsd:type)rp  rg  &{http://www.w3.org/2001/XMLSchema}typexsdz http://www.w3.org/2001/XMLSchematyper|  rP  z	@xsd:typez@typez@{*}typez{*}type)rP  rS  r^   )r4   r3   )r5   r  r3   s   ` @r   test_xpath_tokenizerz$ElementTreeTest.test_xpath_tokenizer  s   ))))))	' 	' 	' 	' 	' 	' 	' 	cC5h'''gV}%%%dS#Ji000111n>>>???h***+++*. . .	/ 	/ 	/ 	o888999hv'''n:::;;;cC5i,,,---dTFj222333 > > >???3 6K 6K 6K 	L 	L 	L 	kC,--- #5"6777l222333#%D%D%DEEE 	gy!!!eeWh
###fvhk000111 	lPPP89	; 	; 	;f?@56	8 	8 	8kC!IJ89	; 	; 	;gV}56	8 	8 	8j3	*56	8 	8 	8kC,579 9	: 	: 	: 	: 	:r!   c                 @   |                      t                              t                              dd                    d           |                      t                              t                              dd                    d           |                      t                              t                              dd                    d           |                      t                              t                              dd          d          d           d S )	Nr   instructions   <?test instruction?>z
<testing&>s   <?test <testing&>?>u   <testing&>ãzlatin-1s=   <?xml version='1.0' encoding='latin-1'?>
<?test <testing&>?>)r}   r=   r	  r   r   r   s    r   test_processinginstructionz*ElementTreeTest.test_processinginstruction*  s     	R%=%=fm%T%TUU'	) 	) 	)RUU6=%A%ABB'	) 	) 	)
 	RUU6<%@%@AA&	( 	( 	(RUU63C%D%DiPP+	, 	, 	, 	, 	,r!   c                 \   dD ]}||                                 fD ]}d|z  }t          t                              d|z            d          }|                     ||           t          t                              d|d|d          d          }|                     ||           d S )	N)AREABASEBASEFONTBRCOLEMBEDFRAMEHRIMGINPUTISINDEXLINKMETAPARAMSOURCETRACKWBRz<%s>z<%s />rC  rB  <z></r  )lowerrQ   r=   r   r}   )r5   r   rL   r   
serializeds        r   #test_html_empty_elems_serializationz3ElementTreeTest.test_html_empty_elems_serialization:  s    2 		7 		7G !'--//2 7 7!D=&rvvho'>'>vNNN
  X666&rvvvTTT$$$.G'H'H.46 6 6
  X66667		7 		7r!   c                    t                               ddd          }t          j                    5 }t                               |           d d d            n# 1 swxY w Y   |                     |                                d           d S )N
cirriculumpublicexamplestatuscompanyz1<cirriculum status="public" company="example" />
)r=   r|   r   captured_stdoutdumpr}   rJ   )r5   r   stdouts      r   test_dump_attribute_orderz)ElementTreeTest.test_dump_attribute_orderH  s    JJ|HiJHH$&& 	&GGAJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	**M	O 	O 	O 	O 	Os   AAAc                     t                               ddd          }|                     t          |          d           |                     t          |d          d           d S )	Nr  r  r  r  z0<cirriculum status="public" company="example" />rC  rB  z;<cirriculum status="public" company="example"></cirriculum>)r=   r|   r}   rQ   r5   r:  s     r   test_tree_write_attribute_orderz/ElementTreeTest.test_tree_write_attribute_orderP  sx    zz,xzKK4K	M 	M 	M4777M	O 	O 	O 	O 	Or!   c                     t                               t                    }|                     |d         j        ddi           d S )Nr   z*{http://www.w3.org/XML/1998/namespace}langeng)r=   r   ATTLIST_XMLr}   rz   r  s     r   test_attlist_defaultz$ElementTreeTest.test_attlist_defaultX  sJ    }}[))aFN	P 	P 	P 	P 	Pr!   N)0r@   rA   rB   r   r   r   r   r   r   r   r   r  r  r#  r0  rl  rs  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r@  rE  rH  rM  rP  rW  rY  r  r  r  r  r  r  r"   r!   r   r   r      s       4 4 4A: A: A:F? ? ?6*? *? *?X$ $ $	! 	! 	!6 6 6
< 
< 
<4p 4p 4plH H H,+ + +Z2 2 2,v% v% v%pP P P"; ; ;z  ,> > >#) #) #)JO O O*
 *
 *
X
 
 
2
 
 
 
 
 
@	
 	
 	

 
 
N N N
 
 

 
 

 
 
* * *X	
 	
 	
S S S&9K 9K 9KvA A A< < <#@ #@ #@J  B?( ?( ?(B% % %8: 8: 8:t, , , 7 7 7O O OO O OP P P P Pr!   r   c                   p    e Zd ZddZddZddZddZd Zd Zd Z	d	 Z
d
 Zd Zd Zd Zd Zd Zd ZdS )XMLPullParserTestNc                     ||                     |           d S t          dt          |          |          D ]"}|                     ||||z                       #d S Nr   )r  r   r~   )r5   r"  r*   
chunk_sizer   s        r   _feedzXMLPullParserTest._feeda  sm    KK1c$ii44 2 2D1Z<011112 2r!   c                     |                      d t          |                                |          D             |           d S )Nc                 4    g | ]\  }}||j         |j        ffS r"   )rU   ry   )rW   eventrL   s      r   rX   z3XMLPullParserTest.assert_events.<locals>.<listcomp>j  s@     J J J dh	*+ J J Jr!   )r}   r   read_eventsr5   r"  r   
max_eventss       r   assert_eventszXMLPullParserTest.assert_eventsh  s^    J J &v'9'9';';Z H HJ J J	 	 	 	 	r!   c                     |                      t          t          |                                |                    |           d S r^   )r}   r   r   r  r  s       r   assert_event_tuplesz%XMLPullParserTest.assert_event_tuplesn  sH    **,,j99::	 	 	 	 	r!   c                     t          |                                |          }|                     d |D             |           d S )Nc                 &    g | ]\  }}||j         fS r"   rT   r5  s      r   rX   z7XMLPullParserTest.assert_event_tags.<locals>.<listcomp>u  s#    HHH648,HHHr!   )r   r  r}   )r5   r"  r   r  rD  s        r   assert_event_tagsz#XMLPullParserTest.assert_event_tagss  sS    **,,j99HHHHH!	# 	# 	# 	# 	#r!   c                    dD ]}|                      |          5  t                                          }|                     |g            |                     |d|           |                     |g            |                     |d|           |                     |g            |                     |d|           |                     |dg           |                     |d|           |                     |d|           |                     |dd	g           |                     |d
|           |                     |dg           |                     |                                           d d d            n# 1 swxY w Y   d S )N)Nr      )r  <!-- comment -->
z+<root>
  <element key='value'>text</element>
r2  <element>text</element>tail
<empty-element/>
r8  </root>
r9  )r  r=   XMLPullParserr  r  r   r  )r5   r  r"  s      r   test_simple_xmlz!XMLPullParserTest.test_simple_xmlx  s   & 	2 	2J44 2 2))++&&vr222

6#7DDD&&vr222

6I%' ' ' &&vr222

65*555&&v0B/CDDD

6#BJOOO

6#7DDD&&v&,0    

6;
;;;&&v/@AAA!!&,,..111'2 2 2 2 2 2 2 2 2 2 2 2 2 2 2	2 	2s   EE;;E?	E?	c                    t                                           }|                                }|                     |d           t	          |          \  }}|                     ||j        fd           |                     |d           t	          |          \  }}|                     ||j        fd           |                     t                    5  t	          |           d d d            d S # 1 swxY w Y   d S )Nz-<root>
  <element key='value'>text</element>
r2  r  r9  )	r=   r  r  r  ra  r}   rU   r   StopIteration)r5   r"  r   r6  rL   s        r   test_feed_while_iteratingz+XMLPullParserTest.test_feed_while_iterating  s)   !!##!!

6LMMMBxx&$(+-?@@@

6;'''Bxx&$(+_===}-- 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   C//C36C3c                    t                                           }|                     |g            |                     |d           |                     |g            |                     |d           |                     |g            |                     |d           |                     |g            |                     |d           |                     |dg           |                     |d           |                     |d           |                     |ddg           |                     |d	           |                     |d
g           |                     |                                           d S )Nr  <root xmlns='namespace'>
"<element key='value'>text</elementr  r<  r  r  r>  r  r@  )r=   r  r  r  r   r  r5   r"  s     r   test_simple_xml_with_nsz)XMLPullParserTest.test_simple_xml_with_ns  sy   !!##vr***

6/000vr***

67888vr***

6?@@@vr***

65!!!v(E'FGGG

6:;;;

6/000v)/( 	 	 	 	

6;'''v(B'CDDD&,,..)))))r!   c                    t                               d          }|                     |d           |                     |d           |                     t	          |                                          dg           |                     |d           |                     |d           |                     |d           |                     |d	           |                     |d
           |                     t	          |                                          dg           |                     |                                           d S )NrV  rC  r  r  rO  r  r  r  r  r  rU  )r=   r  r  r}   r   r  r   r  r  s     r   test_ns_eventsz XMLPullParserTest.test_ns_events  s1   !!)?!@@

6/000

67888##%%&&,-	/ 	/ 	/ 	

6?@@@

65!!!

6:;;;

6/000

6;'''f0022336F5GHHH&,,..)))))r!   c                    t                               d          }|                     |d           |                     |ddgd           |                     |dgd	           |                     |d
           |                     |ddg           |                     |d           |                                 |                     |dg           d S )N)rL  rG  r3  rC   <tag xmlns='abc' xmlns:p='xyz'>
rL  )rP  abcrL  )r  xyzr   r  rG  {abc}tagr   
<child />
rG  
{abc}childr3  r  </tag>
r3  r  r=   r  r  r  r  r  r  s     r   test_ns_events_startz&XMLPullParserTest.test_ns_events_start  s   !!)E!FF

6>???  %&*
  	! 	 	 	 	v!(
 	 	 	 	 	

6=)))v#!(
 	 	 	
 	

6:&&&v(
 	 	 	 	 	r!   c                    t                               d          }|                     |d           |                     |ddgd           |                     |dgd	           |                     |d
           |                     |ddg           |                     |d           |                                 |                     |dgd	           |                     |ddg           d S )N)rL  rG  r3  rM  rC  r  r  r  r   r  r  r   r  r  r  r  r  rU  r  r  s     r   test_ns_events_start_endz*XMLPullParserTest.test_ns_events_start_end  sB   !!)O!PP

6>???  %&*
  	! 	 	 	 	v!(
 	 	 	 	 	

6=)))v#!(
 	 	 	
 	

6:&&&v(
 	 	 	 	 	  *
 	 	 	 	 	r!   c                    t                               d          }|                     |d           |                     |g            t                               d          }|                     |d           |                     |g            t                               d          }|                     |d           |                     |dg           |                     |d           |                     |d	g           |                     |d
           |                     |dg           |                     |d           |                     |g d           |                     |d           |                     |                                           |                     |dg           t                               d          }|                     |d           |                     |g            |                     |d           |                     |dg           |                     |d           |                     |d	g           |                     |d
           |                     |g            |                     |d           |                     |ddg           |                     |d           |                     |                                           d S )Nr"   rC  z<root/>
rF  <!-- text here -->
z<root>
rJ  r  rK  r  r2  z8<element xmlns='foo'>text<empty-element/></element>tail
)rG  {foo}elementrG  {foo}empty-element)r3  r  )r3  r  z</root>r9  )rG  r  r  r  )r=   r  r  r  r  r   r  r  s     r   test_eventszXMLPullParserTest.test_events  s   !!!,,

6;'''vr***!!)9!::

6122262&&&!!)9!::

6:&&&v(9':;;;

6?@@@v(<'=>>>

65!!!v(:';<<<

6N	P 	P 	Pv ( ( ( 	 	 	 	

69%%%&,,..)))v'8999!!!44

6/000vr***

6:&&&v(9':;;;

6?@@@v(<'=>>>

65!!!vr***

6N	P 	P 	Pv%+( 	 	 	 	

69%%%&,,..)))))r!   c                 t   t                               d          }|                     |d           |                     |dt           j        dffg           |                     |d           |                     |dt           j        dffg           |                     |d           |                     |d	g           |                     |d
           |                     |dt           j        dffg           |                     |d           |                     |dg           |                     |d           |                     |dt           j        dffg           t                               d          }|                     |d           |                     |dt           j        dffg           d S )N)rG  ro  r3  rC  r  ro  z text here z<!-- more text here -->
z more text here z<root-tag>text)rG  root-tagz<!-- inner comment-->
z inner commentz</root-tag>
)r3  r  z<!-- outer comment -->
z outer comment )ro  )r=   r  r  r  rq  r  r  s     r   test_events_commentz%XMLPullParserTest.test_events_comment  s   !!)D!EE

612226Y]0K$L#MNNN

667776Y=O0P$Q#RSSS

6+,,,v(='>???

645556Y=M0N$O#PQQQ

6?+++v(;'<===

656666Y=N0O$P#QRRR!!!66

612226Y]0K$L#MNNNNNr!   c                 ^   t                               d          }|                     |d           |                     |dt           j        dffg           t                               d          }|                     |d           |                     |dt           j        dffg           d S )	N)rG  r  r3  rC  z<?pitarget?>
r  pitarget)r  z<?pitarget some text ?>
zpitarget some text )r=   r  r  r  r   r  s     r   test_events_piz XMLPullParserTest.test_events_pi2  s    !!)?!@@

6+,,,6TBE:+>$?#@AAA!!!11

667776TBE3H+I$J#KLLLLLr!   c                 \   ddh}t                               |          }|                     |d           |                     |ddg            G d d          }t                                |                      }|                     |d           |                     |ddg           d S )	Nr3  rG  rC  z<foo>bar</foo>)rG  r   )r3  r   c                        e Zd Zd Zd Zd ZdS )9XMLPullParserTest.test_events_sequence.<locals>.DummyIterc                 2    t          g d          | _        d S )N)rG  r3  rL  )r   rD  r   s    r   __init__zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__B  s    "#?#?#?@@r!   c                     | S r^   r"   r   s    r   __iter__zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__D  s    r!   c                 *    t          | j                  S r^   )ra  rD  r   s    r   r   zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__F  s    DK(((r!   N)r@   rA   rB   r  r  r   r"   r!   r   	DummyIterr  A  sD        A A A  ) ) ) ) )r!   r  )r=   r  r  r  )r5   eventsetr"  r  s       r   test_events_sequencez&XMLPullParserTest.test_events_sequence:  s    7#!!!22

6+,,,v(8.'IJJJ	) 	) 	) 	) 	) 	) 	) 	) !!!55

6+,,,v(8.'IJJJJJr!   c                     |                      t                    5  t                              d           d d d            d S # 1 swxY w Y   d S )NrX  rC  )r   r   r=   r  r   s    r   test_unknown_eventz$XMLPullParserTest.test_unknown_eventM  s    z** 	? 	?$=>>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   AAAr^   )r@   rA   rB   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r"   r!   r   r  r  _  s       2 2 2 2      
# # # #
2 2 2.
 
 
* * *** * *  .  6,* ,* ,*\O O O&M M MK K K&? ? ? ? ?r!   r  z<?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>
C1.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>
zdisclaimer.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>
C2.xml324387z	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>
C2b.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>
C3.xmlzQ<?xml version='1.0'?>
<data>
  <item><![CDATA[Brooks & Shields]]></item>
</data>
zdata.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>
C5.xmlz<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>Example.</p>
  <xi:include href="{}"/>
</document>
default.xmla  <?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
  <xi:include href="C1.xml"/>
</document>
include_c1_repeated.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>
B1.xmlzn<?xml version='1.0'?>
<div xmlns:xi="http://www.w3.org/2001/XInclude">
    <xi:fallback></xi:fallback>
</div>
B2.xmlz<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive2.xml:</p>
  <xi:include href="Recursive2.xml"/>
</document>
Recursive1.xmlz<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive3.xml:</p>
  <xi:include href="Recursive3.xml"/>
</document>
zRecursive2.xmlz<?xml version='1.0'?>
<document xmlns:xi="http://www.w3.org/2001/XInclude">
  <p>The following is the source code of Recursive1.xml:</p>
  <xi:include href="Recursive1.xml"/>
</document>
zRecursive3.xmlc                   <    e Zd Zd
dZddZd Zd Zd Zd Zd	 Z	dS )XIncludeTestr  Nc                     	 t           |         }n# t          $ r t          d          w xY w|dk    rt                              |          }|S )Nresource not foundr  )XINCLUDEKeyErrorOSErrorr=   r   )r5   hrefr  rE   r*   s        r   xinclude_loaderzXIncludeTest.xinclude_loader  sY    	0D>DD 	0 	0 	0.///	0E>>66$<<Ds    *c                     d S r^   r"   )r5   r  r"  rE   s       r   none_loaderzXIncludeTest.none_loader  s    tr!   c                     |dk    rVt          |d          5 }t                              |                                          cd d d            S # 1 swxY w Y   d S d S )Nr  rZ  )r  r=   r  r   )r5   r  r  r!  s       r   
_my_loaderzXIncludeTest._my_loader  s     E>>dD!! -Qxx{{**,,- - - - - - - - - - - - - - - - - - 4s   ,AAAc                     ddl m} |                     d          }|                    || j                   |                     t          |          d           d S )Nr   r0   r  z<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)r4   r1   r  includer  r}   rQ   )r5   r1   rh  s      r   test_xinclude_defaultz"XIncludeTest.test_xinclude_default  sn    ,,,,,,""=11sDO4443	 	 	 	 	r!   c                    ddl m} |                     d          }|                    || j                   |                     t          |          d           |                     d          }|                    || j                   |                     t          |          d           |                     d          }|                    || j                   |                     t          |          d           |                     d	          }|                    || j                   |                     t          |          d
           |                     d          }|                     t                    5 }|                    || j                   d d d            n# 1 swxY w Y   |                     t          |j	                  d           |                     t          |          d           d S )Nr   r0   r  a  <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>r  zO<document>
  <p>This document has been accessed
  324387 times.</p>
</document>r   zX<document>
  <p>This document has been <em>accessed</em>
  324387 times.</p>
</document>r  z<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>r  r  aI  <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>)
r4   r1   r  r  r}   rQ   r   r  r   r   r5   r1   r]  r   s       r   test_xincludezXIncludeTest.test_xinclude  s^   ,,,,,, ''11x)=>>>8,,	 	 	 ''11x)=>>>8,,	 	 	 ''	22x)=>>>8,,	 	 	 ''11x)=>>>8,,	 	 	 ''11w'' 	C2""8T-ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	CR\**,@AAA8,,		 		 		 		 		s   F**F.1F.c                     ddl m} |                     d          }|                    || j                   |                     dt          |                    d                               d S )Nr   r0   r  r   z.//p)r4   r1   r  r  r}   r~   r   )r5   r1   r]  s      r   test_xinclude_repeatedz#XIncludeTest.test_xinclude_repeated;  ss    ,,,,,,''(ABBx)=>>>H$4$4V$<$< = =>>>>>r!   c                 v   ddl m} t                              t          d                   }|                     |j                  5 }|                    || j                   d d d            n# 1 swxY w Y   | 	                    t          |j                  d           t                              t          d                   }|                     |j                  5 }|                    || j                   d d d            n# 1 swxY w Y   | 	                    t          |j                  d           t                              t          d                   }|                     |j                  5 }|                    || j                   d d d            n# 1 swxY w Y   | 	                    t          |j                  d	           t                              t          d
                   }|                     |j                  5 }|                    || j                   d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j                   d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j        d            d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j        d           d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j        d           d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j        d           d d d            n# 1 swxY w Y   | 	                    t          |j                  d           |                     d          }|                     |j                  5 }|                    || j        d           d d d            n# 1 swxY w Y   | 	                    t          |j                  d           d S )Nr   r0   r  )rp   z%cannot load 'disclaimer.xml' as 'xml'r  z!cannot load 'count.txt' as 'text'r  z1unknown parse type in xi:include tag ('BAD_TYPE')r  zYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')r  z#recursive include of Recursive2.xml)	max_depthzAmaximum xinclude depth reached when including file Recursive2.xmlr   zAmaximum xinclude depth reached when including file Recursive3.xmlr   zAmaximum xinclude depth reached when including file Recursive1.xmlr  )r4   r1   r=   r   r  r   FatalIncludeErrorr  r  r}   r   r   XINCLUDE_BADr  LimitedRecursiveIncludeErrorr  s       r   test_xinclude_failuresz#XIncludeTest.test_xinclude_failuresB  ss   ,,,,,, 66(8,--~?@@ 	FB""8D4D"EEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	FR\**7	9 	9 	9 66(8,--~?@@ 	FB""8D4D"EEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	FR\**3	5 	5 	5 66,x011~?@@ 	FB""8D4D"EEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	FR\**C	E 	E 	E 66,x011~?@@ 	FB""8D4D"EEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	FR\**@	A 	A 	A
 ''(899~?@@ 	CB""8T-ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	CR\**5	7 	7 	7 ''(899~?@@ 	SB""8T-AT"RRR	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	S 	SR\**5	7 	7 	7 ''(899~JKK 	Pr""8T-AQ"OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	PR\**S	U 	U 	U ''(899~JKK 	Pr""8T-AQ"OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	PR\**S	U 	U 	U ''(899~JKK 	Pr""8T-AQ"OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	PR\**S	U 	U 	U ''(899~?@@ 	PB""8T-AQ"OOO	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	P 	PR\**5	7 	7 	7 	7 	7s   A//A36A3!D

DD<F%%F),F)I  II"K

KK,MMM8O""O&)O&Q..Q25Q2S::S>S>VV
V
)r  Nr^   )
r@   rA   rB   r  r  r  r  r  r  r"  r"   r!   r   r	  r	    s                  > > >@? ? ?D7 D7 D7 D7 D7r!   r	  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Z ej         ej                    d
          d             Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"dS )BugsTestc                      fd}t                               d          } ||           t                               d          }d|_         ||           t                               d          }d|_         ||           t                               d          }|                    dd            ||           t                               d          }|                    dd            ||           d S )Nc                                          t                    5 }t          |            d d d            n# 1 swxY w Y                       t	          |j                  d           d S )Nzcannot serialize 123 (type int))r   	TypeErrorrQ   r}   r   r   )rL   r   r5   s     r   r  z-BugsTest.test_bug_xmltoolkit21.<locals>.check  s    ""9--  $                             S..57 7 7 7 7s   8<<{   rL   123)r=   r|   ry   rx   r   )r5   r  rL   s   `  r   test_bug_xmltoolkit21zBugsTest.test_bug_xmltoolkit21  s    	7 	7 	7 	7 	7 zz#dzz&!!	dzz&!!	dzz&!!edzz&!!dr!   c                    t                               t                    }t                               |          }|                     |                    d          d           |                     |                    d          d           d S )NrU   ry   r   rn  )r=   r   r   r/   r}   r   )r5   rL   rP   s      r   test_bug_xmltoolkit25zBugsTest.test_bug_xmltoolkit25  sp     vvj!!~~d##u--v666}55yAAAAAr!   c                    t                               d          }|                     t          |                    d                    g            |                     t          |                    d                    dg           d S )N"<doc><table><tbody/></table></doc>z.//theadz.//tbodytbody)r=   r   r}   rZ   r   r5   rP   s     r   test_bug_xmltoolkit28zBugsTest.test_bug_xmltoolkit28  sr     vv:;;Z(@(@AA2FFFZ(@(@AAG9MMMMMr!   c                    t                               d          }t          j                    5 }t                               |           |                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr.  z$<doc><table><tbody /></table></doc>
)r=   r   r   r  r  r}   rJ   )r5   rP   r  s      r   test_bug_xmltoolkitX1zBugsTest.test_bug_xmltoolkitX1  s     vv:;;$&& 	Y&GGDMMMV__..0WXXX	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Ys   AA>>BBc                 F   t                               d          }|                     t                               |d          d           t                               d          }|                     |j        ddi           |                     t                               |d          d           t                               d          }|                     t                               |d          d	           t                               d
          }|                     t                               |d          d           t                               d          }|                    dd           |                     t                               |d          d           d S )Ns2   <?xml version='1.0' encoding='iso-8859-1'?><tg />r   s   <täg />sD   <?xml version='1.0' encoding='iso-8859-1'?><tag ttr='v&#228;lue' />u   ättru   välues   <tag ättr="välue" />s:   <?xml version='1.0' encoding='iso-8859-1'?><tg>text</tg>s   <täg>text</täg>r   rU   )r=   r   r}   r	  rz   r|   r   r0  s     r   test_bug_xmltoolkit39zBugsTest.test_bug_xmltoolkit39  sr    vvNOOT7335FGGGvv 6 7 7y*&=>>>T7335	7 	7 	7 vv / 0 0T7330	2 	2 	2 zz*%%T7335FGGGzz%  l+++T7335	7 	7 	7 	7 	7r!   c                     t                               d          }|                     t          |d          d           |                     t          |          d           d S )Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>r  r  s   <doc>&#33328;</doc>u   <doc>舰</doc>rG  rD  s     r   test_bug_xmltoolkit54zBugsTest.test_bug_xmltoolkit54  si     FF ( ) )1z:::&	( 	( 	(1':;;;;;r!   c                     |                      t          j                  5 }t                              d           d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )Ns?   <!DOCTYPE doc SYSTEM 'doc.dtd'><doc>&ldots;&ndots;&rdots;</doc>z+undefined entity &ldots;: line 1, column 36)r   r=   re  r   r}   r   r   )r5   r   s     r   test_bug_xmltoolkit55zBugsTest.test_bug_xmltoolkit55  s     r}-- 	8FF 7 8 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	R\**=	? 	? 	? 	? 	?s   AAAc                 |     G d d          }|                      t          t          j         |                       d S )Nc                       e Zd Zd ZdS )5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilec                     t           r^   )r  r5   r   s     r   r  z:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.read  s    r!   N)r@   rA   rB   r  r"   r!   r   ExceptionFiler<    s#            r!   r?  )r   r  r=   r  )r5   r?  s     r   test_bug_xmltoolkit60zBugsTest.test_bug_xmltoolkit60  sR    	 	 	 	 	 	 	 	 	'28]]__=====r!   c                 $   ddd}t                                           }|j                            |           |                    d           |                                }|                     |                    d          j        d           d S )Nu   ’u   ‘)rsquolsquoaF  <?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.//paragraphu7   A new cultivar of Begonia plant named ‘BCT9801BEG’.)	r=   r  rJ  updater  r  r}   r   ry   )r5   ENTITIESr"  ts       r   test_bug_xmltoolkit62zBugsTest.test_bug_xmltoolkit62  s     &99X&&& % 	& 	& 	& LLNN//4K	M 	M 	M 	M 	Mr!   zSkips under coverage.c                     d } |             t          j        d           }t          d          D ]} |             |                     t          j        d           |           d S )Nc                      t                                           } |                     di            |                     d           |                     d           d S )NrU   ry   )r=   r  rG  r*   r3  )rP   s    r   xmltoolkit63z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63	  sJ    >>##DJJub!!!IIfHHUOOOOOr!   i  )re   getrefcountr   r}   )r5   rJ  countr   s       r   test_bug_xmltoolkit63zBugsTest.test_bug_xmltoolkit63  su    	 	 	 	%%t 	 	ALNNNN..66666r!   c           	         t                               dd          }|                     t                               |          d           |                     t                               t                               |                                        d          d           |                     t                               t                               t                               |                              d           d S )NSomeTagzdef _f():
  return 3
r  s0   <SomeTag text="def _f():&#10;  return 3&#10;" />ry   )r=   r|   r}   r	  r   rl   rD  s     r   test_bug_200708_newlinez BugsTest.test_bug_200708_newline  s     JJy'@JAAQC	E 	E 	EA//33F;;)	+ 	+ 	+RVVBKKNN%;%;<<C	E 	E 	E 	E 	Er!   c                    t                                           }|                    d           |                     |                                j        d            G d d          }t                                |                      }|                    d           |                     |                                j        d           d S )Nz<element>some text</element>r   c                       e Zd Zd ZdS )2BugsTest.test_bug_200708_close.<locals>.EchoTargetc                 6    t                               d          S )Nr   r=   r|   r   s    r   r  z8BugsTest.test_bug_200708_close.<locals>.EchoTarget.close(  s    zz),,,r!   Nr@   rA   rB   r  r"   r!   r   
EchoTargetrS  '  s#        - - - - -r!   rW  r  )r=   r  r  r}   r  rU   )r5   r"  rW  s      r   test_bug_200708_closezBugsTest.test_bug_200708_close   s    2333+Y777	- 	- 	- 	- 	- 	- 	- 	- ZZ\\222333+Y77777r!   c                    t                               d          }t                               |d          }|                     t	          |d          d           t                               d          }t                               |d          }t                               |d          }|                     t	          |d          d           t                               d          }t                               |d          }t                               |d          }|                     t                    5 }t	          |d           d d d            n# 1 swxY w Y   |                     t          |j                  d           d S )	Nz{default}elemr   )r  z%<elem xmlns="default"><elem /></elem>z{not-default}elemzI<elem xmlns="default" xmlns:ns1="not-default"><elem /><ns1:elem /></elem>rL   z<cannot use non-qualified names with default_namespace option)	r=   r|   rp  r}   rQ   r   r   r   r   )r5   r   sr   s       r   !test_bug_200709_default_namespacez*BugsTest.test_bug_200709_default_namespace.  s   JJ''MM!_--1	BBB7	9 	9 	9 JJ''MM!_--MM!0111	BBB	 	 	 JJ''MM!_--MM!V$$z** 	6ba95555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6R\**N	P 	P 	P 	P 	Ps   :EEEc                    t                               d          }|                     t                               |          d           t                               dd           t                               d          }|                     t                               |          d           t                               d          }|                     t                               |          d           d S )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/" />)r=   r|   r}   r	  register_namespacerD  s     r   "test_bug_200709_register_namespacez+BugsTest.test_bug_200709_register_namespaceE  s    JJHIIQQ	S 	S 	S
e%OPPPJJHIIQQ	S 	S 	S
 JJ@AAQG	I 	I 	I 	I 	Ir!   c                    t                               d          }|                    t                               d                     |                     |d         j        t           j                   t                               d          }|                    t                               d                     |                     |d         j        t           j                   d S )Nr   r   r   )r=   r|   r   rq  r}   rU   r   )r5   r   s     r   test_bug_200709_element_commentz(BugsTest.test_bug_200709_element_commentT  s     JJsOO	E""###12:...JJsOO	u125)))))r!   c                    t                               d          }t                               |d          }t                               |d          }t                               d          }|                    d|           |                     t          |          g d           |                    d|           |                     t          |          g d           d S )	Nr   r   r   r   r   )r   r   r   r  )r   r   r   r   )r=   r|   rp  r   r}   rZ   r5   r   r   r   r   s        r   test_bug_200709_element_insertz'BugsTest.test_bug_200709_element_insert`  s    JJsOOMM!S!!MM!S!!JJsOO	A**OOO<<<	Q**,@,@,@AAAAAr!   c                 d   t                               d          }t                               |d          }t                               d          }|                    |           |                     t          |                    t           j                            t           j        g           d S )Nr   r   zTEST-b)r=   r|   rp  rq  r   r}   rZ   r   )r5   r   r   	comment_bs       r   test_bug_200709_iter_commentz%BugsTest.test_bug_200709_iter_commentj  s}    JJsOOMM!S!!JJx((		rz(:(:;;bj\JJJJJr!   c                 &   t                                           }|                    d          }|                    di           }|                    d          }|                                }|                     t          |          d           d S )Nr*   rU   r  )r=   r  r*   rG  r3  r  r}   rQ   )r5   r   r   s      r   test_bug_1534630zBugsTest.test_bug_1534630t  ss    nnHHVIIeR  GGENNIIKK1y11111r!   c                 *   t                               d          }|                     t                               |d          d           t                               d          }|                     t                               |d          d           d S )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>tg</body>r  rD  s     r   test_issue6233zBugsTest.test_issue6233|  s    FF . / /Q00)	* 	* 	* FF * + +Q00)	* 	* 	* 	* 	*r!   c                 (   t                               d          }|                     t          |          dg           t                               t                    }|d d          |d d <   |                     t          |          g d           d S )Nr   rU   rU   rU   rk  )r=   r   r}   rZ   r   )r5   rL   newelems      r   test_issue6565zBugsTest.test_issue6565  s    vv+,,--w777&&$$!!!*QQQ--/H/H/HIIIIIr!   c                 r    t                               dd           t                               dd           d S )N	test10777zhttp://myuri/)r=   r]  r   s    r   test_issue10777zBugsTest.test_issue10777  s6     	k?;;;
k?;;;;;r!   c                 `    G fdd          }t                               d           |            _                                        }t	          |          }|                     ||           |                     j        t                     |                     j        d           d S )Nc                       e Zd Z fdZdS )%BugsTest.test_lost_text.<locals>.Textc                     d_         dS )NchangedTr  rD  s    r   __bool__z.BugsTest.test_lost_text.<locals>.Text.__bool__  s    "tr!   Nr@   rA   rB   rw  r   s   r   r   rt    .              r!   r   rU   rv  )r=   r|   ry   r   ra  r{   r   r}   r5   r   r   rF  r   s       @r   test_lost_textzBugsTest.test_lost_text  s    	 	 	 	 	 	 	 	 	 	
 JJuJJLLGGa&&&afc***+++++r!   c                     G fdd          }t                               d                              t                               d                      |            d         _                                        }t          |          }|                     ||           |                     d         j        t                     |                     d         j        d           d S )Nc                       e Zd Z fdZdS )%BugsTest.test_lost_tail.<locals>.Textc                 "    dd         _         dS Nrv  r   Tr  rD  s    r   rw  z.BugsTest.test_lost_tail.<locals>.Text.__bool__  s    %!	tr!   Nrx  ry  s   r   r   r    rz  r!   r   r:  rU   r   rv  )	r=   r|   r   rx   r   ra  r{   r   r}   r{  s       @r   test_lost_tailzBugsTest.test_lost_tail  s    	 	 	 	 	 	 	 	 	 	
 JJv	E""###DFF!	JJLLGGa&&&adi---1I.....r!   c                 |    G fdd          }t                               d                              t                                |                                                     t                               d                                         d          	 t	                    }n%# t
          $ r |                     d           Y nw xY w|                     |j        |           |                     d         j        t                     | 
                    d         j        d           d S )Nc                       e Zd Z fdZdS )$BugsTest.test_lost_elem.<locals>.Tagc                 `    t                               d          d<   t                     dS r  )r=   r|   ra  )r5   r   r   r   s     r   __eq__z+BugsTest.test_lost_elem.<locals>.Tag.__eq__  s(    zz),,!Qtr!   Nr@   rA   rB   r  )r   r   s   r   r   r    s3               r!   r   r:  rU   zgenerators are not reentrantr   rv  )r=   r|   r   r   ra  r   skipTestr{   rU   r   r}   )r5   r   rF  r   r   s      @@r   test_lost_elemzBugsTest.test_lost_elem  s;   	 	 	 	 	 	 	 	 	 	 	 JJv	CCEE""###	E""###FF5MM	:QAA 	: 	: 	:MM899999	:aeS)))adh,,,19-----s   %B5 5CCc                     d|z  }t                               |          }|                     |                    d          |                    d                     d S )Ns   <a b="%s"/>r   r   )r=   r   r}   rl   decode)r5   ry   r  r:  s       r   check_expat224_utf8_bugz BugsTest.check_expat224_utf8_bug  sM    t#vvc{{#G(<(<=====r!   c                 b    d}|                      |           d}|                      |           d S )Ns   ààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààs  xàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r  r  s     r   test_expat224_utf8_bugzBugsTest.test_expat224_utf8_bug  s<     "$$T***($$T*****r!   c                    t          t          d          5 }|                                }d d d            n# 1 swxY w Y   t                              |          }|                    d          }|                    d                                          }|                    dd          }|dd         }| 	                    |                    d          |           d S )NrZ  r   r   r  r     )
r  UTF8_BUG_XMLFILEr  r=   r   rl   r  stripr&   r}   )r5   fprawr:  xmlattrry   s         r   test_expat224_utf8_bug_filez$BugsTest.test_expat224_utf8_bug_file  s    "D)) 	R''))C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	}}S!!((3-- zz'""((**||FC((AbDz#-----s   7;;c                     |                      t          t                                          j        d           |                      t          t                                          j        dd            d S )NrU   )r   r'  r=   r  rG  r   s    r   test_39495_treebuilder_startz%BugsTest.test_39495_treebuilder_start  sT    )R^^%5%5%;UCCC)R^^%5%5%;UDIIIIIr!   N)#r@   rA   rB   r*  r,  r1  r3  r5  r7  r9  r@  rG  unittestskipIfre   gettracerM  rP  rX  r[  r^  r`  rc  rf  rh  rj  rn  rq  r|  r  r  r  r  r  r  r"   r!   r   r$  r$    s         8B B BN N NY Y Y7 7 72< < <? ? ?> > >M M M" X_\S\^^%<==7 7 >=7	E 	E 	E8 8 8P P P.I I I
* 
* 
*B B BK K K2 2 2
* 
* 
*J J J< < <, , ,/ / / . . .(> > >

+ 
+ 
+. . .J J J J Jr!   r$  c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )BasicElementTestc                     d}ddi}t                               ||          }|                     |t           j                   |                     dt	          |                     |                     dt	          |                     |                     dt	          |                     |                     dt	          |                     |                     |j        |           |                     |j                   |                     |j	                   | 
                    |j        |           |                     |j        |           d|d	<   | 
                    |j        |           |                     |j        |           d S )
Nr   zixwyprU   rz   ry   rx   bazr   )r=   r|   r{   r   r   r}   rU   r   ry   rx   r  rz   r  )r5   rU   rz   element_foos       r   test___init__zBasicElementTest.test___init__  sm   %!jjf-- 	k2:666eS--...hK 0 0111fc+..///fc+../// 	#...+*++++*+++ 	+V444+V444 u+V444K.77777r!   c                 x   dt          t          j                  vrt          j        d          t                              dddi          }|                    t                              dddi                     |                     t                    5  |                                }d d d            n# 1 swxY w Y   | 	                    ||           | 
                    |j        |j                   | 
                    |j        |j                   | 
                    |j        |j                   | 
                    t          |          t          |                     t          j        ||          D ]\  }}|                     ||           | 
                    |j        |j                   d S )	Nr   zElement.copy() not presentr   r  r  r   r  qix)r   r=   r|   r  SkipTestr   assertWarnsDeprecationWarningr   r  r}   rU   ry   rx   r~   	itertoolszip_longestassertIsrz   r5   r  element_foo2r  r  s        r   r   zBasicElementTest.test_copy	  s   RZ((#$@AAAjj%(8992::eue-=>>???011 	. 	.&++--L	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	{333 	);?;;;*K,<===*K,<=== 	\**C,<,<=== !* 5k< P P 	* 	*VVMM&&)))) 	,k.@AAAAAs   B88B<?B<c                    t                               dddi          }|                    t                               dddi                     t          j        |          }|                     ||           |                     |j        |j                   |                     |j        |j                   |                     |j        |j                   |                     t          |          t          |                     t          j        ||          D ]\  }}|                     ||           |                     |j        |j                   d S Nr   r  r  r   r  r  )r=   r|   r   r   r  r}   rU   ry   rx   r~   r  r  r  rz   r  s        r   test___copy__zBasicElementTest.test___copy__*	  sC   jj%(8992::eue-=>>???y-- 	{333 	);?;;;*K,<===*K,<=== 	\**C,<,<=== !* 5k< P P 	* 	*VVMM&&)))) 	,k.@AAAAAr!   c                    t                               dddi          }|                    t                               dddi                     t          j        |          }|                     ||           |                     |j        |j                   |                     |j        |j                   |                     |j	        |j	                   |                     t          |          t          |                     t          j        ||          D ]\  }}|                     ||           |                     |j        |j                   |                     |j        |j                   d|j        d<   |                     |j        |j                   |                     |j        |j                   d S r  )r=   r|   r   r   r   r  r}   rU   ry   rx   r~   r  r  rz   r  r  s        r   test___deepcopy__z"BasicElementTest.test___deepcopy__B	  s   jj%(8992::eue-=>>???}[11 	{333 	);?;;;*K,<===*K,<=== 	\**C,<,<=== !* 5k< P P 	- 	-VVVV,,,, 	,k.@AAA,k.@AAA %*5!,k.@AAAL/1CDDDDDr!   c                    t                               d          }|                     t          |j        d           |                     t          |j        t                               d          dg           |                     t          |j        dd           t                               d          g|d d <   |                     t                    5  d|d<   d d d            n# 1 swxY w Y   |                     t                    5  t                               d          dg|d d <   d d d            n# 1 swxY w Y   t          |d          r*dd gdd	d
d}|                     t          |j        |           t          |d          rQ G d dt           j                  } |d          g|d d <   |                     t          t          j
        |           d S d S )Njoer   r   r   r   __setstate__rU   r   rx   ry   )rU   	_childrenrz   rx   ry   __deepcopy__c                       e Zd Zd ZdS )9BasicElementTest.test_augmentation_type_errors.<locals>.Ec                     d S r^   r"   )r5   memos     r   r  zFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__w	  s    4r!   N)r@   rA   rB   r  r"   r!   r   Er  v	  s#                 r!   r  )r=   r|   r   r'  r   r   r   r   r  r   r   )r5   r   stater  s       r   test_augmentation_type_errorsz.BasicElementTest.test_augmentation_type_errors`	  sX   JJu)QXs333)QX

50A0A5/IJJJ)QXq%888

5!!"!!!y)) 	 	AaD	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	. 	.JJu%%u-AaaaD	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 1n%% 	@"V  E i???1n%% 	;         BJ       AeHH:AaaaDi:::::	; 	;s$   C%%C),C)
"D88D<?D<c                     G d d          } |            }t                               d|          |_        t          j        |          }~t                       |                      |                       t                               d          } |            }||_        t          j        |          }t                               |d|          }~~~t                       |                      |                       t                               d          }t                               d          }t                               d          }|                    |           |                    |           |                    |           t          j        |          }~~~t                       |                      |                       d S )	Nc                       e Zd ZdS ).BasicElementTest.test_cyclic_gc.<locals>.DummyNr@   rA   rB   r"   r!   r   Dummyr  }	          Dr!   r  r  )r   r   r   r   r   )	r=   r|   dummyrefweakrefrefr
   r   rp  r   )r5   r  r   wrefr   r   r   r   s           r   test_cyclic_gczBasicElementTest.test_cyclic_gc|	  s   	 	 	 	 	 	 	 	 EGGZZAZ..
{1~~$$&&!!! JJuEGG
{1~~]]1e!],,q"$$&&!!! ZZZZZZ
		"
		"
		"{2B$$&&!!!!!r!   c                 @   dfd}t                               d          }t          j        ||          }|                      |            j        d           ~t                       |                     d           |                      |            d            d S )NFc                     dd S NTr"   )wflags    r   wref_cbz.BasicElementTest.test_weakref.<locals>.wref_cb	  s    DDDr!   r   T)r=   r|   r  r  r}   rU   r
   )r5   r  r   r  r  s       @r   test_weakrefzBasicElementTest.test_weakref	  s    	 	 	 	 	 JJsOO{1g&&S)))t$$$&&&&&r!   c                     t                               dddd          }|                     |                    dd          d           |                     |                    d	d          d           d S )
Nr   r   r   r  )r   r   zr      )r   r  )r=   r|   r}   rl   )r5   r   s     r   test_get_keyword_argsz&BasicElementTest.test_get_keyword_args	  sm    ZZ!qAZ..Q//333Q//33333r!   c           	         t          dt          j        dz             D ]g}t          | j        d          D ]L\  }}|                    dd          }d|_        d|_        |                    |d	          	                    |                    d
                     |	                    |                    d	                     |
                    d          d                             dd           |                     |d|||          }|                     |j        d           |                     |j        d         d           |                     t!          |          d           |                     ||           Nid S )Nr   r   repeatr   *   )r   ztext goes herezopposite of headchild
grandchildz.//grandchildr   r   zother valuer8   r   )r   rf   HIGHEST_PROTOCOLr   r`   r|   ry   rx   rp  r   r   r   rv   r}   rU   rz   r~   r   )r5   rq   ro   rp   r   r   s         r   test_picklezBasicElementTest.test_pickle	  s{   1f59:: 	0 	0E")$,q"A"A"A 0 0NN5bN11)+!!!W--44V^^L5Q5QRRR00111		/**1-11&-HHH))!-D*0&%A A   ///  5!12666  R!,,,((B////0	0 	0r!   c           	         t          dt          j        dz             D ]}t          | j        d          D ]\  }}d}|                    |          }|                     |                                d         d           |                     |d|||          }|                     |j	        d           |                     |d         j	        d	           d S )
Nr   r   r  z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>rU   groupr8   r   dogs)
r   rf   r  r   r`   r   r}   __getstate__rv   rU   )r5   rq   ro   rp   XMLTEXTr   r   s          r   test_pickle_issue18997z'BasicElementTest.test_pickle_issue18997	  s    1f59:: 
	4 
	4E")$,q"A"A"A 	4 	4  &&w//  !2!25!97CCC))".E*0&%A A  111  AF3333	4
	4 
	4r!   N)r@   rA   rB   r  r   r  r  r  r  r  r  r  r  r"   r!   r   r  r    s        8 8 86B B B:B B B0E E E<; ; ;8!" !" !"F' ' '4 4 4
0 0 0&4 4 4 4 4r!   r  c                   J    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )BadElementTestc                 f    G fdd          } |            gt                               d          }	 |                               n# t          $ r Y nw xY w G d d|t           j                  } |d          gt                               d          }|                               d S )Nc                   *    e Zd Ze fd            ZdS )2BadElementTest.test_extend_mutable_list.<locals>.Xc                 \    t                               d          gd d <   t           j        S )Nr  rU  r5   Ls    r   	__class__z<BadElementTest.test_extend_mutable_list.<locals>.X.__class__	  s'    

5))*!!!z!r!   Nr@   rA   rB   propertyr  r  s   r   Xr  	  8        " " " " X" " "r!   r  r   c                       e Zd ZdS )2BadElementTest.test_extend_mutable_list.<locals>.YNr  r"   r!   r   Yr  	  r  r!   r  r   r=   r|   r   r'  r5   r  r   r  r  s       @r   test_extend_mutable_listz'BadElementTest.test_extend_mutable_list	  s    	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 QSSEJJu	HHQKKKK 	 	 	D		 	 	 	 	2: 	 	 	QsVVHJJu	s   A 
AAc                     G fdd          } |            t                               d          gt                               d          }	 |                               n# t          $ r Y nw xY w G d d|t           j                  } |d          t                               d          gt                               d          }|                               d S )Nc                   *    e Zd Ze fd            ZdS )3BadElementTest.test_extend_mutable_list2.<locals>.Xc                 &    d d = t           j        S r^   rU  r  s    r   r  z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__	  s    aaaDz!r!   Nr  r  s   r   r  r  	  r  r!   r  r  r   c                       e Zd ZdS )3BadElementTest.test_extend_mutable_list2.<locals>.YNr  r"   r!   r   r  r  	  r  r!   r  r   r  r  s       @r   test_extend_mutable_list2z(BadElementTest.test_extend_mutable_list2	  s
   	" 	" 	" 	" 	" 	" 	" 	" 	" 	"
 QSS"**U##$JJu	HHQKKKK 	 	 	D		 	 	 	 	2: 	 	 	QuXXrzz%(()JJu	s   A& &
A32A3c                     G fddt           j                  }t                               d                               |d          g           |                     t          j        t                               d                     t                               d                              t                               d          g           |                     t          j         |d                     d S )Nc                       e Zd Z fdZdS )3BadElementTest.test_remove_with_mutating.<locals>.Xc                     d d = dS )NFr"   )r5   or   s     r   r  z:BadElementTest.test_remove_with_mutating.<locals>.X.__eq__	  s    aaaDur!   Nr  ry  s   r   r  r  	  s.              r!   r  r   r   r  )r=   r|   r   r   r   r   r5   r  r   s     @r   test_remove_with_mutatingz(BadElementTest.test_remove_with_mutating	  s    	 	 	 	 	 	 	
 	 	 	 JJu	!!E((*ah

50A0ABBBJJu	"**U##$%%%*ah%99999r!   c                    t                               d          }t          |d|          5  |                     t                    5  t          |           d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Nr   rU   )r=   r|   r   r   RuntimeErrorr   rD  s     r   test_recursive_reprz"BadElementTest.test_recursive_repr
  s    JJuq%## 	 	""<00  Q              	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s5   A;A#A;#A'	'A;*A'	+A;;A?A?c                     G fddt                     }t                                          }|                    di            |                    d           |                     |d                     |                    d           |                    d           |                                |                     j        d           d S )Nc                       e Zd Z fdZdS )/BadElementTest.test_element_get_text.<locals>.Xc                 :    	 j          d S # t          $ r Y d S w xY wr^   )ry   	NameErrorrr  s    r   __del__z7BadElementTest.test_element_get_text.<locals>.X.__del__
  s5    IIII    DDs    
Nr@   rA   rB   r  rL   s   r   r  r  
  .              r!   r  rU   ABCDEFGHIJKLABCDEFGHIJKL)	r   r=   r  rG  r*   r3  r  r}   ry   r5   r  r   rL   s      @r   test_element_get_textz$BadElementTest.test_element_get_text
  s    	 	 	 	 	 	 	 	 	 	 NN	r	v	qqyy	v	ewwyyN33333r!   c                 
    G fddt                     }t                                          }|                    di            |                    di            |                    d           |                    d           |                     |d                     |                    d           |                    d           |                                |                     d         j        d	           d S )
Nc                       e Zd Z fdZdS )/BadElementTest.test_element_get_tail.<locals>.Xc                 F    	 d         j          d S # t          $ r Y d S w xY wr  )rx   r  rr  s    r   r  z7BadElementTest.test_element_get_tail.<locals>.X.__del__#
  s9    GLLLL    DDs    
  Nr  r  s   r   r  r  "
  r  r!   r  r:  rU   r  r  r  r   r  )	r   r=   r  rG  r3  r*   r  r}   rx   r  s      @r   test_element_get_tailz$BadElementTest.test_element_get_tail 
  s    	 	 	 	 	 	 	 	 	 	 NN		r	e	v	qqyy	v	fwwyya~66666r!   c                 X    G fdd          }t                               d                              t                               d                     d  |                                          t                               d                     dd |                      d S )Nc                       e Zd Z fdZdS )%BadElementTest.test_subscr.<locals>.Xc                     d d = dS Nr   r"   rD  s    r   	__index__z/BadElementTest.test_subscr.<locals>.X.__index__8
  s    aaaDqr!   Nr@   rA   rB   r#  ry  s   r   r  r   7
  .              r!   r  rL   r  r   r   )r=   r|   r   r  s     @r   test_subscrzBadElementTest.test_subscr5
  s    	 	 	 	 	 	 	 	 	 	
 JJv	G$$%%%	$1133$	G$$%%%	!Bqqss(r!   c                      G fdd          }t                               d          t          d          D ]0}                    dt                               d                     1g dd |            <   d S )Nc                       e Zd Z fdZdS ))BadElementTest.test_ass_subscr.<locals>.Xc                     g d d <   dS r"  r"   rD  s    r   r#  z3BadElementTest.test_ass_subscr.<locals>.X.__index__F
  s    !!!qr!   Nr$  ry  s   r   r  r)  E
  r%  r!   r  rL   r   r   r  )r=   r|   r   r   )r5   r  r.  r   s      @r   test_ass_subscrzBadElementTest.test_ass_subscrC
  s    	 	 	 	 	 	 	 	 	 	
 JJvr 	- 	-AHHQ

7++,,,,!Bqqss(r!   c                     d }t                               |          }|                    di            |                    d           |                     t
          |j        di            ~t                       d S )Nc                     g S r^   r"   r   r   s     r   element_factoryz>BadElementTest.test_treebuilder_start.<locals>.element_factoryR
      Ir!   r/  rU   r  r   )r=   r  rG  r*   r   AttributeErrorr
   r5   r/  r   s      r   test_treebuilder_startz%BadElementTest.test_treebuilder_startP
  ss    	 	 	NN?N;;	r	v.!'62>>>r!   c                     d }t                               |          }|                    di            |                    d           |                     t
          |j        d           ~t                       d S )Nc                     g S r^   r"   r.  s     r   r/  z<BadElementTest.test_treebuilder_end.<locals>.element_factory^
  r0  r!   r1  rU   r  )r=   r  rG  r*   r   r2  r3  r
   r3  s      r   test_treebuilder_endz#BadElementTest.test_treebuilder_end\
  sq    	 	 	NN?N;;	r	v.!%777r!   N)r@   rA   rB   r  r  r  r	  r  r  r&  r+  r4  r7  r"   r!   r   r  r  	  s          &  &: : :  4 4 4&7 7 7*    
 
 

 
 
 
 
r!   r  c                       e Zd Zd Zd ZdS )MutatingElementPathc                 8    t          j        | g|R  }||_        |S r^   )r   __new__rL   )ra   rL   r   r5   s       r   r;  zMutatingElementPath.__new__j
  s%    {3&&&&	r!   c                     | j         d d = dS r  r  r5   r  s     r   r  zMutatingElementPath.__eq__n
  s    IaaaLtr!   N)r@   rA   rB   r;  r  r"   r!   r   r9  r9  i
  s2              r!   r9  c                       e Zd Zd ZdS )BadElementPathc                     ddz  )Nr   r   r"   r=  s     r   r  zBadElementPath.__eq__t
  s    c	r!   Nr  r"   r!   r   r?  r?  s
  s#            r!   r?  c                   X     e Zd Z fdZ fdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Z xZS )BadElementPathTestc                 z    t                                                       ddlm} |j        | _        i |_        d S Nr   r2   )supersetUpr4   r3   r   
path_cacher5   r3   r  s     r   rF  zBadElementPathTest.setUpy
  s>    ))))))%,r!   c                 l    ddl m} | j        |_        t	                                                       d S rD  )r4   r3   rG  r   rE  tearDownrH  s     r   rJ  zBadElementPathTest.tearDown
  s;    ))))))!_r!   c                     t                               d          }|                    t                               d          g           |                    t	          |d                     d S Nr   r   r   )r=   r|   r   r   r9  rD  s     r   test_find_with_mutatingz*BadElementPathTest.test_find_with_mutating
  sW    JJu	"**U##$%%%	"1c**+++++r!   c                     t                               d          }|                    t                               d          g           	 |                    t	          d                     d S # t
          $ r Y d S w xY wrL  )r=   r|   r   r   r?  ZeroDivisionErrorrD  s     r   test_find_with_errorz'BadElementPathTest.test_find_with_error
  s{    JJu	"**U##$%%%	FF>#&&'''''  	 	 	DD	   
"A. .
A<;A<c                     t                               d          }|                    t                               d          g           |                    t	          |d                     d S rL  )r=   r|   r   r   r9  rD  s     r   test_findtext_with_mutatingz.BadElementPathTest.test_findtext_with_mutating
  sW    JJu	"**U##$%%%	

&q#../////r!   c                     t                               d          }|                    t                               d          g           	 |                    t	          d                     d S # t
          $ r Y d S w xY wrL  )r=   r|   r   r   r?  rO  rD  s     r   test_findtext_with_errorz+BadElementPathTest.test_findtext_with_error
  s{    JJu	"**U##$%%%	JJ~c**+++++  	 	 	DD	rQ  c                     t                               d          }t                               |d          }dddg di g}|D ]2}||_        |                     |                    d          |           3d S )Nr   r   rP  r   Fr"   ./barr=   r|   rp  ry   r}   r   )r5   	root_elemsub_elemfalseyvals        r   (test_findtext_with_falsey_text_attributez;BadElementPathTest.test_findtext_with_falsey_text_attribute
  s    JJu%%	==E22aB+ 	? 	?CHMY//88#>>>>	? 	?r!   c                     t                               d          }t                               |d          }d |_        |                     |                    d          d           d S )Nr   r   rW  rP  rX  )r5   rY  rZ  s      r   &test_findtext_with_none_text_attributez9BadElementPathTest.test_findtext_with_none_text_attribute
  sW    JJu%%	==E22++G44b99999r!   c                     t                               d          }|                    t                               d          g           |                    t	          |d                     d S rL  )r=   r|   r   r   r9  rD  s     r   test_findall_with_mutatingz-BadElementPathTest.test_findall_with_mutating
  sW    JJu	"**U##$%%%			%a--.....r!   c                     t                               d          }|                    t                               d          g           	 |                    t	          d                     d S # t
          $ r Y d S w xY wrL  )r=   r|   r   r   r?  rO  rD  s     r   test_findall_with_errorz*BadElementPathTest.test_findall_with_error
  s{    JJu	"**U##$%%%	IInS))*****  	 	 	DD	rQ  )r@   rA   rB   rF  rJ  rM  rP  rS  rU  r]  r_  ra  rc  __classcell__)r  s   @r   rB  rB  x
  s                     
, , ,
  0 0 0
  ? ? ?: : :/ / /
      r!   rB  c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )ElementTreeTypeTestc                    |                      t          j        t                     |                      t          j        t                     |                      t          j        t                     |                      t          j        t                     |                      t          j        t                     |                      t          j        t                     d S r^   )	r{   r=   re  r~  rT  r/   r|   r  r  r   s    r   test_istypezElementTreeTypeTest.test_istype
  s    bmT222bh---bnd333bj$///bnd333blD11111r!   c                 2    G d dt           j                  } |d          }|                     |t           j                   |                     ||           |                     |j        d           d|_        |                     |j        d           d S )Nc                       e Zd ZdS )DElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementNr  r"   r!   r   	MyElementrk  
  r  r!   rl  r   r  )r=   r|   r{   r}   rU   ry   r5   rl  myes      r   test_Element_subclass_trivialz1ElementTreeTypeTest.test_Element_subclass_trivial
  s    	 	 	 	 	
 	 	 	 ic2:...c9---%((( 5)))))r!   c                     G fddt           j                   dddddd	          }|                     |j        d
           |                     t	          |                                          g d           d S )Nc                   &     e Zd Zi f fd	Z xZS )HElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementc                 H     t          |           j        |dz   |fi | d S )N__)rE  r  )r5   rU   rz   extrarl  r  s       r   r  zQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__
  s4    /i&&/d
FLLeLLLLLr!   )r@   rA   rB   r  rd  )r  rl  s   @r   rl  rr  
  sQ        +- M M M M M M M M M M Mr!   rl  r   r   r   )r   r   r     )r   r   foo__))r   r   )r   r   )r   r  )r   rv  )r=   r|   r}   rU   r
  r   )r5   rn  rl  s     @r   !test_Element_subclass_constructorz5ElementTreeTypeTest.test_Element_subclass_constructor
  s    	M 	M 	M 	M 	M 	M 	M
 	M 	M 	M iQQ//1:::'***		,,444	6 	6 	6 	6 	6r!   c                      G d dt           j                  } |d          }|                     |                                d           d S )Nc                       e Zd Zd ZdS )GElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementc                     | j         S r^   rT   r   s    r   	newmethodzQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethod
  s	    xr!   N)r@   rA   rB   r}  r"   r!   r   rl  r{  
  s#                 r!   rl  r  )r=   r|   r}   r}  rm  s      r    test_Element_subclass_new_methodz4ElementTreeTypeTest.test_Element_subclass_new_method
  sc    	  	  	  	  	 
 	  	  	  i%00000r!   c                 B    G d dt           j                  }t                               d          }d|_         |d          }d|_        |                    |           |                     |                    d          d           |                     |                    d          j        d           t          |	                    d                    }|                     t          |          d|           |                     |d         j        d           d S )	Nc                       e Zd ZdS )AElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementNr  r"   r!   r   rl  r  
  r  r!   rl  r   ry   r   rn  r   r   )r=   r|   ry   r   r}   r   r   rU   r   r   r~   )r5   rl  r   subfounds        r   test_Element_subclass_findz.ElementTreeTypeTest.test_Element_subclass_find
  s   	 	 	 	 	
 	 	 	 JJui	E**I666*E222QYYu%%&&UQ...qu-----r!   N)r@   rA   rB   rh  ro  rx  r~  r  r"   r!   r   rf  rf  
  s_        2 2 2* * *6 6 61 1 1. . . . .r!   rf  c                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	S )
ElementFindTestc                 h   t                               t                    }|                     |                    d          j        d           |                     |                    d          j        d           |                     |                    d          j        d           t                               t                    |d<   |                     |                    d          j        d           |                     |                    d          d           |                     |                    d          d           |                     |                    d          d	           |                     |                    dd
          d	           |                     |                    d                     |                     |                    dd
          d
           |                     t                               d                              d          d	           d S )NrU   r   ./tagr   zsection/nexttagnexttagry   rn  rP  r   togz<tag><empty /></tag>empty)	r=   r   r   r}   r   rU   SAMPLE_SECTIONr   r   rD  s     r   test_find_simplez ElementFindTest.test_find_simple
  s   FF:*E222..2E:::,e444vvn%%! 1226	BBBG,,f555M22I>>> 	$566;;;$5yAA2FFF 	!**U++,,,E955yAAA 	 677@@II2NNNNNr!   c                 V   d}t                               |          }|                     |                    d          j        d         d           |                     |                    d          j        d         d           |                     |                    d          j        d         d           |                     |                    d	          j        d         d
           |                     |                    d          j        d         d           |                     t          d|j        d           |                     t          d|j        d           |                     t          d|j        d           |                     t          d|j        d           d S )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]XPathz./tag[0]z	./tag[-1]z./tag[last()-0]z./tag[last()+1])r=   r   r}   r   rz   r  SyntaxError)r5   
LINEAR_XMLr   s      r   test_find_xpathzElementFindTest.test_find_xpath
  sj   
 FF: 	
++27;SAAA
++27;SAAA007@#FFF 1229'BCHHH 1229'BCHHH{GQVZHHH{GQV[III{GQV=NOOO{GQV=NOOOOOr!   c                 2   t                               t                    }t                               t                    |d<   |                     t          |                    d                    dg           |                     t          |                    d                    ddg           |                     t          |                    d                    g            |                     t          |                    d                    g            |                     t          |                    d                    g d           |                     t          |                    d	                    dgd
z             |                     t          |                    d                    dg           |                     t          |                    d                    dgdz             |                     t          |                    d                    g d           |                     t          |                    d                    g d           |                     t          |                    d                    g d           |                     t          |                    d                    g d           |                     t          |                    d                    g d           |                     t          |                    d                    dg           |                     t          |                    d                    dg           |                     t          |                    d                    dgdz             |                     t          |                    d                    dgdz             |                     t          |                    d                    dgdz             |                     t          |                    d                    dg           |                     t          |                    d                    dgdz             |                     t          |                    d                    dgdz             |                     t          |                    d                    dg           |                     t          |                    d                    dg           |                     t          |                    d                    d g           |                     t          |                    d!                    g            |                     t          |                    d"                    g            |                     t          |                    d#                    dgdz             |                     |                    d$          |                    d                     |                     t          |                    d%                    d g           |                     t          |                    d&                    d g           |                     t          |                    d'                    d g           |                     t          |                    d(                    d g           |                     t          |                    d)                    d g           |                     t          |                    d*                    g            |                     t          |                    d+                    g            |                     t          |                    d,                    g            |                     t          |                    d-                    g            |                     t          |                    d.                    g            |                     t          |                    d/                    dg           |                     t          |                    d0                    dg           |                     t          |                    d1                    dg           |                     t          |                    d2                    dg           |                     t          |                    d3                    dg           |                     t          |                    d4                    g            |                     t          |                    d5                    g            |                     t          |                    d6                    dgdz             |                     t          |                    d7                    dgdz             |                     t          |                    d8                    dgdz             |                     t          |                    d9                    dgdz             |                     t          |                    d:                    dgdz             |                     t          |                    d;                    dgd
z             |                     t          |                    d<                    dgd
z             |d         |d=<   |                     t          |                    d(                    d d g           |                     t          |                    d3                    ddg           d S )>Nr   rp  r(  rU   r  ztog/foor   rl  z.//tagrv  r   zsection//tagz	section/*)rU   r  nextsectionz
section//*)rU   r  r  rU   zsection/.//*z*/*z*//*z*/tagz*/./tagr  z././tagz.//tag[@class]r  z.//tag[@class="a"]z.//tag[@class!="a"]z.//tag[@class="b"]z.//tag[@class!="b"]z.//tag[@id]z.//section[tag]rk  z.//section[element]z../tagzsection/../tagz	section//z.//section[tag='subtext']z.//section[tag ='subtext']z.//section[tag= 'subtext']z.//section[tag = 'subtext']z.//section[ tag = 'subtext' ]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']z.//tag[.!='subtext']z.//tag[. !='subtext']z.//tag[.!= "subtext"]z.//tag[ . != "subtext" ]z.//tag[. != 'subtext']z.//tag[. != 'subtext ']z.//tag[.!= ' subtext']r   )r=   r   r   r  r}   rZ   r   rD  s     r   test_findallzElementFindTest.test_findall   s   FF:vvn%%!		#77&BBB		%(8(899E5>JJJ		%(8(8992>>>		)(<(<==rBBB		#77%%%	' 	' 	'		((;(;<<GaK	 	 			-(@(@AAE7KKK		.(A(ABBUGaKPPP		+(>(>??---	/ 	/ 	/		,(?(?@@444	6 	6 	6		.(A(ABB444	6 	6 	6		%(8(899---	/ 	/ 	/		&(9(9::444	6 	6 	6		'(:(:;;eWEEE		)(<(<==wGGG		'(:(:;;eWq[III		)(<(<==w{KKK		2B(C(CDDGaK	 	 			2F(G(GHHG	 	 			2G(H(HIIGaK	 	 			2F(G(GHHGaK	 	 			2G(H(HIIG	 	 			-(@(@AAG	 	 			2C(D(DEEK	 	 			2G(H(HII2NNN		((;(;<<bAAA		2B(C(CDDGaK	 	 	;//<1H1HIII		2M(N(NOOK	 	 			2N(O(OPPK	 	 			2N(O(OPPK	 	 			2O(P(PQQK	 	 			2Q(R(RSSK	 	 	
 			2N(O(OPP	 	 			2O(P(PQQ	 	 			2O(P(PQQ	 	 			2P(Q(QRR	 	 			2R(S(STT	 	 	 			2G(H(HII	" 	" 	"		2H(I(IJJ	" 	" 	"		2H(I(IJJ	" 	" 	"		2K(L(LMM	" 	" 	"		2I(J(JKK	" 	" 	"		2J(K(KLL	 	 			2I(J(JKK	 	 	
 			2H(I(IJJ1	& 	& 	&		2I(J(JKK1	& 	& 	&		2I(J(JKK1	& 	& 	&		2L(M(MNN1	& 	& 	&		2J(K(KLL1	& 	& 	& 			2K(L(LMM1	& 	& 	&		2J(K(KLL1	& 	& 	& t!		2O(P(PQQ#Y/	1 	1 	1		2I(J(JKK	) 	) 	) 	) 	)r!   c                    t                               t                    }|                     t	          |                    d                    g            |                     t	          |                    d                    dgdz             |                     t	          |                    d                    dgdz             d S )NrU   z{http://effbot.org/ns}tagr   z.//{http://effbot.org/ns}tagr  )r=   r   rO  r}   rZ   r   rD  s     r   test_test_find_with_nsz&ElementFindTest.test_test_find_with_ns  s    FF=!!		%(8(8992>>>199%@AABB()A-	/ 	/ 	/ 	199%CDDEE()A-	/ 	/ 	/ 	/ 	/r!   c                    t                               d          }ddi}|                     t          |                    d|                    d           |                     t          |                    d|                    d           ddi}|                     t          |                    d|                    d	           |                     t          |                    d|                    d           ddd
}|                     t          |                    d|                    d           |                     t          |                    d|                    d	           d S )N
            <a xmlns:x="X" xmlns:y="Y">
                <x:b><c/></x:b>
                <b/>
                <c><x:b/><b/></c><y:b/>
            </a>xxr  z.//xx:b)r_  r   .//br  r   )r  rP  )r=   r   r}   r~   r   )r5   r:  nsmaps      r   test_findall_different_nsmapsz-ElementFindTest.test_findall_different_nsmaps  sU   vv    sT\\)\FFGGKKKT\\&U\CCDDaHHHsT\\)\FFGGKKKT\\&U\CCDDaHHH$$T\\)\FFGGKKKT\\&U\CCDDaHHHHHr!   c                 R   t                               d          }|                    t                               d                     |                     t          |                    d                    g d           |                     t          |                    d                    dg           |                     t          |                    d                    dg           |                     t          |                    d	                    d
g           |                     t          |                    d                    ddg           |                     t          |                    d                    dg           |                     t          |                    d                    t          |                    d                               |                     t          |                    d                    g d           |                     t          |                    d          |d         gz             t          |                    d                               |                     t          |                    d                    g d           |                     t          |                    d                    ddg           |                     t          |                    d                    ddg           |                     t          |                    d                    d
g           |                     t          |                    d                    g d           |                     t          |                    d                    ddg           |                     t          |                    d                    t          |                    d                               d S )Nr  r   z{*}b){X}br   {Y}bz{*}cr   z{X}*r  z{Y}*r  ry  r   z{}br{  )r  r   r   r  r  r   z.//{*}b)r  r   r  r   r  z.//{*}cz.//{X}*z.//{Y}*z.//{}*)r   r   r   r   z.//{}br  )r=   r   r   rq  r}   rZ   r   r  s     r   test_findall_wildcardz%ElementFindTest.test_findall_wildcard  s   vv    	BJJv&&'''V(<(<==...	0 	0 	0V(<(<==	  	  	 V(<(<== 	# 	# 	#V(<(<== 	# 	# 	#U(;(;<<s	% 	% 	%U(;(;<<	  	  	 U(;(;<<'S(9(9::	< 	< 	<V(<(<==333	5 	5 	5 	V(<(<Rz(IJJ'S(9(9::	< 	< 	< 	Y(?(?@@;;;	= 	= 	=Y(?(?@@s	% 	% 	%Y(?(?@@ &)	+ 	+ 	+Y(?(?@@ 	# 	# 	#X(>(>??---	/ 	/ 	/X(>(>??s	% 	% 	%X(>(>??'V(<(<==	? 	? 	? 	? 	?r!   c                     t                               t                    }|                     t          d          5  |                    d           d d d            d S # 1 swxY w Y   d S )Nzcannot use absolute pathz/tag)r=   r   r   r  r  r   rD  s     r   test_bad_findzElementFindTest.test_bad_find  s    FF:##K1KLL 	 	IIf	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   AA"%A"c                    t                               t                    }|                     t                               |                              d          j        d           |                     t                               |                              d          d           |                     t          t                               |          	                    d                    dgdz             d}| 
                    t          |          5  t                               |          	                    d          }d d d            n# 1 swxY w Y   |                     t          |          dgdz             d S )NrU   ry   r   zThis 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  )r=   r   r   r}   r/   r   rU   r   rZ   r   assertWarnsRegexFutureWarning)r5   r   r   r   s       r   test_find_through_ElementTreez-ElementFindTest.test_find_through_ElementTree  sx   FF:**//66:EBBB**33E::FCCCq(9(9(A(A%(H(HIIGaK	 	 	# ""=#66 	4 	4""**733B	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4 	4++eWq[99999s   .EEEN)r@   rA   rB   r  r  r  r  r  r  r  r  r"   r!   r   r  r  
  s        O O O.P P P,n) n) n)`/ / /I I I"*? *? *?X  
: : : : :r!   r  c                   4    e Zd ZddZd Zd Zd Zd Zd ZdS )	ElementIterTestNc                 F    t          |                    |                    S r^   )rZ   r   )r5   rL   rU   s      r   _ilistzElementIterTest._ilist  s    diinn---r!   c                    t                               d          }|                     |                     |          g d           |                     |                     |                    d                    ddg           |                     t          |                                          j        d           |                     d                    |	                                          d           |                     d                    |                    d          	                                          d           |                     t          |	                                          d	           t          |d
          }|                     t          t                               |                    d         d           t          |d
          }t                               t                                                     }|                     t          t                               ||                    d         d           t                               d           }|                     t           |j                   t                               d          }|                     d                    |	                                          d           d S )Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>)rC  r(  r   r(  r   rC  rP  zthis is a paragraph...zthis is a paragraph.z
this is a F)rM   r   r3  r  )r"  z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)r=   r   r}   r  r   ra  r   rU   r*  r   rQ   r`  r  r  r/   r   r2  )r5   rh  
sourcefiler"  rP   s        r   
test_basiczElementIterTest.test_basic  sG   ffNOOS))+@+@+@AAASXXf%5%566FFFchhjj))-v666002JKKK&!1!1!:!:!<!<=="	$ 	$ 	$cllnn--|<<< se444
bll:6677:EBBB se444
R^^%5%566bll:flEEFFqI	  	  	  ~~d##.$)444 ffABB00(;;;;;r!   c                    t                               d          }|                     |                     |          dg           t                               |d          }|                     |                     |          ddg           t                               |d          }|                     |                     |          g d           t                               |d          }|                     |                     |          g d           |d         |d<   |d= |                     |                     |          ddg           d S )	Nr   r   r   )r   r   r   r   )r   r   r   r   r   r   )r=   r|   r}   r  rp  rb  s        r   test_cornerszElementIterTest.test_corners
  s!   JJsOOQ#/// MM!S!!Q#s444 MM!S!!Q999 MM!S!!Q)=)=)=>>> t!aDQ#s44444r!   c                    t                               d          }|                     |                     |d          dgdz             |                     |                     |d          dgdz             |                     t	          |                    d                    dgdz             g d}|                     t	          |                                          |           |                     |                     |          |           |                     |                     |d          |           d S )	NaJ  
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>roomr  houser   rT   )r]  r  r  r  shedr  r  r   )r=   r   r}   r  rZ   r   )r5   rh  all_tagss      r   test_iter_by_tagz ElementIterTest.test_iter_by_tag   s/   ff    	S&11F8a<@@@S'22WIMBBB 	3888//00HqL	 	 	
- - -

33X>>>S))8444S#..99999r!   c                     t                               d          }|                                }|                     t                    5  t          j        |           d d d            d S # 1 swxY w Y   d S )Nr   )r=   r|   r   r   r'  r   )r5   r   r   s      r   r   zElementIterTest.test_copy=  s    JJsOOVVXXy)) 	 	IbMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   	A++A/2A/c                 F   t                               d          }|                                }t          t          j        dz             D ]U}|                     t          t          j        f          5  t	          j	        ||           d d d            n# 1 swxY w Y   Vd S )Nr   r   )
r=   r|   r   r   rf   r  r   r'  ri   rg   )r5   r   r   rq   s       r   r  zElementIterTest.test_pickleC  s    JJsOOVVXX62Q677 	( 	(E""Iv/C#DEE ( (R'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	(s   3BB	B	r^   )	r@   rA   rB   r  r  r  r  r   r  r"   r!   r   r  r    ss        . . . .< < <65 5 5,: : ::  ( ( ( ( (r!   r  c                   p    e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd ZdS )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>c                 *   |                      |j        d           |                      |j        d           |                      |j        d            |                      |j        i            t          |          }|                      t          |          d           |d         }|                      |j        d           |                      |j        d           |                      |j        d           |                      |j        i            d S )NrC  ry   r   r   divrn  rx   )r}   rU   ry   rx   rz   r   r~   )r5   r   childrenr  s       r   _check_sample1_elementz&TreeBuilderTest._check_sample1_elementS  s    '''(((&&&2&&&77X***E***Y///V,,,r*****r!   c                     G d d          } G d d|          }t                                |                      }|                    | j                   |                     |                                d           t                                |                      }|                    | j                   |                     |                                d           t                               t                                }|                    | j                   |                     |                                           d S )Nc                       e Zd Zd ZdS )<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilderc                     dS )Nr  r"   r   s    r   r  zBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeb  s    rr!   NrV  r"   r!   r   BaseDummyBuilderr  a  s#            r!   r  c                       e Zd Zd xZxZZdS )8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuilderc                      d S r^   r"   )r   s    r   <lambda>zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>f  s    D r!   N)r@   rA   rB   r*   rG  r3  r"   r!   r   DummyBuilderr  e  s        !00D05333r!   r  r  r  )r=   r  r  sample1r}   r  objectr   )r5   r  r  r"  s       r   test_dummy_builderz"TreeBuilderTest.test_dummy_builder`  s>   	 	 	 	 	 	 	 		1 	1 	1 	1 	1+ 	1 	1 	1 \\^^44DL!!!,,,%5%5%7%788DL!!!,,,VXX..DL!!!&,,..)))))r!   c                    t                                           }|                     |                    d          j        t           j                   |                     |                    d          j        d           t                               t           j                  }|                     |                    d          j        t           j                   |                     |                    d          j        d           t                               t                    }|                     |                    d          t          d                     d S )Nctext)comment_factory)r=   r  r}   ro  rU   rq  ry   r~   r5   r   s     r   test_treebuilder_commentz(TreeBuilderTest.test_treebuilder_commentt  s    NN7++/<<<7++0':::NN2:N667++/<<<7++0':::NN3N//7++S\\:::::r!   c                    t                                           }|                     |                    dd           j        t           j                   |                     |                    dd           j        d           t                               t           j                  }|                     |                    d          j        t           j                   |                     |                    d          j        d           |                     |                    dd          j        t           j                   |                     |                    dd          j        d           t                               d           }|                     |                    d          t          d          d f           |                     |                    dd          t          d          df           d S )Nr  )
pi_factoryr  z text zpitarget  text c                 $    t          |           |fS r^   )r~   )r  ry   s     r   r  z5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>  s    CKK;N r!   )r=   r  r}   r  rU   r   ry   r~   r  s     r   test_treebuilder_piz#TreeBuilderTest.test_treebuilder_pi  s   NNh--125999h--2H===NNbeN,,h+RU333h,h777j(337???j(338:KLLLNN&N&NNOOh#h--)>???j(33c*oox5PQQQQQr!   c                     G d dt           j                  }d}t                               |          }|                     |j        d           t                                |                      }|                    |           |                                }|                     |j        d           d}t                               |          }|                     |j        d           d}t                                |                      }|                    |           |                                }|                     |j        d           d S )Nc                       e Zd ZdS );TreeBuilderTest.test_late_tail.<locals>.TreeBuilderSubclassNr  r"   r!   r   TreeBuilderSubclassr    r  r!   r  z<a>text<!-- comment -->tail</a>texttailr  z<a>text<?pi data?>tail</a>)r=   r  r   r}   ry   r  r  r  )r5   r  r  r   r"  s        r   test_late_tailzTreeBuilderTest.test_late_tail  s?   	 	 	 	 	". 	 	 	 0MM#,,,%8%8%:%:;;CLLNN,,,*MM#,,,*%8%8%:%:;;CLLNN,,,,,r!   c                     G d dt           j                  }d}t                               t                               d                    }|                    |           |                                }|                     |d         j        d           |                     |d         j        d	           |                     |j        d
           t                                |d                    }|                    |           |                                }|                     |d         j        d           |                     |d         j        d	           |                     |j        d
           d}t                               t                               d                    }|                    |           |                                }|                     |d         j        d           |                     |d         j        d           |                     |j        d           t                                |d                    }|                    |           |                                }|                     |d         j        d           |                     |d         j        d           |                     |j        d           d S )Nc                       e Zd ZdS )KTreeBuilderTest.test_late_tail_mix_pi_comments.<locals>.TreeBuilderSubclassNr  r"   r!   r   r  r    r  r!   r  z/<a>text<?pi1?> <!-- comment -->
<?pi2?>tail</a>T)insert_commentsr  r   r  z
tailztext z+<a>text<!-- comment -->
<?pi data?>tail</a>)
insert_piszpi datarx   ztext
)r=   r  r  r  r  r}   ry   rx   )r5   r  r  r"  r   s        r   test_late_tail_mix_pi_commentsz.TreeBuilderTest.test_late_tail_mix_pi_comments  s   	 	 	 	 	". 	 	 	 AR^^D^%I%IJJCLLNN1K0001H---)))%8%8%N%N%NOOCLLNN1K0001H---)))<R^^t^%D%DEECLLNN1I...1F+++***%8%8D%I%I%IJJCLLNN1I...1F+++*****r!   c                     t                               t                               d                     }|                    | j                   |                                }|                     |           d S Nr1  r  )r=   r  r  r  r  r  r  r5   r"  r   s      r   $test_treebuilder_elementfactory_nonez4TreeBuilderTest.test_treebuilder_elementfactory_none  s^    R^^D^%I%IJJDL!!!LLNN##A&&&&&r!   c                 X    G d dt           j                  } |            }|                     |                    d          d           t                               |          }|                    | j                   |                                }|                     |           d S )Nc                       e Zd Zd ZdS )4TreeBuilderTest.test_subclass.<locals>.MyTreeBuilderc                     |dz  S Nr   r"   r>  s     r   r  z;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobar      1ur!   Nr@   rA   rB   r  r"   r!   r   MyTreeBuilderr    #            r!   r  r   r   r  )	r=   r  r}   r  r  r  r  r  r  r5   r  tbr"  r   s        r   test_subclasszTreeBuilderTest.test_subclass  s    	 	 	 	 	BN 	 	 	 ]__2+++R((DL!!!LLNN##A&&&&&r!   c                     G d dt           j                  } |t           j        t           j                  }|                     |                    d          d           t                               |          }|                    | j                   |                    d           |	                                }| 
                    |           d S )Nc                       e Zd Zd ZdS )?TreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilderc                     |dz  S r  r"   r>  s     r   r  zFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobar  r  r!   Nr  r"   r!   r   r  r    r  r!   r  )r  r  r   r   r  z<!-- a comment--><?and a pi?>)r=   r  rq  r   r}   r  r  r  r  r  r  r  s        r   test_subclass_comment_piz(TreeBuilderTest.test_subclass_comment_pi  s    	 	 	 	 	BN 	 	 	 ]2:"%HHH2+++R((DL!!!3444LLNN##A&&&&&r!   c                    g fd}t                               |          }t                               |          }|                    | j                   |                                 |                     dg           d S )Nc                 d                         |            t                              | |          S r^   )r   r=   r|   )rU   rz   lsts     r   	myfactoryz7TreeBuilderTest.test_element_factory.<locals>.myfactory  s&    JJsOOO::c6***r!   r1  r  toplevel)r=   r  r  r  sample2r  r}   )r5   r  r  r"  r  s       @r   test_element_factoryz$TreeBuilderTest.test_element_factory  s    	+ 	+ 	+ 	+ 	+
 ^^I^66R((DL!!!zl+++++r!   c                 $   t                               |          }t                               |          }|                    | j                   |                                }|                     ||           |                     |           d S r  )r=   r  r  r  r  r  r{   r  )r5   ra   r  r"  r   s        r   _check_element_factory_classz,TreeBuilderTest._check_element_factory_class  sy    ^^C^00R((DL!!!LLNNa%%%##A&&&&&r!   c                 `     G d dt           j                  }|                     |           d S )Nc                       e Zd ZdS )@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementNr  r"   r!   r   rl  r    r  r!   rl  )r=   r|   r  )r5   rl  s     r   test_element_factory_subclassz-TreeBuilderTest.test_element_factory_subclass  sH    	 	 	 	 	
 	 	 	)))44444r!   c                     t           j        }|                     |j        d            G d d|t                    }|                     |           d S )Nr8   c                       e Zd ZdS )LTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementNr  r"   r!   r   rl  r    r  r!   rl  )r=   _Element_Pyr}   rA   r   r  )r5   baserl  s      r   )test_element_factory_pure_python_subclassz9TreeBuilderTest.test_element_factory_pure_python_subclass
  sj     ~*ABBB	 	 	 	 	j 	 	 	)))44444r!   c                      G d d          }t                                |                      }|                    | j                   |                     |                                d           d S )Nc                       e Zd ZdZd Zd ZdS )3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNc                     |||f| _         d S r^   _doctype)r5   rn   pubidsystems       r   doctypez;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctype  s    !%uf 5r!   c                     | j         S r^   r  r   s    r   r  z9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close  s
    }$r!   )r@   rA   rB   r  r  r  r"   r!   r   DoctypeParserr    s7        H6 6 6% % % % %r!   r  r  rC  z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r=   r  r  r  r}   r  )r5   r  r"  s      r   test_doctypezTreeBuilderTest.test_doctype  s    	% 	% 	% 	% 	% 	% 	% 	% ]]__55DL!!!H	I 	I 	I 	I 	Ir!   c                 T    G d d          }t                                |                       dD ]Y}|                     t          |          5  t                                ||                     d d d            n# 1 swxY w Y   Zt                                |t                               dD ]n}t                                ||t                              }|                    | j                   |                     |                                           od S )Nc                        e Zd ZdefdZd ZdS )BTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNc                 "    || _         || _        d S r^   raise_inwhat)r5   r  r  s      r   r  zKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__*  s     ( 			r!   c                 V    || j         k    r|                     | j                   d }|S )Nc                      d S r^   r"   )r   s    r   handlez^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handle1  s    Dr!   r  )r5   rn   r   s      r   __getattr__zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.  s7    4=(())DM222  r!   )r@   rA   rB   r   r  r!  r"   r!   r   RaisingBuilderr  )  s<        (,: ! ! ! !    r!   r"  r  )rG  r*   r3  ro  r  )r  )	r=   r  r  r   r2  r  r  r   r  )r5   r"  r  r"  s       r   test_builder_lookup_errorsz*TreeBuilderTest.test_builder_lookup_errors(  sr   
	 
	 
	 
	 
	 
	 
	 
	 	NN,,---> 	; 	;E''
E:: ; ;NN5$9$9:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; 	NN???@@@> 	. 	.E\\N)S)S)S\TTFKK%%%fllnn----	. 	.s   %BB	B	N)r@   rA   rB   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r#  r"   r!   r   r  r  K  s
       2G
 2G+ + +* * *(
; 
; 
;R R R- - -0"+ "+ "+H' ' '' ' '' ' ', , ,' ' '5 5 5
5 5 5I I I". . . . .r!   r  c                   D    e Zd ZdZdZdZd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )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>c                     |                      |j        d           |                      |d         j        d           |                      |d         j        d           d S )NrO   r   line22)r}   rU   ry   rD  s     r   _check_sample_elementz#XMLParserTest._check_sample_elementK  sX    '''16***1D)))))r!   c                     t                               dt                                                     }|                    | j                   |                     |                                           d S )Nr   )rE   r  )r=   r  r  r  r  r)  r  )r5   r  s     r   test_constructor_argsz#XMLParserTest.test_constructor_argsP  s_    ,,&(nn&6&6  8 8T\"""""7==??33333r!   c                      G d dt           j                  } |            }|                    | j                   |                     |                                           d S )Nc                       e Zd ZdS )-XMLParserTest.test_subclass.<locals>.MyParserNr  r"   r!   r   MyParserr.  W  r  r!   r/  )r=   r  r  r  r)  r  )r5   r/  r"  s      r   r  zXMLParserTest.test_subclassV  so    	 	 	 	 	r| 	 	 	DL!!!""6<<>>22222r!   c                     t          j                    5  t          j        dt                     t                                          }|                    | j                   |                                 d d d            d S # 1 swxY w Y   d S )Nerror)	warningscatch_warningssimplefilterr  r=   r  r  r  r  r  s     r   test_doctype_warningz"XMLParserTest.test_doctype_warning]  s    $&& 	 	!'+=>>>\\^^FKK%%%LLNNN		 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   A"BB
Bc                    d  G fddt           j                  } |            }|                     t          d          5  |                    | j                   d d d            n# 1 swxY w Y   |                                 |                                d xt          j	                    5  t          j
        dt                     t          j
        dt                      G fdd          } | |                      }|                    | j                   |                                 |                                |                     d           d d d            d S # 1 swxY w Y   d S )	Nc                       e Zd Z fdZdS )@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypec                     ||fd S r^   r"   )r5   r   r   r  s      r   r  zHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeg  s     &>r!   Nr@   rA   rB   r  r  s   r   MyParserWithDoctyper8  f  s.        * * * * * * *r!   r;  r  r1  c                       e Zd Z fdZdS ):XMLParserTest.test_subclass_doctype.<locals>.DoctypeParserc                     |||fd S r^   r"   )r5   rn   r  r  	_doctype2s       r   r  zBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypev  s    !%uf 5IIIr!   Nr:  )r?  s   r   r  r=  u  s.        6 6 6 6 6 6 6r!   r  r  r  )r=   r  r  RuntimeWarningr  r  r  r   r2  r3  r4  r  r}   )r5   r;  r"  r  r  r?  s       @@r   test_subclass_doctypez#XMLParserTest.test_subclass_doctyped  sL   	* 	* 	* 	* 	* 	* 	*", 	* 	* 	*
 %$&&"">9== 	& 	&KK%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&(#####9$&& 	M 	M!'+=>>>!'>:::6 6 6 6 6 6 6 6 6 6
 )(@@@FKK%%%LLNNNh'''YLM M M	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	M 	Ms%   A++A/2A/6B1E44E8;E8c                 f   t          j                    5  t          j        dt                     t          j        dt                      G d dt
          j                  } |            }|                    | j                   |	                                 ddd           dS # 1 swxY w Y   dS )z:Ensure that ordinary usage is not deprecated (Issue 19176)r1  c                       e Zd ZdS )DXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr  r"   r!   r   MyParserWithoutDoctyperD    s        r!   rE  N)
r2  r3  r4  r  r@  r=   r  r  r  r  )r5   rE  r"  s      r   test_inherited_doctypez$XMLParserTest.test_inherited_doctype  s    $&& 	 	!'+=>>>!'>:::       ++--FKK%%%LLNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   BB&&B*-B*c                 t   t                               t                                                     }|                    | j                   |                                }|                     |j        d           |                     |j        d         d           |                     |j	        d           d S )Nr  moneyr   u
   $£€𐅻)
r=   r  r  r  sample3r  r}   rU   rz   ry   r  s      r   test_parse_stringzXMLParserTest.test_parse_string  s    R^^%5%566DL!!!LLNN((('*,CDDD!899999r!   N)r@   rA   rB   r  r  rI  r)  r+  r  r5  rA  rF  rJ  r"   r!   r   r%  r%  B  s        -GGMG* * *
4 4 43 3 3  M M M<	 	 	: : : : :r!   r%  c                       e Zd Zd ZdS )NamespaceParseTestc                    ddd}t                               t                    }|                     t	          |                    d|                    d           |                     t	          |                    d|                    d           |                     t	          |                    d|                    d           d S )	Nhellor   )hr!  z{hello}tabler   z.//{hello}tdr   z.//{foo}name)r=   r   SAMPLE_XML_NS_ELEMSr}   r~   r   )r5   r  rh  s      r   test_find_with_namespacez+NamespaceParseTest.test_find_with_namespace  s    E**mm/00S[[??@@!DDDS[[??@@!DDDS[[??@@!DDDDDr!   N)r@   rA   rB   rQ  r"   r!   r   rL  rL    s(        E E E E Er!   rL  c                   V    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd ZdS )ElementSlicingTestc                     d |D             S )Nc                     g | ]	}|j         
S r"   rT   )rW   r   s     r   rX   z1ElementSlicingTest._elem_tags.<locals>.<listcomp>  s    (((!(((r!   r"   )r5   elemlists     r   
_elem_tagszElementSlicingTest._elem_tags  s    ((x((((r!   c                 F    |                      t          |                    S r^   )rW  r   rr  s     r   _subelem_tagsz ElementSlicingTest._subelem_tags  s    tDzz***r!   c                     t                               d          }t          |          D ] }t                               |d|z             !|S )zxCreate an Element with a tag 'a', with the given amount of children
           named 'a0', 'a1' ... and so on.

        r   za%s)r=   r|   r   rp  )r5   numchildrenr   r   s       r   _make_elem_with_childrenz+ElementSlicingTest._make_elem_with_children  sJ    
 JJsOO{## 	( 	(AMM!UQY''''r!   c                 .   |                      d          |                     d         j        d           |                     d         j        d           |                     t          fd           |                     t          fd           d S )Nr   r   a1a8c                       d         S )N   r"   ry  s   r   r  z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>  s    ae r!   c                       d         S )Nir"   ry  s   r   r  z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>  s    af r!   )r\  r}   rU   r   
IndexErrorrD  s    @r   test_getslice_single_indexz-ElementSlicingTest.test_getslice_single_index  s    ))"--14(((2D)))*mmmm444*nnnn55555r!   c                    |                      d          }|                     |                     |dd                    g d           |                     |                     |dd                   g d           |                     |                     |dd                   g d           |                     |                     |dd                   ddg           |                     |                     |dd                   ddg           |                     |                     |d d	                   d
dg           d S )Nr  r  )a3a4a5   r  rg  rh  r  r   a0r^  )r\  r}   rW  rD  s     r   test_getslice_rangez&ElementSlicingTest.test_getslice_range  s8   ))!,,122//1C1C1CDDD1Q3002D2D2DEEE1R4113E3E3EFFF1Q3004,???1R411D$<@@@2A2//$>>>>>r!   c           	         |                      d          }|                     |                     |ddd                   ddg           |                     |                     |d d d                   g d           |                     |                     |d d d                   ddg           |                     |                     |dd d                   d	dg           |                     |                     |dd t          j                           d
g           |                     |                     |dd t          j        dz                     d
g           d S )Nr      r   r`  a9r  )rk  rg  a6ro  rk  r^  rg  @   r\  r}   rW  re   maxsizerD  s     r   test_getslice_stepsz&ElementSlicingTest.test_getslice_steps  sF   ))"--1R633dD\BBB33Q3002J2J2JKKK33Q3004,???14a411D$<@@@1>ck>):;;dVDDD1+=ck2o+=)>??$HHHHHr!   c           	         |                      d          }|                     |                     |d d d                   g d           |                     |                     |d d d                   ddg           |                     |                     |dd t          j                            dg           |                     |                     |dd t          j         dz
                     dg           |                     |                     |dd t          j         d	z                     dg           d S )
Nrv  r  )rg  a2r^  rk  r_  rg  r^  r  r   rq  rr  rD  s     r   test_getslice_negative_stepsz/ElementSlicingTest.test_getslice_negative_steps  s$   ))!,,44R4113K3K3KLLL44R411D$<@@@1?s{l?);<<tfEEE1+<s{l1n+<)=>>GGG1+>s{lB.>+>)?@@4&IIIIIr!   c                 @   |                      d          }|dd= |                     |                     |          ddg           |                      d          }|dd = |                     |                     |          g            |                      d          }|d d d= |                     |                     |          g            |                      d          }|d d d= |                     |                     |          ddg           |                      d          }|d	d d= |                     |                     |          ddg           |                      d          }|d d d= |                     |                     |          d
g           d S )Nrv  r   r   rv  rg  r  r_  rk  r   r^  )r\  r}   rY  rD  s     r   test_delslicez ElementSlicingTest.test_delslice  s   ))!,,acF++A..t===))!,,abbE++A..333))!,,dddG++A..333))!,,dddG++A..t===))!,,addG++A..t===))!,,cccF++A..77777r!   c                    |                      d          }t                              d          |d<   |                     |                     |          g d           t                              d          |d<   |                     |                     |          g d           |                     t                    5  t                              d          |d	<   d d d            n# 1 swxY w Y   |                     t                    5  t                              d          |d
<   d d d            n# 1 swxY w Y   |                     |                     |          g d           d S )Nrv  r   r   rk  r   rv  rg  r   r_  )rk  r   r   rg  r   r  )r\  r=   r|   r}   rY  r   rd  rD  s     r   test_setslice_single_indexz-ElementSlicingTest.test_setslice_single_index  s   ))!,,zz#!++A..0G0G0GHHH

3"++A..0F0F0FGGGz** 	# 	#::c??AaD	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#z** 	$ 	$JJsOOAbE	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$++A..0F0F0FGGGGGs$    C**C.1C.D99D= D=c                 >   |                      d          }d t          d          D             |dd<   |                     |                     |          g d           |                      d          }t                              d          g|dd<   |                     |                     |          g d           |                      d          }d	 t          d          D             |dd<   |                     |                     |          g d
           d S )Nrv  c                 H    g | ]}t                               d |z             S zb%srU  rW   r   s     r   rX   z:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>   (    :::A"**UQY'':::r!   r   r   r  )rk  b0b1rg  r   )rk  r   rg  c                 H    g | ]}t                               d |z             S r  rU  r  s     r   rX   z:ElementSlicingTest.test_setslice_range.<locals>.<listcomp>  r  r!   )rk  r  r  b2rg  )r\  r   r}   rY  r=   r|   rD  s     r   test_setslice_rangez&ElementSlicingTest.test_setslice_range  s   ))!,,::q:::!A#++A..0H0H0HIII))!,,**S//"!A#++A..0A0A0ABBB))!,,::q:::!A#++A..0N0N0NOOOOOr!   c                    |                      d          }d t          d          D             |ddd<   |                     |                     |          g d           |                      d          }|                     t
                    5  t                              d          g|ddd<   d d d            n# 1 swxY w Y   |                     t
                    5  d t          d	          D             |ddd<   d d d            n# 1 swxY w Y   |                     t
                    5  g |ddd<   d d d            n# 1 swxY w Y   |                     |                     |          g d
           |                      d          }t                              d          g|dd t          j	        <   |                     |                     |          g d           t                              d          g|dd t          j	        dz  <   |                     |                     |          g d           d S )Nr  c                 H    g | ]}t                               d |z             S r  rU  r  s     r   rX   z:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>  s(    <<<aBJJuqy))<<<r!   r   r   r  )rk  r  rv  r  rh  ri  r   c                 H    g | ]}t                               d |z             S r  rU  r  s     r   rX   z:ElementSlicingTest.test_setslice_steps.<locals>.<listcomp>  s(    @@@!

519--@@@r!   r  )rk  r^  rv  rg  rh  ri  rv  r{  r   rq  rk  r   rv  rg  
r\  r   r}   rY  r   r   r=   r|   re   rs  rD  s     r   test_setslice_stepsz&ElementSlicingTest.test_setslice_steps  s   ))!,,<<588<<<!Aa%++A..0T0T0TUUU))!,,z** 	) 	)

3(Aa!eH	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	)z** 	A 	A@@uQxx@@@Aa!eH	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	Az** 	 	Aa!eH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	++A..0T0T0TUUU))!,,ZZ__-!.S[.++A..0G0G0GHHH!#C 1!
S["_
++A..0G0G0GHHHHH6   "B==CC" DDD3	EEEc                 @   |                      d          }d t          d          D             |ddd<   |                     |                     |          g d           |                      d          }|                     t
                    5  t                              d          g|ddd<   d d d            n# 1 swxY w Y   |                     t
                    5  d t          d	          D             |ddd<   d d d            n# 1 swxY w Y   |                     t
                    5  g |ddd<   d d d            n# 1 swxY w Y   |                     |                     |          g d
           |                      d          }t                              d          g|dd t          j	         <   |                     |                     |          g d           t                              d          g|dd t          j	         dz
  <   |                     |                     |          g d           t                              d          g|dd t          j	         dz  <   |                     |                     |          g d           d S )Nrv  c                 H    g | ]}t                               d |z             S r  rU  r  s     r   rX   zCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>!  s(    ===qRZZ	**===r!   r   r   r  )rk  r  r  rg  r   c                 H    g | ]}t                               d |z             S r  rU  r  s     r   rX   zCElementSlicingTest.test_setslice_negative_steps.<locals>.<listcomp>(  s(    AAA1EAI..AAAr!   r  )rk  r^  rv  rg  r   r{  r   r  r   rq  )rk  r   rv  rg  r  rD  s     r   test_setslice_negative_stepsz/ElementSlicingTest.test_setslice_negative_steps  sE   ))!,,==E!HH===!Ab&	++A..0H0H0HIII))!,,z** 	* 	*C)Aa"fI	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*z** 	B 	BAAaAAAAa"fI	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	B 	Bz** 	 	Aa"fI	 	 	 	 	 	 	 	 	 	 	 	 	 	 	++A..0H0H0HIII))!,, jjoo.!/ck\/++A..0G0G0GHHH "

30!
ck\!^
++A..0G0G0GHHH"$**S//!2!
ck\2
++A..0G0G0GHHHHHr  N)r@   rA   rB   rW  rY  r\  re  rl  rt  rw  ry  r}  r  r  r  r"   r!   r   rS  rS    s        ) ) )+ + +  6 6 6? ? ?I I IJ J J8 8 82H H HP P PI I I(I I I I Ir!   rS  c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Z G d d          Zd Zd Zd Zd Zd Zd Zd ZdS )IOTestc           	      	   t                               d          }d|_        |                     t	          |          d           dD ]}|                     |          5  |                     t	          ||          d           |                     t	          ||                                          d           d d d            n# 1 swxY w Y   dD ]}|                     |          5  |                     t	          ||          d|z                      |                     |                                }|                     t	          ||          d|z                      |                     d d d            n# 1 swxY w Y   t                               d          }d	|_        |                     t	          |          d
           |                     t	          |d          d           |                     t	          |d          d           dD ]=}|                     t	          ||          d|z                      |                     >t                               d          }d	|j        d<   |                     t	          |          d           |                     t	          |d          d           |                     t	          |d          d           dD ]=}|                     t	          ||          d|z                      |                     >t                               d          }d|_        |                     t	          |          d           |                     t	          |d          d           |                     t	          |d          d           dD ]=}|                     t	          ||          d|z                      |                     >t                               d          }d|j        d<   |                     t	          |          d           |                     t	          |d          d           |                     t	          |d          d           dD ]=}|                     t	          ||          d|z                      |                     >d S )NrU   r  z<tag>abc</tag>)r   r  r  s   <tag>abc</tag>)r  r  utf-32z2<?xml version='1.0' encoding='%s'?>
<tag>abc</tag>z<&"'>z<tag>&lt;&amp;"'&gt;</tag>r   s   <tag>&lt;&amp;"'&gt;</tag>r  z><?xml version='1.0' encoding='%s'?>
<tag>&lt;&amp;"'&gt;</tag>r   z"<tag key="&lt;&amp;&quot;'&gt;" />s"   <tag key="&lt;&amp;&quot;'&gt;" />zF<?xml version='1.0' encoding='%s'?>
<tag key="&lt;&amp;&quot;'&gt;" />u   åöö<>u   <tag>åöö&lt;&gt;</tag>s   <tag>åöö&lt;&gt;</tag>s%   <tag>&#229;&#246;&#246;&lt;&gt;</tag>u=   <?xml version='1.0' encoding='%s'?>
<tag>åöö&lt;&gt;</tag>u   <tag key="åöö&lt;&gt;" />s   <tag key="åöö&lt;&gt;" />s(   <tag key="&#229;&#246;&#246;&lt;&gt;" />)r  r  r  r  r  u@   <?xml version='1.0' encoding='%s'?>
<tag key="åöö&lt;&gt;" />)	r=   r|   ry   r}   rQ   r  upperr)   rz   )r5   rL   encr  s       r   r@  zIOTest.test_encoding7  s   zz%  	4*:;;;( 	+ 	+Cc"" + +  4#!>!>!>)+ + +  4#))++!F!F!F)+ + ++ + + + + + + + + + + + + + +
 6 	@ 	@Cc"" @ @  4#!>!>!>*,/017> > > 		  4%!@!@!@*,12396#;;@ @ @@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ zz%  	4*GHHH4':::.	0 	0 	04*===.	0 	0 	05 	G 	GCYtc:::3589:@&++G G G G zz%  &E4*OPPP4':::6	8 	8 	84*===6	8 	8 	85 	P 	PCYtc:::<>ABCI6#;;P P P P zz%  $	4*KLLL4':::>	@ 	@ 	@4*===8	: 	: 	:5 	E 	ECYtc:::13678>sE E E E zz%  -E4*NOOO4':::A	C 	C 	C4*===;	= 	= 	=M 	J 	JCYtc:::68;<=CVC[[J J J J	J 	Js&   ACC	C	,BFF	
F	c                    |                      t          j        t                     t                              t                              d                    }|                    t                     t          t          d          5 }| 	                    |
                                d           d d d            d S # 1 swxY w Y   d S )N   <site>ø</site>rZ     <site>&#248;</site>)rf  r   rg  r   r=   r/   r   rI   r  r}   r  r5   rP   r!  s      r   test_write_to_filenamezIOTest.test_write_to_filename|  s    	(&111~~bff%<==>>

6&$ 	C1QVVXX'ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs   )B==CCc                    |                      t          j        t                     t                              t                              d                    }|                    t          d           t          t          d          5 }| 	                    |
                                d           d d d            n# 1 swxY w Y   |                    t          d           t          t          d          5 }| 	                    |
                                t          d                     d d d            d S # 1 swxY w Y   d S )Nr  r   r  rZ     <site>ø</site>r  :   <?xml version='1.0' encoding='ISO-8859-1'?>
<site></site>)rf  r   rg  r   r=   r/   r   rI   r  r}   r  r+   r  s      r   $test_write_to_filename_with_encodingz+IOTest.test_write_to_filename_with_encoding  s   	(&111~~bff%<==>>

6G
,,,&$ 	E1QVVXX'CDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	

6L
111&$ 	81QVVXX{6(7 (7 8 8 8	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8 	8s$   	)B>>CC:6D==EEc                 2   |                      t          j        t                     t	          t          d          5 }|j        }d d d            n# 1 swxY w Y   t          j        t                     t                              t                              d                    }|	                    t          d           t	          t          d          5 }| 
                    |                                d           d d d            d S # 1 swxY w Y   d S )Nr  r  rC   r  rZ  r  )rf  r   rg  r   r  rE   r=   r/   r   rI   r}   r  )r5   r!  rE   rP   s       r   !test_write_to_filename_as_unicodez(IOTest.test_write_to_filename_as_unicode  sj   	(&111&# 	"!zH	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"   ~~bff%<==>>

6I
...&$ 	A1QVVXX'?@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	As#   AAA)DDDc                    |                      t          j        t                     t                              t                              d                    }t          t          dd          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            n# 1 swxY w Y   t          t          ddd	
          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            n# 1 swxY w Y   t          t          dd          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr  r  r   r  rC   rZ  r  r'  xmlcharrefreplace)rE   errorsr  r  s   <site></site>rf  r   rg  r   r=   r/   r   r  rI   rb  rc  r}   r  r  s      r   test_write_to_text_filezIOTest.test_write_to_text_file  s   	(&111~~bff%<==>>&#000 	'AJJq9J---QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	E1QVVXX'CDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E &#8KLLL 	'PQJJq9J---QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	D1QVVXX(BCCC	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D 	D &#555 	'JJq9J---QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	A1QVVXX'?@@@	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	A 	Asl   /2B--B14B1)DD	D%2E##E'*E')F88F<?F<2HHH8)I..I25I2c                    |                      t          j        t                     t                              t                              d                    }t          t          d          5 }|                    |           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )Nr  r^  rZ  r  r  r  s      r   test_write_to_binary_filez IOTest.test_write_to_binary_file  sc   	(&111~~bff%<==>>&$ 	'1JJqMMMQX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	C1QVVXX'ABBB	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	C 	Cs$   -0B))B-0B-	)C??DDc                    |                      t          j        t                     t                              t                              d                    }t          t          d          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            n# 1 swxY w Y   t          t          d          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d           d d d            d S # 1 swxY w Y   d S )	Nr  r^  r   r  rZ  r  r  r  r  r  s      r   'test_write_to_binary_file_with_encodingz.IOTest.test_write_to_binary_file_with_encoding  s   	(&111~~bff%<==>>&$ 	'1JJq7J+++QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	E1QVVXX'CDDD	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E &$ 	'1JJq<J000QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	71QVVXX67 7 7	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7sH   -2B++B/2B/)D  DD 2EE"%E">)F44F8;F8c                    |                      t          j        t                     t                              t                              d                    }t          t          d          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d                    d                     d d d            n# 1 swxY w Y   t          t          dd          5 }|                    |d           | 	                    |j
                   d d d            n# 1 swxY w Y   t          t          d          5 }|                     |                                d                    d                     d d d            d S # 1 swxY w Y   d S )	Nr  r^  r  r  rZ  u7   <?xml version='1.0' encoding='utf-16'?>
<site>ø</site>r   )	buffering)rf  r   rg  r   r=   r/   r   r  rI   rb  rc  r}   r  r)   r  s      r   "test_write_to_binary_file_with_bomz)IOTest.test_write_to_binary_file_with_bom  s   	(&111~~bff%<==>>&$ 	'1JJq8J,,,QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	>1QVVXX,,2F8,<,<> > >	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>
 &$!,,, 	'JJq8J,,,QX&&&	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' &$ 	>1QVVXX,,2F8,<,<> > >	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	> 	>sH   -2B++B/2B/<DDD52E33E7:E7<GG #G c                     t                                           }t          j        d          }|                    |           |                     |                                j        d           d S Nz"<?xml version="1.0"?><site></site>site)r=   r/   rF   rH   r  r}   r   rU   r5   rP   r   s      r   test_read_from_stringiozIOTest.test_read_from_stringio  sZ    ~~EFF

6+V44444r!   c                    t                               t                               d                    }t          j                    }|                    |d           |                     |                                d           d S Nr  rC   r  )r=   r/   r   rF   rH   rI   r}   rJ   r  s      r   test_write_to_stringiozIOTest.test_write_to_stringio  sh    ~~bff%<==>>

6I
...**,CDDDDDr!   c                     t                                           }t          j        d          }|                    |           |                     |                                j        d           d S Ns"   <?xml version="1.0"?><site></site>r  )r=   r/   rF   rG   r  r}   r   rU   r5   rP   r  s      r   test_read_from_bytesiozIOTest.test_read_from_bytesio  sW    ~~jBCC

3+V44444r!   c                 
   t                               t                               d                    }t          j                    }|                    |           |                     |                                d           d S Nr  r  )r=   r/   r   rF   rG   rI   r}   rJ   r  s      r   test_write_to_bytesiozIOTest.test_write_to_bytesio  s_    ~~bff%<==>>jll

3)CDDDDDr!   c                       e Zd ZdS )IOTest.dummyNr  r"   r!   r   dummyr    s        r!   r  c                 $   t          j        d          }|                                 }|j        |_        t                                          }|                    |           |                     |                                j	        d           d S r  )
rF   rH   r  r  r=   r/   r  r}   r   rU   )r5   r   readerrP   s       r   test_read_from_user_text_readerz&IOTest.test_read_from_user_text_reader  sp    EFFk~~

6+V44444r!   c                 N   t                               t                               d                    }t          j                    }|                                 }|j        |_        |                    |d           |                     |                                d           d S r  )	r=   r/   r   rF   rH   r  rI   r}   rJ   )r5   rP   r   writers       r   test_write_to_user_text_writerz%IOTest.test_write_to_user_text_writer  s~    ~~bff%<==>>|

6I
...**,CDDDDDr!   c                 V   t          j        d          }|                                 }|j        |_        t                                          }|                    |           |                     |                                j	        d           t                                          }d S r  )
rF   rG   r  r  r=   r/   r  r}   r   rU   )r5   r  r  rP   s       r   !test_read_from_user_binary_readerz(IOTest.test_read_from_user_binary_reader	  s}    jBCCh~~

6+V444~~r!   c                 J   t                               t                               d                    }t          j                    }|                                 }|j        |_        |                    |           |                     |                                d           d S r  )	r=   r/   r   rF   rG   r  rI   r}   rJ   r5   rP   r  r  s       r    test_write_to_user_binary_writerz'IOTest.test_write_to_user_binary_writer  sx    ~~bff%<==>>jlly

6)CDDDDDr!   c                    t                               t                               d                    }t          j                    }|                                 }|j        |_        d |_        |j        |_        |                    |d           | 	                    |
                                d                    d                     d S )Nz<site />c                      dS r  r"   r"   r!   r   r  zBIOTest.test_write_to_user_binary_writer_with_bom.<locals>.<lambda>  s    $ r!   r  r  z0<?xml version='1.0' encoding='utf-16'?>
<site />)r=   r/   r   rF   rG   r  rI   seekabletellr}   rJ   r)   r  s       r   )test_write_to_user_binary_writer_with_bomz0IOTest.test_write_to_user_binary_writer_with_bom  s    ~~bff^4455jlly&,h

6H
---%vh//	1 	1 	1 	1 	1r!   c           	         t                               d          }|                     t                               |d          d                    t                               |d                               |                     t                               |d          d                    t                               |d                               d S )Nz<tag>foo</tag>rC   rP  r  r!   )r=   r   r}   r	  r*  r+  r  s     r   test_tostringlist_invariantz"IOTest.test_tostringlist_invariant&  s    }}-..KKi((GGBOOD)4455	7 	7 	7 	KKh''HHR__T84455	7 	7 	7 	7 	7r!   c                 \   t                               d          }|                     t                               |d          d           |                     t                               |dd          d           |                     t                               |dd          d           d S )Nz<tag>a<x />b<y></y>c</tag>rC   z<tag>a<x />b<y />c</tag>T)short_empty_elementsFz<tag>a<x></x>b<y></y>c</tag>)r=   r   r}   r	  r  s     r   test_short_empty_elementsz IOTest.test_short_empty_elements/  s    }}9::KKi((&	( 	( 	( 	KKidKCC&	( 	( 	( 	KKieKDD*	, 	, 	, 	, 	,r!   N)r@   rA   rB   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  6  sx       CJ CJ CJJC C C8 8 8	A 	A 	AA A A*C C C7 7 7"> > >(5 5 5E E E5 5 5E E E       5 5 5E E E     E E E
1 
1 
17 7 7
, 
, 
, 
, 
,r!   r  c                   &    e Zd Zd Zd Zd Zd ZdS )ParseErrorTestc                 j    |                      t                                          t                     d S r^   )r{   r=   re  r  r   s    r   r  zParseErrorTest.test_subclass=  s&    bmmoo{;;;;;r!   c                 x    	 t                               |           d S # t           j        $ r}|cY d }~S d }~ww xY wr^   )r=   r   re  )r5   rZ  r   s      r   
_get_errorzParseErrorTest._get_error@  sO    	MM!} 	 	 	HHHHHH	s    9499c                    |                      |                     d          j        d           |                      |                     d          j        d           |                      |                     d          j        d           d S )Nr   )r   r   z<tag>&foo;</tag>)r   r  zfoobar<)r   r  )r}   r  positionr   s    r   test_error_positionz"ParseErrorTest.test_error_positionF  sx    //8&AAA);<<EvNNN33<fEEEEEr!   c                     dd l mc mc m} |                     |                     d          j        |j        |j                            d S )Nr   r   )	xml.parsers.expat.errorsparsersexpatr  r}   r  codecodesXML_ERROR_SYNTAX)r5   ERRORSs     r   test_error_codezParseErrorTest.test_error_codeK  sf    111111111111//4V45	7 	7 	7 	7 	7r!   N)r@   rA   rB   r  r  r  r  r"   r!   r   r  r  <  sS        < < <  F F F
7 7 7 7 7r!   r  c                       e Zd Zd ZdS )KeywordArgsTestc                    t                               d          }|                     |                    dd           |                    dd                      |                     |                    dd d           |                    dd d                      |                     |                    dd           |                    dd                      |                     t          |                    dd                     t          |                    dd                                |                     t                               d          j	        i            t                               dt          dd                    t                               dt          dd                    t                               dt          d	          d
          t                               ddd          t                               dt          dd          dd          g}|D ]G}|                     |j        d           |                     |j	        t          dd                     Ht                               |d         dddi          }|                     |j	        d         d           |                     t          d          5  t                               dd           d d d            n# 1 swxY w Y   |                     t          d          5  t                               dd           d d d            d S # 1 swxY w Y   d S )Nz
<a>foo</a>r   )pathr_  )r  r   r_  #r   )r  r  )rz   )r  )r  r   r  key1value1zmust be dict, not strzI'm not a dict)r=   r   r}   r   r   r   r   r   r|   rz   rj   rU   rp  r  r'  )r5   r   elementsr   r   s        r   test_issue14818zKeywordArgsTest.test_issue14818T  s|   FF<  T**ST::	< 	< 	<Ct44dtLL	N 	N 	N3--==	? 	? 	?ajjd3344ajjcdjCCDD	F 	F 	F 	C/444JJsDce44455JJs4SU#;#;#;J<<JJsDcNNNuJ55JJsJ//JJsDce44435JII
  	A 	AAQUC(((QXt'?'?'?@@@@]]8A;&(9K]LL6*H555##I/FGG 	. 	.JJs,---	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.##I/FGG 	5 	5JJs#3J444	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5 	5s$   L  LL&MMMN)r@   rA   rB   r  r"   r!   r   r  r  Q  s#        5 5 5 5 5r!   r  c                       e Zd Zd Zd ZdS )NoAcceleratorTestc                 <    t           st          j        d          d S )Nzonly for the Python version)r_   r  r  r   s    r   rF  zNoAcceleratorTest.setUpv  s)     	C#$ABBB	C 	Cr!   c                     |                      t          j        j        t          j                   |                      t          j        j        t          j                   d S r^   )r{   r_   r|   r  typesFunctionTyper  r   s    r   test_correct_import_pyETz*NoAcceleratorTest.test_correct_import_pyET{  sF     	dl3U5GHHHdn5u7IJJJJJr!   N)r@   rA   rB   rF  r  r"   r!   r   r  r  u  s:        C C C
K K K K Kr!   r  c                 &    t          j        | fi |S r^   )r_   canonicalize)r  rN   s     r   c14n_roundtripr    s    S,,G,,,r!   c                   $    e Zd ZdZd Zd Zd ZdS )C14NTestNc                 ,   |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d	          d
           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           d}|                      t          |          |           d}|                      t          |          |           d}|                      t          |          |           d S )Nz<doc/>z<doc></doc>z<doc xmlns='uri'/>z<doc xmlns="uri"></doc>z <prefix:doc xmlns:prefix='uri'/>z,<prefix:doc xmlns:prefix="uri"></prefix:doc>z+<doc xmlns:prefix='uri'><prefix:bar/></doc>z7<doc><prefix:bar xmlns:prefix="uri"></prefix:bar></doc>z<elem xmlns:wsu='http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd' xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/' />z<elem></elem>z*<doc>Hello, world!<!-- Comment 1 --></doc>z<doc>Hello, world!</doc>z<value>&#x32;</value>z<value>2</value>zG<compute><![CDATA[value>"0" && value<"10" ?"valid":"error"]]></compute>zI<compute>value&gt;"0" &amp;&amp; value&lt;"10" ?"valid":"error"</compute>zS<compute expr='value>"0" &amp;&amp; value&lt;"10" ?"valid":"error"'>valid</compute>z{<compute expr="value>&quot;0&quot; &amp;&amp; value&lt;&quot;10&quot; ?&quot;valid&quot;:&quot;error&quot;">valid</compute>z7<norm attr=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>z/<norm attr=" '    &#xD;&#xA;&#x9;   ' "></norm>z6<normNames attr='   A   &#x20;&#13;&#xa;&#9;   B   '/>z=<normNames attr="   A    &#xD;&#xA;&#x9;   B   "></normNames>z7<normId id=' &apos;   &#x20;&#13;&#xa;&#9;   &apos; '/>z1<normId id=" '    &#xD;&#xA;&#x9;   ' "></normId>z5<X xmlns="http://nps/a"><Y targets="abc,xyz"></Y></X>zJ<X xmlns="http://nps/a"><Y xmlns="http://nsp/b" targets="abc,xyz"></Y></X>zN<X xmlns="http://nps/a"><Y xmlns:b="http://nsp/b" b:targets="abc,xyz"></Y></X>)r}   r  r5   r  s     r   test_simple_roundtripzC14NTest.test_simple_roundtrip  s]   11=AAA(<==)	+ 	+ 	+(JKK:	< 	< 	<(UVVE	G 	G 	G  )M  N  N	 	 	 	(TUU&	( 	( 	((?@@	  	  	 (qrrW	Y 	Y 	Y  )B  C  C J	K 	K 	K(abb?	A 	A 	A(`aaK	M 	M 	M(abbA	C 	C 	C F,,c222Z,,c222^,,c22222r!   c                    t          j        d          }|                     t          |d          d           |                     t          |ddg          d           |                     t          |ddg	          d
           |                     t          |ddgdg          d           |                     t          |dddg	          d           |                     t          |ddg          d           |                     t          |dddg	          d           |                     t          |ddg          d           d S )Nz        <root xmlns:x="http://example.com/x">
            <a x:attr="attrx">
                <b>abtext</b>
            </a>
            <b>btext</b>
            <c>
                <x:d>dtext</x:d>
            </c>
        </root>
        T)
strip_textz<root><a xmlns:x="http://example.com/x" x:attr="attrx"><b>abtext</b></a><b>btext</b><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>z{http://example.com/x}attr)r  exclude_attrszc<root><a><b>abtext</b></a><b>btext</b><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>z{http://example.com/x}d)r  exclude_tagszb<root><a xmlns:x="http://example.com/x" x:attr="attrx"><b>abtext</b></a><b>btext</b><c></c></root>)r  r  r  z4<root><a><b>abtext</b></a><b>btext</b><c></c></root>r   r   zC<root><c><x:d xmlns:x="http://example.com/x">dtext</x:d></c></root>)r  za<root>
    
    
    <c>
        <x:d xmlns:x="http://example.com/x">dtext</x:d>
    </c>
</root>zI<root><a xmlns:x="http://example.com/x" x:attr="attrx"></a><c></c></root>zu<root>
    <a xmlns:x="http://example.com/x" x:attr="attrx">
        
    </a>
    
    <c>
        
    </c>
</root>)r  r  r}   r  r  s     r   test_c14n_exclusionzC14NTest.test_c14n_exclusion  s   o 
 
 
 	34000	 	 	 	34@\?]^^^	 	 	 	34?X>YZZZ	 	 	 	34@\?])B(CE E E	 	 	 	34sCjIII	 	 	
 	3c3Z888	 	 	 	34?XZ]>^___	 	 	 	3.G-MNNN
	 
	 
	 
	 
	r!   c                    t          dd          }t          t          j        j        |          d t          t          j        |                    D             d D             }fdD             fd|D             }|                     dt          d	 |	                                D                                  d+d
}|
                                D ]\  }}|D ]\  }} ||d          dk    }	 ||d          dk    }
 ||d          dk    }d|v rWd |d         d                             d          D             }d |d         d                             d          D             }nd x}}d                    d t          |
                                          D                       }|                     | d| d          5  |dk    r|s|                     d|            |dk    r|s|                     d|            d|v r:|d         d                             d          	 |                     d|             |dz             }|d k    rt           d!          d"          5 }t          |d"          5 }t!          j        |                                                    d#|                                                    }d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t(                              ||	|
|||$          }t           |dz             d%d&'          5 }|                                }|d(k    r,|                    d)d*          }|                    d)d*          }d d d            n# 1 swxY w Y   |                     ||           d d d            n# 1 swxY w Y   d S ),Nzc14n-20r   r   c                 L    g | ]!}|                     d           |dd         "S ).xmlNr  )endswithrW   filenames     r   rX   z+C14NTest.test_xml_c14n2.<locals>.<listcomp>  sB     / / /8%%f--/#2# / / /r!   c                 <    g | ]}|                     d           |S )in)
startswithr	  s     r   rX   z+C14NTest.test_xml_c14n2.<locals>.<listcomp>  s<     
 
 
!""4((

 
 
r!   c           	          i | ]Z}|                     d           |d t                               |          dz                                             D             [S )c14nc                     i | ]>}|j                             d           d         |j        pd                                |f?S )}r  rP  )rU   splitry   r  )rW   options     r   
<dictcomp>z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<dictcomp>  sY         
  %%b)V[->B,E,E,G,G+P  r!   r  )r  r=   r  r   )rW   r
  	full_paths     r   r  z+C14NTest.test_xml_c14n2.<locals>.<dictcomp>  s     
 
 
 ""6**
   !hhyy':':V'CDDLLNN  
 
 
r!   c                 2    i | ]fd D             S )c                     g | ]]}|                     d  d          rB|                    dd          d         v 9||                    dd          d                  f^S )out_r.  r   r  )r  rsplit)rW   r
  configs
input_files     r   rX   z6C14NTest.test_xml_c14n2.<locals>.<dictcomp>.<listcomp>  s       &&';j';';';<< OOC++B/7:: 78??3#:#:2#>?@ ;::r!   r"   )rW   r  r  filess    @r   r  z+C14NTest.test_xml_c14n2.<locals>.<dictcomp>  sW     
 
 
        %  
 
 
r!      c                     g | ]	}|D ]}|
S r"   r"   )rW   output_filesoutput_files      r   rX   z+C14NTest.test_xml_c14n2.<locals>.<listcomp>&  s=     "- "- "-(+"- "- "- "- "- "-r!   c                 >    |                      ||df          d         S )Nr"   r   rl   )configoption_namer   s      r   
get_optionz+C14NTest.test_xml_c14n2.<locals>.get_option*  s    ::kGR=99!<<r!   IgnoreCommentstrueTrimTextNodesPrefixRewrite
sequential
QNameAwarec                 j    g | ]0}d |                     d           d|                     d           1S {NSr  Namer"  r  s     r   rX   z+C14NTest.test_xml_c14n2.<locals>.<listcomp>6  sL        >RVVD\\==RVVF^^==  r!   r   z/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrc                 j    g | ]0}d |                     d           d|                     d           1S r-  r"  r  s     r   rX   z+C14NTest.test_xml_c14n2.<locals>.<listcomp>;  sL        >RVVD\\==RVVF^^==  r!   z){http://www.w3.org/2010/xml-c14n2}Element,c              3   n   K   | ]0\  }\  }}| d |pd                     d |D                        V  1dS )=r2  c              3   V   K   | ]$}|j                             d           d         V  %dS )r  r  N)rU   r  )rW   r   s     r   	<genexpr>z4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>E  s5      /W/WC0@0@0D/W/W/W/W/W/Wr!   N)r*  )rW   rn   r   r  s       r   r6  z*C14NTest.test_xml_c14n2.<locals>.<genexpr>D  sm       ( (//uh YYeWsxx/W/Wh/W/W/W'W'WYY( ( ( ( ( (r!   ()
inNsRedeclz2Redeclared namespace handling is not supported in inNsSuperfluousz.{http://www.w3.org/2010/xml-c14n2}XPathElementz2QName rewriting in XPath text is not supported in r  inC14N5z	world.txtrZ  s   &ent2;)	from_filewith_commentsr  rewrite_prefixesqname_aware_tagsqname_aware_attrsrr  r  inC14N3z attr="default"rP  r^   )r	   r   r'   r  r*  r
  listdirr}   r~   valuesr   r   r  r  r   r  rF   rG   r  r&   r=   r  )r5   datadirinput_filestestsr%  r  r  r   r#  keep_commentsr  r>  qattrsqtagsconfig_descrr!  entity_filery   r   r  r  r  s                      @@@r   test_xml_c14n2zC14NTest.test_xml_c14n2  s4   9];;;BGL'22	/ /vbj6I6I/J/J / / /
 
%*
 
 

 
 
 
 "
 
 

 
 
 
 
 *
 
 
 	S "- "-,1LLNN"- "- "- . . 	/ 	/ 	/	= 	= 	= 	= ). <	5 <	5$J'3 ;5 ;5#V *
,!. !.17!8'ZO- -067
#-:O$- $-0<$= 6)) "("6q"9"A"AM#O #O  F
 "("6q"9"A"AG#I #I  EE &*)EF  #xx ( (39&,,..3I3I( ( (    
 \\["B"B<"B"B"BCC  5  5!\11:J1^Q\^^` ` `!%666?O6^Q\^^` ` `#v--&2Fq2I2N2NL3N 3NUY3Z^Q\^^` ` ` "	*v"566A!Y..!))K"8"8$?? `;!%a `!$&Jqvvxx/?/?	;K[K[K]K]/^/^$_$_` ` ` ` ` ` ` ` ` ` ` ` ` ` `` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ??"#&3#-)9).& + J JD iif(<==sVTTT GXY#$6688%22'/'7'78I2'N'NH#'<<0A2#F#FDG G G G G G G G G G G G G G G $$Xt444A 5  5  5  5  5  5  5  5  5  5  5  5  5  5  57;5<	5 <	5s   B,OL	AK+L	+K//L	2K/3L	6OLO	L
AOAN	ON""O%N"&OOO)r@   rA   rB   maxDiffr  r  rM  r"   r!   r   r  r    sP        G
&3 &3 &3PG G G`b5 b5 b5 b5 b5r!   r  c                    t          ddg          a| t          } | at          t          t
          t          t          t          t          t          t          t          t          t          t          t           t"          t$          t&          t(          g}t          t          ur|                    t,          g           ddlm} t          j        j        }|                                }|j        }|                                |_        t;          t          d          r0t                              t          j        t          j                   }nd }	 tC          j"        |  ddlm} |#                                 |$                    |           ||_        |t          j        |  d xaad S # ddlm} |#                                 |$                    |           ||_        |t          j        |  d xaaw xY w)Nr8   r9   )blockedr   r2   _set_factories)%r   r_   r=   r-   rS  r  r  rB  r   r  r  r	  rf  r  r  r  r%  r  r$  r  r  r   r  r4   r3   r]  _namespace_mapr   r   r   rQ  rq  r   r   run_unittestr   rD  )moduletest_classesr3   r  
nsmap_copyrG  old_factoriess          r   	test_mainrX  n  s    6(6'79 9 9D~ 
B 	%
L0 2~~ 	 	 	
 &%%%%%!0EJ#J#**Kr#$$ ))"*be<<l++))))))Z   '$}--TTT 	*)))))Z   '$}--Ts   F" "AG.__main__)TrC   r^   )Rr   r   rC  rF   r  r   r'   rf   re   r  r  r  r2  r  r   r   r   r   r   test.supportr   r   r	   r
   r   r   test.support.import_helperr   test.support.os_helperr   r_   r=   r   r)   UnicodeEncodeErrorr  r  r  r   r  rO  rP  rK  rL  r  r#   r+   TestCaser-   rQ   rZ   r\   r   r  r  formatescaper   r	  r$  r  r  r   r9  __hash__r?  rB  rf  r  r  r  r%  rL  rS  r  r  r  r  r  r  rX  r@   r"   r!   r   <module>rb     sL         				      				  



            % % % % % % % %       " " " " " " ( ( ( ( ( ( C C C C C C C C C C C C : : : : : : ) ) ) ) ) ) 	,}===A'"""" A A A
(
?
@
@@AH_]CCC 83MJJJ 
 "
  #(     4 4 4
L 
L 
L 
L 
L" 
L 
L 
L   & & &= = = = = = = =@VP VP VP VP VPh' VP VP VPr$p? p? p? p? p?) p? p? p?l  	   !      F;4;~t,,-- 	 	'	" # X X 	 	 	 p7 p7 p7 p7 p78$ p7 p7 p7l]J ]J ]J ]J ]Jx  ]J ]J ]JH_4 _4 _4 _4 _4(9 _4 _4 _4DT T T T T_h&7 T T Tn    #     #|      S    , ? ? ? ? ?(*; ? ? ?D5. 5. 5. 5. 5.(+ 5. 5. 5.pv: v: v: v: v:h' v: v: v:r]( ]( ]( ]( ](h' ]( ]( ](@t. t. t. t. t.h' t. t. t.nQ: Q: Q: Q: Q:H% Q: Q: Q:hE E E E E* E E ESI SI SI SI SI* SI SI SIlC, C, C, C, C,X C, C, C,L7 7 7 7 7X& 7 7 7* 5  5  5  5  5h'  5  5  5HK K K K K) K K K - - -`5 `5 `5 `5 `5x  `5 `5 `5JB B B BJ zIKKKKK s   B B/