
    7bhʣ                       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Zd dlZd dlm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%jM                  d        edd      Z) edd      Z*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d Z3dddZ4d Z5 G d d ejl                        Z7dud"Z8d# Z9 G d$ d%      Z: G d& d'ejl                        Z; G d( d)ejl                        Z<i Z=d*e=d+<   d,e=d-<   d.e=d/<   d0e=d1<   d2e=d3<   d4e=d5<   d6e=d7<   d8e=d9<   d:j}                   ej~                  e%d!            e=d;<   d<e=d=<   i Z@d>e@d?<   d@e@dA<   dBe=dC<   dDe=dE<   dFe=dG<    G dH dIejl                        ZA G dJ dKejl                        ZB G dL dMe:ejl                        ZC G dN dOe:ejl                        ZD G dP dQeE      ZF G dR dSeE      ZG G dT dUeE      ZH G dV dWe:ejl                        ZI G dX dYejl                        ZJ G dZ d[ejl                        ZK G d\ d]ejl                        ZL G d^ d_ejl                        ZM G d` daejl                        ZN G db dcejl                        ZO G dd deejl                        ZP G df dgejl                        ZQ G dh diejl                        ZR G dj dkejl                        ZS G dl dmejl                        ZT G dn doejl                        ZUdp ZV G dq drejl                        ZWdvdsZXeYdtk(  r ej                          yy# e'$ r  ejP                  d      w xY w)w    N)nullcontext)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>
c                  N    t         J d       t        J d       t         t        u S )NzET must be initializedzpyET must be initializedETpyET     =/opt/python-3.12.12/usr/lib/python3.12/test/test_xml_etree.pyis_python_implementationr   ~   s.    >333>777:r   c                 `    | j                   }t        j                  j                  | dd|      S )zMock cls.__eq__ to check whether it has been called or not.

    The behaviour of cls.__eq__ (side-effects included) is left as is.
    __eq__T)autospecwraps)r   mockpatchobject)clseqs     r   equal_wrapperr%      s+    
 
B::S(TDDr   F)quietc                       fd}|S )Nc                 D      fd}t        j                  |        |S )Nc                  j    t        j                  di5   | i | d d d        y # 1 sw Y   y xY w)Nr&   )r	   check_warnings)argskwargsfiltersr&   tests     r   newtestz1checkwarnings.<locals>.decorator.<locals>.newtest   s0     //FFd%f% GFFs   	)2)	functoolsupdate_wrapper)r.   r/   r-   r&   s   ` r   	decoratorz checkwarnings.<locals>.decorator   s    	& 	  $/r   r   )r&   r-   r2   s   `` r   checkwarningsr3      s     r   c                 ^    | j                  dt        j                  j                               S )N   
)replaceoslinesepencode)datas    r   convlinesepr;      s     <<rzz00233r   c                       e Zd Zd Zd Zy)
ModuleTestc                 (    ddl m} ddl m} ddl m} y )Nr   )ElementTreeElementIncludeElementPath)	xml.etreer?   rA   rC   )selfr?   rA   rC   s       r   test_sanityzModuleTest.test_sanity   s     	*,)r   c                 B    d}t        j                  | t        |d       y )N)xml.etree.ElementTree_elementtree)
HTML_EMPTY)not_exported)r   check__all__r   )rE   namess     r   test_allzModuleTest.test_all   s    9T2u?Kr   N)__name__
__module____qualname__rF   rN   r   r   r   r=   r=      s    *Lr   r=   Tc                     |dk7  rt        j                         }nt        j                         }t        j	                  |       } |j
                  |fd|i| |r|j                         S |j                  d       |S )Nunicodeencodingr   )ioBytesIOStringIOr   r?   writegetvalueseek)elem	to_stringrT   optionsfiletrees         r   	serializer`      se    9zz|{{}>>$DDJJt2h2'2}}		!r   c                 @    | D cg c]  }|j                    c}S c c}w Ntag)seqr[   s     r   summarize_listrf      s    !$%DHH%%%   c                   (    e Zd Zed        Zd Zd Zy)ElementTestCasec                 &    t         t        h| _        y rb   )r   r   modulesr#   s    r   
setUpClasszElementTestCase.setUpClass   s    Rjr   c                    	 t        t        j                  ||      5  t        j                  ||      }d d d        t        t        j                  ||      5  t        j
                        }d d d        |S # 1 sw Y   DxY w# 1 sw Y   S xY w# t        j                  $ r]}t        t        dft        dfg      }	t        j                  d|d|	j                  ||      d|	j                  ||            |d }~ww xY w)NcETr   zFailed to round-trip z from z to )r   sysrk   pickledumpsloadsPicklingErrordictr   r   r   
TestFailedget)
rE   objnamedumperloaderprototempresultpehumans
             r   pickleRoundTripzElementTestCase.pickleRoundTrip   s    	L3;;f5||C/ 63;;f5d+ 6  655  ## 	L2u+f~67E$$(+(-		&&(A(-		&&(A&C D JLL	LsL   B A7#B B-B 7B <B BB B D #AC;;D c                    | j                  |t        j                  t        j                  f       | j                  |t        j                  t        j                  f       | j	                  t        t        |            t        t        |                   t        ||      D ]  \  }}| j                  ||        t        j                  dddd      }| j	                   ||       ||             y )Nrd   tailtextattrib)assertIsInstancer   Elementr   assertEquallenlistzipassertEqualElementsoperator
attrgetter)rE   alicebobxy
propertiess         r   r   z#ElementTestCase.assertEqualElements   s    ebjj$,,%?@cBJJ#=>T%[)3tCy>:sODAq$$Q* $((I
E*JsO<r   N)rO   rP   rQ   classmethodrm   r   r   r   r   r   ri   ri      s    ! !=r   ri   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/y.)/ElementTreeTestc                 :    | j                  t        |      |       y rb   )r   r`   )rE   r[   expecteds      r   serialize_checkzElementTreeTest.serialize_check   s    4(3r   c                      fdt         j                  d      } |       t         j                  |      } |j                                t         j                  dd      }t         j                  |      } j	                  t        |      d       t         j                  dd      } fd |j                          |j                          |j                          |j                          |j                          |j                          |j                          |j                          |j                          |j                          |j                           |j"                          |j$                          |j&                          |j(                         fd} ||j                  d              ||j                  d	              ||j                  d              ||j                  d	              j+                  t         j,                  t         j.                          j+                  t         j0                  t         j2                         y )
Nc                 2   j                  t        j                  |       d       t        |       }dD ]9  }j                  t	        | |      d|z         j                  ||d|z         ; j                  | j                  t               j                  | j                  t               | j                   j                  | j                  t               | j                   j                  | j                  t               | D ]
  } |        y )Nznot an elementmsg)rd   r   r   r   zno %s memberzno %s visible by dir)
assertTruer   	iselementdirhasattrassertInr   rd   strr   ru   r   r   )elementdirelemattrr[   check_elementrE   s       r   r   z5ElementTreeTest.test_interface.<locals>.check_element   s    OOBLL17GOH'lG7 6*T1   3dG2T9  ; 8 !!'++s3!!'..$7||'%%gllC8||'%%gllC8d#  r   rd      tägvaluekeyz^<Element 't\xe4g' at 0x.*>$c                 F    j                  t        | d      d| z         y )N__call__z%s not callabler   )r   r   )methodrE   s    r   check_methodz4ElementTreeTest.test_interface.<locals>.check_method   s%    OOGFJ7)F2  4r   c                 *     | j                          y rb   )__next__)itr   s    r   
check_iterz2ElementTreeTest.test_interface.<locals>.check_iter  s    %r   *)r   r   r?   getrootassertRegexreprappendextendinsertremovefinditerfindfindallfindtextclearrw   setkeysitemsiteritertextr   XML
fromstringPIProcessingInstruction)rE   r   r_   r   r   r   s   `   @@r   test_interfacezElementTreeTest.test_interface   s   	$$ **U#g~~g&dlln%**X7*3~~g&g(GH**U*0	4 	W^^$W^^$W^^$W^^$W\\"W%%&W__%W%%&W]]#W[[!W[[!W\\"W]]#W\\"W%%&	& 	7##E*+7##C()4=='(4==%& 	/ 8 89r   c                 R   t         j                  d      }| j                  |j                  d       d|_        | j                  |j                  d       d|_        | j                  |j                  d       | j	                  |j
                         d|_        | j                  |j
                  d       d|_        | j                  |j
                  d       | j	                  |j                         d|_        | j                  |j                  d       d|_        | j                  |j                  d       | j                  |j                  i        dd	d
|_        | j                  |j                  dd	d
       ddd|_        | j                  |j                  ddd       y )Nrd   TagTAGTextTEXTTailTAILbd)acBD)AC)r   r   r   rd   assertIsNoner   r   r   )rE   r   s     r   test_set_attributez"ElementTreeTest.test_set_attribute   sH   **U#e,e,e,',,'v.v.',,'v.v.,"-s)=>"-s)=>r   c                    t         j                  d      }| j                  |d       t         j                  d      }|j	                  |       | j                  |d       |j                  |       | j                  |d       |j                  d|       | j                  |d       |j                  |       |j                  |g       | j                  |d       |j                  |       |j                  t        |g             | j                  |d       |j                  |       t         j                  dd	      }| j                  |d
       t         j                  d      }|j	                  |       | j                  |d       |j                  d|       | j                  |d       |j                  |       | j                  |d       |j                  |       | j                  |d
       | j                  t              5 }|j                  |       d d d        | j                  t        j                        d       | j                  |d
       |||g|dd | j                  |d   d       | j                  |dd |d   |d   g       | j                  |d dd   |d   |d   g       |dd= | j                  |d       y # 1 sw Y   xY w)N<body><tag/></body><body><tag /></body>tag2z<body><tag /><tag2 /></body>r   z<body><tag2 /><tag /></body>rd   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)rE   r[   er   
subelementcms         r   test_simpleopszElementTreeTest.test_simpleops;  sx    vv+,T#9:JJvAT#ABAT#9:AqT#ABAQCT#ABAD!IT#ABA**U*0W&;<ZZ)
z"W&IJq*%W=	?z"W&IJz"W&;<z*bNN:& +R\\*,KLW&;<"J
;!WQZ61
GAJ'?@!AWQZ(@AAaCLW=	? +*s   KKc                     | j                  t        j                  d      d       | j                  t        j                  d      d       | j                  t        j                  d      d       y )Nz<tag>hello</tag>z)<tag>&#104;&#101;&#108;&#108;&#111;</tag>z<tag><![CDATA[hello]]></tag>)r   r   r   rE   s    r   
test_cdatazElementTreeTest.test_cdatag  s[     	RVV$67"	$RVV$OP"	$RVV$BC"	$r   c                    t        j                  t        j                  d            }t        j                  |      }| j                  |j                  d      j                  d       | j                  |j                  d      j                  d       t        j                  t              }| j                  |j                  d      j                  d       | j                  |j                  d      j                  d       y )Nr   )r^   rd   section/tagr   zelement/../empty-elementempty-element)
rU   rV   
SAMPLE_XMLr9   r   r?   r   r   rd   SIMPLE_XMLFILE)rE   
stringfiler_   s      r   test_file_initzElementTreeTest.test_file_initq  s    ZZ
 1 1' :;
~~:~.5)--u5=155u=~~>~29-119=#=>BB	!r   c                 ~   ddl m} t        j                  t              }|j
                  j                          t        d      D ]2  }t        j                  |      j                  dt        |      z          4 t        |j
                        }t        d      D ]2  }t        j                  |      j                  dt        |      z          4 | j                  t        |j
                        |       t        d      D ]2  }t        j                  |      j                  dt        |      z          4 | j                  t        |j
                        |       t        d      D ]2  }t        j                  |      j                  dt        |      z          4 | j                  t        |j
                        d       y )Nr   rB   
   z./   iX  i  )rD   rC   r   r   r   _cacher   ranger?   r   r   r   r   assertGreater
assertLess)rE   rC   r[   icache_len_10s        r   test_path_cachezElementTreeTest.test_path_cache|  s*    	*vvj!  "rABNN4055d3q6kB;--.rABNN4055d3q6kB[//0,?rABNN4055d3q6kB3{112LAsAR^^D166tCF{CK../5r   c                    dd l }t        j                  d      } |j                   |      } |j                  |      }d|j	                  d      _        | j                  |d       | j                  |d       | j                  |d       y )Nr   z<tag>hello<foo/></tag>barfooz<tag>hello<bar /></tag>z<tag>hello<foo /></tag>)copyr   r   deepcopyr   rd   r   )rE   r  e1e2e3s        r   	test_copyzElementTreeTest.test_copy  sx     	VV,-TYYr]T]]2"R!:;R!:;R!:;r   c                 8   t         j                  d      }|j                  d       | j                  |j                  dd      d       |j	                  dd       | j                  |j                  d      d       t         j                  dd      }| j                  |j                  d      d       | j                  |j
                  ddi       ddi}t         j                  d|      }|j                          | j                  |j                  d      d       | j                  |j
                  ddi       ddi}t        j                  di |}|j                          | j                  |j                  d      d       | j                  |j
                  ddi       t         j                  dddid      }| j                  |j                  d      d       | j                  |j
                  ddi       t         j                  d      }d|_        |j	                  d	d
       |j	                  dd       | j                  t         j                  |      d       | j                  t        |j                               d	dg       | j                  t        |j                               ddg       | j                  |j
                  d   d       d|j
                  d<   d|j
                  d<   | j                  t         j                  |      d       t         j                  d      }|j	                  dd       |j	                  dd       |j	                  dd       |j	                  dd       | j                  t         j                  |      d       y )Nrd   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;  " />rc   )r   r   rw   r   r   r   r   r   tostringsortedr   r   )rE   r[   r   s      r   test_attribzElementTreeTest.test_attrib  s    zz% %3Y? %'2zz%Wz-%'2ug&67!zz%(%'2ug&67!zz*6*%'2ug&67zz%%!1wz?%'2ug&67zz&!	)$'"T*@	B		,w.@A

-%'9:	<W-w7&G&GT*N	P zz&!dfi &'T*n	pr   c                 "   t         j                  d      }ddi}|j                  d|      }| j                  |j                  |d       |j                  |       | j                  |d       |j                          | j                  |d       |j                  |       | j                  |d       |j                  ||g       | j                  |d	       |g|d d  | j                  |d       t        |g      |d d  | j                  |d       y )
Nrd   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assertIsNotr   r   r   r   r   tuple)rE   r[   r   subelems       r   test_makeelementz ElementTreeTest.test_makeelement  s     zz% !""8V45FGGT#FG

T9-GT#FGWg&'T[	])QT#FG	"QT#FGr   c                 d   t         j                  t              }t        j                         }|j                  |d       | j                  |j                         d       t         j                  t              }t        j                         }|j                  |d       | j                  |j                         d       t        t              5 }|j                         }d d d        t         j                         }| j                  |j                  d       |j                         | j                  |j!                         d       t         j#                         }t         j                  |      }|j                  |       | j                  |j!                         d       y # 1 sw Y   xY w)NrS   rT   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   rU   rW   rX   r   rY   SIMPLE_NS_XMLFILEopenread	XMLParserr   versionfeedr   closeTreeBuilder)rE   r_   streamfr:   parserr!  s          r   test_parsefilezElementTreeTest.test_parsefile  sC    xx'

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

6I
.*	 .!Q668D " 4DV\\^	 !V,DV\\^	! "!s   F&&F/c                 .   t         j                  d      }| j                  t         j                  |d      d       t         j	                  d      }| j                  t         j                  |d      d       g d}t         j                  |      }| j                  t         j                  |      d       | j                  dj                  t         j                  |            d       | j                  t         j                  |d      d       t         j                  d      \  }}| j                  t        |      d	       t         j                  d
      \  }}| j                  t        |      d       | j                  |d   j                  d       y )N<html><body>text</body></html>rS   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   rd   )rE   r   sequence_idss        r   test_parseliteralz!ElementTreeTest.test_parseliteral  s>   &&9:WyA0	2-- @AWyA0	2=##H-W-1	3"//'":;1	3Wg62	3 :;3S1%DE3S1%V&1r   c                    t         j                  } |t              }| j                  |j                         t        |      \  }}| j                  |j                         | j                  ||j                  fd       | j                  |D cg c]  \  }}||j                  f c}}g d       | j                  |j                  j                  d        |t              }| j                  |D cg c]  \  }}||j                  f c}}g d       d} |t        |      }| j                  |D cg c]  \  }}||j                  f c}}g        d} |t        |      }| j                  |D cg c]  \  }}||j                  f c}}g        d} |t        |      }| j                  |D cg c]  \  }}||j                  f c}}g d       d	} |t        |      }| j                  |D cg c]  \  }}|dv r||j                  fn||f c}}g d
       d} |t        j                  d      |      }|D cg c]  \  }}|	 }}}| j                  |ddg       d}t        t        d      5 }| j                  t              5 } |||       d d d        | j                  |j                         d d d        | j                  t!        j"                        d       t%        j&                  |       5  | j                  t              5 } |t        |       d d d        | j                  t!        |j"                        d       ~d d d        t        j(                  d      }	d} ||	|      }| j                  |D cg c]	  \  }}||f c}}ddg       t        j                  d      }	 ||	      }
t        |
      \  }}| j                  ||j                  fd       | j                  t         j*                        5 }t        |
       d d d        | j                  t!        j"                        d       | j-                  t.        j0                  t2               t        t2        d      5 }|j5                  d       d d d         |t2              }
t        |
      \  }}| j                  ||j                  fd       t%        j&                  |       5  | j                  t         j*                        5 }t        |
       d d d        | j                  t!        |j"                        d       ~~
d d d        t%        j&                  |       5   |t2              }
~
d d d        | j                  t6              5   |d       d d d        y c c}}w c c}}w c c}}w c c}}w c c}}w c c}}w c c}}w # 1 sw Y   %xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY wc c}}w # 1 sw Y   xY w# 1 sw Y   }xY w# 1 sw Y   	xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nendr   )r=  r>  r   r>  rootrA  )r>  {namespace}elementrB  r>  {namespace}empty-elementr>  {namespace}rootr   eventsstartr>  rK  rA  rK  r   r=  rN  r=  )rK  r   r?  r@  )rK  r>  start-nsend-ns)
rO  ) 	namespacerK  rG  rK  rC  rB  rU  rB  rK  rE  rD  rF  rP  NrO  rP  z<root xmlns=''/>rO  rP  rK  r>  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>
)rO  )rO  )rR  u   http://éffbot.org/ns)rO  )u   cléhttp://effbot.org/nsz<document />junk)r>  documentz.junk after document element: line 1, column 12wbs   <document />junknonexistent)r   	iterparser   r   rA  nextr   rd   r#  rU   rW   r$  r   r   assertFalseclosedr   r   r	   check_no_resource_warningrV   
ParseError
addCleanupr   unlinkr   rX   FileNotFoundError)rE   r`  contextactionr[   rI  resr,  r   sourcer   s              r   test_iterparsezElementTreeTest.test_iterparse'  sm    LL	N+',,'G}',,'&$((+-?@I6488,I L 	
 	))62-.I6488,I L 	 NF3I6488,I2NN6:I6488,I2N!NF3I6488,I 	L 		 8-v6.57.5lfd 17:J0J6488,394.A.579	 (BKK(;<fE*12',&$v'2z845*.$'1"":."!V$ /QXX& ( 	R\\*,CD66t<"":.".&1 /S.0GH	 = GH FF+WEW\VT64.WE=@H 	
 /0vBx&$((+-@Ar}}-H .R\\*@	B 		((&1&$1GG'(  vBx&$((+-@A66t<""2==1RR 2S.DFB = 66t<6"B = 01m$ 21[ J J J J J7" 3
 /. (' /. =< F .-   21 =< =< 21s   V
4V
6V!
7V'
7V-
9 V3
V9<W
V?#WW&W%.W&W3
W99X  X  X/X X,	X8?W		WWW#	W&&W09XXX	X  X),X58Yc                    t         j                  d      }d|_        | j                  |d       dt         j	                  |d      _        | j                  |d       d |_        | j                  |d       |j                  dt         j                  d	             | j                  |d
       t         j                  dd      |d<   | j                  |d       y )Nrd   r   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   r   r   
SubElementrd   r   Commentr   rE   r[   s     r   test_writefilezElementTreeTest.test_writefile  s    zz% 	T#45-6dH%*T#LM T#ABArzz),-T<	> %%w'QT#NOr   c                    t        t              5 }|j                         }d d d         G d dt              } |       }t        j                  |      }|j                         | j                  |g d       t        t              5 }|j                         }d d d         G d dt              } |       }t        j                  |      }|j                  |       | j                  |g d       y # 1 sw Y   xY w# 1 sw Y   gxY w)Nc                       e Zd Zd Zd Zd Zy)4ElementTreeTest.test_custom_builder.<locals>.Builderc                 *    | j                  d|f       y NrK  r   rE   rd   r   s      r   rK  z:ElementTreeTest.test_custom_builder.<locals>.Builder.start      WcN+r   c                 *    | j                  d|f       y Nr>  rz  rE   rd   s     r   r>  z8ElementTreeTest.test_custom_builder.<locals>.Builder.end      UCL)r   c                      y rb   r   rE   r   s     r   r:   z9ElementTreeTest.test_custom_builder.<locals>.Builder.data      r   N)rO   rP   rQ   rK  r>  r:   r   r   r   Builderrw    s    ,*r   r  r   rL  c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	rw  c                 *    | j                  d|f       y ry  rz  r{  s      r   rK  z:ElementTreeTest.test_custom_builder.<locals>.Builder.start  r|  r   c                 *    | j                  d|f       y r~  rz  r  s     r   r>  z8ElementTreeTest.test_custom_builder.<locals>.Builder.end  r  r   c                      y rb   r   r  s     r   r:   z9ElementTreeTest.test_custom_builder.<locals>.Builder.data  r  r   c                 ,    | j                  d||f       y )Npirz  )rE   r!  r:   s      r   r  z7ElementTreeTest.test_custom_builder.<locals>.Builder.pi  s    T6401r   c                 *    | j                  d|f       y )Nrp  rz  )rE   r:   s     r   rp  z<ElementTreeTest.test_custom_builder.<locals>.Builder.comment  s    Y-.r   c                 ,    | j                  d||f       y )NrO  rz  )rE   prefixuris      r   start_nsz=ElementTreeTest.test_custom_builder.<locals>.Builder.start_ns  s    Z56r   c                 *    | j                  d|f       y NrP  rz  rE   r  s     r   end_nsz;ElementTreeTest.test_custom_builder.<locals>.Builder.end_ns      Xv./r   N)
rO   rP   rQ   rK  r>  r:   r  rp  r  r  r   r   r   r  z4ElementTreeTest.test_custom_builder.<locals>.Builder  s%    ,*2/70r   ))r  r  r:   )rp  	 comment )rO  rR  rS  rT  rU  rB  rU  rB  rV  rD  rF  rP  rR  )	r$  r   r%  r   r   r&  r(  r   r#  )rE   r,  r:   r  builderr-  s         r   test_custom_builderz#ElementTreeTest.test_custom_builder  s     .!Q668D "	d 	 )W-D 	# 		 #$668D %	0d 	0 )W-D # 	W "!. %$s   C4	D 4C= D	c                      G d dt               } |       }t        j                  |      }|j                  t	        j
                  d             | j                  |g d       y )Nc                       e Zd Zd Zy)@ElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builderc                 *    | j                  d|f       y r  rz  r  s     r   r  zGElementTreeTest.test_custom_builder_only_end_ns.<locals>.Builder.end_ns  r  r   N)rO   rP   rQ   r  r   r   r   r  r    s    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>
            ))rP  r   )rP  pr  )r   r   r&  r(  textwrapdedentr   )rE   r  r  r-  s       r   test_custom_builder_only_end_nsz/ElementTreeTest.test_custom_builder_only_end_ns  sZ    	0d 	0 )W-HOO %  	 	 # 	r   c                     t         j                  d       }| j                  |j                  t         j                         t         j                         }| j                  |j                  t         j                         y )Nr   )r   r&  r   r!  r*  )rE   r-  parser2s      r   %test_initialize_parser_without_targetz5ElementTreeTest.test_initialize_parser_without_target  sO    T*fmmR^^< ,,.gnnbnn=r   c                 >   t        t        d      5 }t        j                  |      }d d d        | j	                  j                         j                         D cg c]  }t        |       c}g dg g g g       | j	                  |j                         D cg c]  }t        |       c}g dg g g g       t        j                  t              }| j	                  t        t        |            d       | j	                  t        t        |d               d       | j	                  |d d  t        |             |d   }|d   }|dd= | j	                  t        t        |            d       | j	                  ||d          | j	                  ||d          ||g|dd | j	                  ||d          | j	                  ||d          | j                  ||d          |j                          | j	                  t        |      g        y # 1 sw Y   xY wc c}w c c}w )Nr[  )r   r   r      r   r   r   )r$  r   r   r"  r   r   r   rf   r   r   r   r   assertNotEqualr   )rE   r,  r_   r[   child1child2s         r   test_childrenzElementTreeTest.test_children  s    .$'188A;D (&*lln&9&9&;=&;d ).&;=7	?	 	&*iik3&1d ).&137	5	 vvj!T$Z!,T$q']+Q/a$t*-aa1IT$Z!,a)a)V$Qq	a)a)FDG,

dR(A ('=3s   HHHHc                     t         j                  d      }| j                  t         j                  |      d       t         j	                  d      }| j                  t         j                  |      d       y )Nr0  r1  )r   r   r   r  r   rs  s     r   test_writestringz ElementTreeTest.test_writestring3  sT    vv67T*,MN}}=>T*,MNr   c                    t         j                  d      }t         j                  |       | j                  t         j	                  |      d       t         j                  d      }t         j                  |       | j                  t         j	                  |      d       t         j                  d      }t         j                  |       | j                  t         j	                  |      d       t         j                  d      }t         j                  |       | j                  t         j	                  |      d       t         j                  d      }t         j                  |       | j                  t         j	                  |      d	       t         j                  d
      }t         j                  |       | j                  t         j	                  |      d       y )Nz<root></root>s   <root />r0  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  rs  s     r   test_indentzElementTreeTest.test_indent9  sD   vvo&
		$T*K8vv67
		$T*,STvv9:
		$T*,STvv:;
		$T*,UVvvWX
		$KK	
 vvPQ
		$KK	
r   c                 H   t         j                  d      }t         j                  |d       | j                  t         j	                  |      d       t         j                  d      }t         j                  |d       | j                  t         j	                  |      d       y )Nr  	)spacesD   <html>
	<body>
		<p>pre<br />post</p>
		<p>text</p>
	</body>
</html>rR  s>   <html>
<body>
<p>pre<br />post</p>
<p>text</p>
</body>
</html>r  rs  s     r   test_indent_spacez!ElementTreeTest.test_indent_spacee  s    vvPQ
		$d	#KK	
 vvPQ
		$b	!KK	
r   c                 Z   t         j                  d      }t         j                  |       | j                  |j	                         D ch c]  }|j
                   c}h d       | j                  |j	                         D ch c]  }|j                   c}h d       | j                  t        |j	                         D ch c]  }|j
                   c}      t        |j	                         D ch c]  }t        |j
                         c}             y c c}w c c}w c c}w c c}w )Nz@<html><body><p>par</p><p>text</p><p><br/></p><p /></body></html>>   N

  
    >   N
      parr   r  r  )	r   r   r  r   r   r   r   r   id)rE   r[   els      r   test_indent_space_cachingz)ElementTreeTest.test_indent_space_caching~  s    vvXY
		$#yy{+{RWW{+*	
 	#yy{+{RWW{+?	
 	499;/;R;/0tyy{3{BGG{34	
 , , 03s   DDD#1D(c                    t         j                  d      }| j                  t              5  t         j	                  |d       d d d        | j                  t         j                  |      d       t         j	                  |d       | j                  t         j                  |      d       t         j                  d      }t         j	                  |dd	       | j                  t         j                  |      d
       y # 1 sw Y   xY w)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  rs  s     r   test_indent_levelz!ElementTreeTest.test_indent_level  s    vvPQz*IId"I% +KKH	

 			$a	 KK	
 vvPQ
		$as	+KK	
) +*s   C??Dc                     t         j                  d      }| j                  t         j                  |d      d       | j                  t         j                  |dd      d       y )N0<body xmlns="http://effbot.org/ns"><tag/></body>rS   r  A<ns0:body xmlns:ns0="http://effbot.org/ns"><ns0:tag /></ns0:body>r\  rT   default_namespace1<body xmlns="http://effbot.org/ns"><tag /></body>r   r   r   r  rs  s     r   test_tostring_default_namespacez/ElementTreeTest.test_tostring_default_namespace  sX    vvHIKKyK1O	
 	KKyDZK[?	
r   c                 ~    t         j                  d      }| j                  t         j                  |dd      d       y )Nr  rS   foobarr  zP<ns1:body xmlns="foobar" xmlns:ns1="http://effbot.org/ns"><ns1:tag /></ns1:body>r  rs  s     r   3test_tostring_default_namespace_different_namespacezCElementTreeTest.test_tostring_default_namespace_different_namespace  s4    vvHIKKyHKM^	
r   c                     t         j                  d      }d}| j                  t        |      5  t         j	                  |dd       d d d        y # 1 sw Y   y xY w)Nr   z>^cannot use non-qualified names with default_namespace option$rS   r  r  )r   r   assertRaisesRegexr   r  )rE   r[   EXPECTED_MSGs      r   5test_tostring_default_namespace_original_no_namespacezEElementTreeTest.test_tostring_default_namespace_original_no_namespace  sD    vv+,W##J=KKyHKM >==s   AAc                 |    t         j                  d      }| j                  t         j                  |d      d       y )Nr   rS   r  r   r  rs  s     r    test_tostring_no_xml_declarationz0ElementTreeTest.test_tostring_no_xml_declaration  s2    vv+,KKyK1"	
r   c                 ~    t         j                  d      }| j                  t         j                  |dd      d       y )Nr   utf8TrT   xml_declarations:   <?xml version='1.0' encoding='utf8'?>
<body><tag /></body>r  rs  s     r   test_tostring_xml_declarationz-ElementTreeTest.test_tostring_xml_declaration  s4    vv+,KKvtKDJ	
r   c                 ~    t         j                  d      }| j                  t         j                  |dd      d       y )Nr   rS   Tr  ;<?xml version='1.0' encoding='utf-8'?>
<body><tag /></body>r  rs  s     r   .test_tostring_xml_declaration_unicode_encodingz>ElementTreeTest.test_tostring_xml_declaration_unicode_encoding  s4    vv+,KKy$KGJ	
r   c           	          t         j                  d      }g d}|D ]N  \  }}}| j                  d| d|       5  | j                  t         j	                  |||      |       d d d        P y # 1 sw Y   [xY w)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  rS   N)r  NF)r  r  F)r  r  F)s   <body><tag></tag></body>r  F)r  rS   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>rS   Tz	encoding=z xml_declaration=r  )r   r   subTestr   r  )rE   r[   	TESTCASESexpected_retvalrT   r  s         r   #test_tostring_xml_declaration_casesz3ElementTreeTest.test_tostring_xml_declaration_cases  s    vv23
	< ;D6OX	( 411@0AC D  KK!)(7   
 $D D ;DD Ds   )A..A7	c           	         t         j                  d      }| j                  dj                  t         j	                  |d            d       | j                  dj                  t         j	                  |dd            d       y )	Nr  rR  rS   r  r  r\  r  r  )r   r   r   r5  r6  rs  s     r   #test_tostringlist_default_namespacez3ElementTreeTest.test_tostringlist_default_namespace  sj    vvHIGGBOOD9O=>O	
 	GGBOOD9PfOgh?	
r   c                    t         j                  d      }| j                  dj                  t         j	                  |d            d       | j                  dj                  t         j	                  |d            d	       t         j	                  |dd
      }| j                  dj                  |      d       | j                  |d   d       | j                  g d|dd         y )Nr   rR  rS   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   r5  r6  r   )rE   r[   
stringlists      r   !test_tostringlist_xml_declarationz1ElementTreeTest.test_tostringlist_xml_declaration  s    vv+,GGBOOD9O=>"	
 	HHR__T4_@AN	

 __TIt_T
GGJJ	
 	A(PQA:ab>Rr   c           
          d fd	} |dd        |dd        |dd        |dd        |d	d
        |dd       d fd}g d}|D ]@  } j                  t        j                  t        j                   ||                  d       B g d}|D ]-  } j	                  t
        t        j                   ||             / g d}|D ]7  } j	                  t        j                  t        j                   ||             9  j	                  t
        t        j                   d      j                  d              j	                  t        t        j                   d      j                  d             y )Nc                     d| d|d}j                  t        j                  |j                  |             j                  |       j                  t        j                  |      j                  |       y )Nz<?xml version='1.0' encoding='z'?><xml>z</xml>)r   r   r   r9   r   )rT   r3  xmlrE   s      r   checkz,ElementTreeTest.test_encoding.<locals>.check&  sU    d$CRVVCJJx$89>>ERVVC[--t4r   r2  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>.xml2  s    ?(JJr   c                 2     |       j                  |       S rb   )r9   )rT   r  s    r   bxmlz+ElementTreeTest.test_encoding.<locals>.bxml4  s    x=''11r   )Cr2  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)rR  )	r   r   r  r   r   r   re  r9   LookupError)rE   r  r  supported_encodingsrT   &unsupported_ascii_compatible_encodings(unsupported_ascii_incompatible_encodingsr  s   `      @r   test_encodingzElementTreeTest.test_encoding%  s:   	5
 	gsj#lF#mX&gx k8$	K	2
" ,HR[[X)?@*M ,2
. ?Hj"&&$x.A ?4
0 AHbmmRVVT(^D A 	*bffc+.>.E.Eg.NO+rvvs5z/@/@/IJr   c                 Z   t         j                  d      }d|_        | j                  t	        |      d       | j                  t	        |d       d       | j                  t	        |d      d       | j                  t	        |d      d       | j                  t	        |d      d	       y )
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>
r   z1 < 2
)r   r   r   r   r`   rE   r   s     r   test_methodszElementTreeTest.test_methods`  s     FFBC1B	D1T2B	D1U3B	D1V4=	?1V4i@r   c                     t         j                  d      }| j                  t        |      d       | j                  t        |d      d       y )Nz(<html><CamelCase>text</CamelCase></html>r8  r7  r   r   r   r`   r9  s     r   test_issue18347zElementTreeTest.test_issue18347o  sB    FF=>1:	<1V4:	<r   c                    t         j                  d      }| j                  t        |d      d       | j	                  |d       | j                  t         j                        5 }t         j                  d       d d d        | j                  t        j                        d       | j                  t         j                        5 }t         j                  t               d d d        | j                  t        |j                        d       t         j                         }d	|j                  d
<   |j                  t               |j                         }| j	                  |d       | j                  t         j                        5 }t         j                  t               d d d        | j                  t        |j                        d       y # 1 sw Y   VxY w# 1 sw Y   xY w# 1 sw Y   HxY w)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 10r   entityz<document>text</document>z,undefined entity &entity;: line 4, column 10)r   r   r   r`   r   r   re  r   r   
ENTITY_XMLr&  r?  r(  r)  EXTERNAL_ENTITY_XML)rE   r   r   r-  rA  s        r   test_entityzElementTreeTest.test_entityv  si   
 FF?@1z:=	?Q JK r}}-FF23 .R\\*5	7 r}}-FF: .R\\*>	@
 "(hJ||~T#>? r}}-FF&' .R\\*>	@- .-
 .- .-s$   $GGG'GG$'G0c                    t         j                  d      }| j                  |d       t         j                  d      }| j                  |d       t         j                  d      }| j                  |d       t         j                  d      }| j                  |d       t         j                  t              }| j                  |d	       y )
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_NSrs  s     r   test_namespacezElementTreeTest.test_namespace  s    
 vv-.T#:; vv[\TQ	S vvOPTE	G vv_`TS	U vvm$T	r   c                    t         j                  d      }| j                  |d       t         j                  t         j                  d            }| j                  |d       t         j                  t         j                  dd            }| j                  |d       t         j                  t         j                  dd            }t         j	                  |t         j                  dd            }t         j	                  |t         j                  dd            }| j                  |d       |j                          d|j                  d	<   | j                  |d
       |j                          d|j                  t         j                  d	      <   | j                  |d
       |j                          d|j                  d	<   | j                  |d       |j                          t         j                  d      |j                  d	<   | j                  |d       |j                          t         j                  d      }t         j                  d      |j                  d<   |j                  |       |j                  |       | j                  |d       | j                  t        t         j                  dd            d       | j                  t        t         j                  d            d       t         j                  dd      }t         j                  dd      }| j                  ||       t         j                  dd      }| j                  ||       | j                  |d       | j                  |d       y )Nz{uri}tagz<ns0:tag xmlns:ns0="uri" />r  rd   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   QNamerq  r   r   r   r   r   r  )rE   r[   r  q1q2s        r   
test_qnamezElementTreeTest.test_qname  s   
 zz*%T#@Azz"((:./T#@Azz"((5%01T#@Azz"((5%01--bhhuf&=>--bhhuf&=>TI	K
 	

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

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

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

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

**U#&(hh}&={#GGT	 	RXXdE23Y?RXXi019=XXdE"XXdE"R XXdK(B#B)Y'r   c                 .    t         j                  d      }y )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   rs  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=       y )?Nr   rB   c                     j                  j                  | |      D cg c]  \  }}|xs | c}}|       y c c}}w rb   )r   xpath_tokenizer)r  r   
namespacesoprd   rC   rE   s        r   r  z3ElementTreeTest.test_xpath_tokenizer.<locals>.check  sN    -8-H-HJ-WY-W'"c !iCi-WY%' Ys   <
r   ztext()r   ()z@name@ry   z@*zpara[1])para[1]zpara[last()])rV  rW  lastrT  rY  z*/para)r   /rV  z/doc/chapter[5]/section[2])r[  docr[  chapterrW  5rY  r[  sectionrW  2rY  zchapter//para)r]  //rV  z//parara  rV  z//olist/item)ra  olistr[  item.z.//para)rd  ra  rV  ..z../@lang)re  r[  rU  langzchapter[title])r]  rW  titlerY  z#employee[@secretary and @assistant])
employeerW  rU  	secretaryrR  andrR  rU  	assistantrY  z	@{ns}attrz{ns}attr{http://spam}eggz
./spam.egg)rd  r[  zspam.eggz.//{http://spam}egg)rd  ra  rl  z{ns}*{}*{*}tag{*}*z	.//{*}tag)rd  ra  rn  z
./xsd:type)rd  r[  &{http://www.w3.org/2001/XMLSchema}typexsdz http://www.w3.org/2001/XMLSchematyperp  rR  z	@xsd:typez@typez@{*}typez{*}type)rR  rH  rb   )rD   rC   )rE   r  rC   s   ` @r   test_xpath_tokenizerz$ElementTreeTest.test_xpath_tokenizer  s   )	' 	cC5h'gV}%dS#Ji01n>?h*+*.	/ 	o89hv'n:;cC5i,-dTFj23 >?3 6K 	L 	kC,- #5"67l23#%DE 	gy!eeWh
#fvhk01 	lP89	;f?@56	8kC!IJ89	;gV}56	8j3	*56	8kC,579	:r   c                    | j                  t        j                  t        j                  dd            d       | j                  t        j                  t        j	                  dd            d       | j                  t        j                  t        j	                  dd            d       | j                  t        j                  t        j	                  dd      d      d       y )	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U'	)RUU6=%AB'	)
 	RUU6<%@A&	(RUU63C%DiP+	,r   c                 &   dD ]  }||j                         fD ]u  }d|z  }t        t        j                  d|z        d      }| j	                  ||       t        t        j                  d|d|d      d      }| j	                  ||       w  y )	N)AREABASEBASEFONTBRCOLEMBEDFRAMEHRIMGINPUTISINDEXLINKMETAPARAMSOURCETRACKWBRz<%s>z<%s />r8  r7  <z></r  )lowerr`   r   r   r   )rE   r   r[   r   
serializeds        r   #test_html_empty_elems_serializationz3ElementTreeTest.test_html_empty_elems_serializationO  s    2G !'--/2!D=&rvvho'>vN
  X6&rvvT$.G'H.46
  X6 32r   c                     t         j                  ddd      }t        j                         5 }t         j	                  |       d d d        | j                  j                         d       y # 1 sw Y   *xY w)N
cirriculumpublicexamplestatuscompanyz1<cirriculum status="public" company="example" />
)r   r   r   captured_stdoutdumpr   rY   )rE   r   stdouts      r   test_dump_attribute_orderz)ElementTreeTest.test_dump_attribute_order]  sX    JJ|HiJH$$&&GGAJ '*M	O '&s   A,,A5c                     t         j                  ddd      }| j                  t        |      d       | j                  t        |d      d       y )	Nr  r  r  r  z0<cirriculum status="public" company="example" />r8  r7  z;<cirriculum status="public" company="example"></cirriculum>)r   r   r   r`   rE   rA  s     r   test_tree_write_attribute_orderz/ElementTreeTest.test_tree_write_attribute_ordere  sI    zz,xzK4K	M47M	Or   c                 x    t         j                  t              }| j                  |d   j                  ddi       y )Nr   z*{http://www.w3.org/XML/1998/namespace}langeng)r   r   ATTLIST_XMLr   r   r  s     r   test_attlist_defaultz$ElementTreeTest.test_attlist_defaultm  s1    }}[)aFN	Pr   N)0rO   rP   rQ   r   r   r   r   r   r   r   r  r  r  r.  r;  rm  rt  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r5  r:  r=  rB  rE  rL  rN  rs  rv  r  r  r  r  r   r   r   r   r      s    4A:F?6*?X$	!6 
<4plH,+Z2,x%tP";z,>#)JO*
X
2
 
@	

N


*X	
S&9KvA<#@JB?(B%8:t, 7OOPr   r   c                       e Zd Zd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 Zd Z ej,                  ej0                  dk  dej0                   d      d        Zd Zy)XMLPullParserTestNc                     ||j                  |       n2t        dt        |      |      D ]  }|j                  ||||z            |r|j                          y y Nr   )r(  r   r   flush)rE   r-  r:   
chunk_sizer  r   s         r   _feedzXMLPullParserTest._feedv  sS    KK1c$i4D1Z<01 5LLN r   c           	          | j                  t        |j                         |      D cg c]  \  }}||j                  |j                  ff! c}}|       y c c}}w rb   )r   r   read_eventsrd   r   )rE   r-  r   
max_eventseventr[   s         r   assert_eventszXMLPullParserTest.assert_events  s\     &v'9'9';Z HJ H dhh		*+ HJ	Js   $A
c                 j    | j                  t        t        |j                         |            |       y rb   )r   r   r   r  )rE   r-  r   r  s       r   assert_event_tuplesz%XMLPullParserTest.assert_event_tuples  s+    **,j9:	r   c                     t        |j                         |      }| j                  |D cg c]  \  }}||j                  f c}}|       y c c}}w rb   )r   r  r   rd   )rE   r-  r   r  rI  rj  r[   s          r   assert_event_tagsz#XMLPullParserTest.assert_event_tags  sI    **,j9H6488,H!	#Hs   A
c                 :   t         j                         }| j                  |g        | j                  |d||       | j                  |g        | j                  |d||       | j                  |g        | j                  |d||       | j                  |dg       | j                  |d||       | j                  |d||       | j                  |ddg       | j                  |d||       | j                  |d	g       | j	                  |j                                y )
N<!-- comment -->
z+<root>
  <element key='value'>text</element>
r=  <element>text</element>tail
<empty-element/>
r?  </root>
r@  r   XMLPullParserr  r  r   r)  )rE   r  r  r-  s       r   test_simple_xmlz!XMLPullParserTest.test_simple_xml  s   !!#vr*

6/UCvr*

6Au	& 	vr*

65*e4v(:';<

6:JN

6/UCv$( 	 	

6;
E:v'89&,,.)r   c                 *    | j                  dd       y )Nr   Tr  r  r  r   s    r   test_simple_xml_chunk_1z)XMLPullParserTest.test_simple_xml_chunk_1      6r   c                 *    | j                  dd       y )N   Tr  r  r   s    r   test_simple_xml_chunk_5z)XMLPullParserTest.test_simple_xml_chunk_5  r  r   c                 (    | j                  d       y )N   )r  r  r   s    r   test_simple_xml_chunk_22z*XMLPullParserTest.test_simple_xml_chunk_22  s    +r   c                    t         j                         }|j                         }| j                  |d       t	        |      \  }}| j                  ||j                  fd       | j                  |d       t	        |      \  }}| j                  ||j                  fd       | j                  t              5  t	        |       d d d        y # 1 sw Y   y xY w)Nz-<root>
  <element key='value'>text</element>
r=  r  r@  )	r   r  r  r  ra  r   rd   r   StopIteration)rE   r-  r   rj  r[   s        r   test_feed_while_iteratingz+XMLPullParserTest.test_feed_while_iterating  s    !!#!

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

6;'Bx&$((+_=}-H .--s   6CCc                 j   t         j                         }| j                  |g        | j                  |d       | j                  |g        | j                  |d       | j                  |g        | j                  |d       | j                  |g        | j                  |d       | j                  |dg       | j                  |d       | j                  |d       | j                  |ddg       | j                  |d	       | j                  |d
g       | j	                  |j                                y )Nr  <root xmlns='namespace'>
"<element key='value'>text</elementr  rB  r  r  rD  r  rF  r  rE   r-  s     r   test_simple_xml_with_nsz)XMLPullParserTest.test_simple_xml_with_ns  s   !!#vr*

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

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

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

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

6:;

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

6;'v(B'CD&,,.)r   c                    t         j                  d      }| j                  |d       | j                  |d       | j                  t	        |j                               dg       | j                  |d       | j                  |d       | j                  |d       | j                  |d	       | j                  |d
       | j                  t	        |j                               dg       | j                  |j                                y )NrX  rH  r  r  rQ  r  r  r  r  r  rW  )r   r  r  r   r   r  r   r)  r  s     r   test_ns_eventsz XMLPullParserTest.test_ns_events  s    !!)?!@

6/0

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

6?@

65!

6:;

6/0

6;'f00236F5GH&,,.)r   c                 `   t         j                  d      }| j                  |d       | j                  |ddgd       | j	                  |dgd	       | j                  |d
       | j	                  |ddg       | j                  |d       |j                          | j	                  |dg       y )N)rO  rK  r>  rH   <tag xmlns='abc' xmlns:p='xyz'>
rO  )rR  abcrO  )r  xyzr   r  rK  {abc}tagr   
<child />
rK  
{abc}childr>  r  </tag>
r>  r  r   r  r  r  r  r)  r  s     r   test_ns_events_startz&XMLPullParserTest.test_ns_events_start  s    !!)E!F

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

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

6:&v(
 	r   c                    t         j                  d      }| j                  |d       | j                  |ddgd       | j	                  |dgd	       | j                  |d
       | j	                  |ddg       | j                  |d       |j                          | j	                  |dgd	       | j                  |ddg       y )N)rO  rK  r>  rP  rH  r  r  r  r   r  r  r   r  r  r  r  r  rW  r  r  s     r   test_ns_events_start_endz*XMLPullParserTest.test_ns_events_start_end  s    !!)O!P

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

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

6:&v(
 	 	 	  *
 	r   c                    t         j                  d      }| j                  |d       | j                  |g        t         j                  d      }| j                  |d       | j	                  |g        t         j                  d      }| j                  |d       | j                  |dg       | j                  |d       | j                  |d	g       | j                  |d
       | j                  |dg       | j                  |d       | j                  |g d       | j                  |d       | j                  |j                                | j                  |dg       t         j                  d      }| j                  |d       | j                  |g        | j                  |d       | j                  |dg       | j                  |d       | j                  |d	g       | j                  |d
       | j                  |g        | j                  |d       | j                  |ddg       | j                  |d       | j                  |j                                y )Nr   rH  z<root/>
rJ  <!-- text here -->
z<root>
rM  r  rN  r  r=  z8<element xmlns='foo'>text<empty-element/></element>tail
)rK  {foo}elementrK  {foo}empty-element)r>  r  )r>  r  z</root>r@  )rK  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62&!!)9!:

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

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

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

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

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

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

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

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

65!vr*

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

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

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

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

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

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

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

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

6126Y]0K$L#MNr   c                 8   t         j                  d      }| j                  |d       | j                  |dt         j                  dffg       t         j                  d      }| j                  |d       | j                  |dt         j                  dffg       y )	N)rK  r  r>  rH  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_piP  s    !!)?!@

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

6676TBEE3H+I$J#KLr   c                    ddh}t         j                  |      }| j                  |d       | j                  |ddg        G d d      }t         j                   |             }| j                  |d       | j                  |ddg       y )	Nr>  rK  rH  z<foo>bar</foo>)rK  r  )r>  r  c                       e Zd Zd Zd Zd Zy)9XMLPullParserTest.test_events_sequence.<locals>.DummyIterc                 (    t        g d      | _        y )N)rK  r>  rO  )r   rI  r   s    r   __init__zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__init__`  s    "#?@r   c                     | S rb   r   r   s    r   __iter__zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__iter__b  s    r   c                 ,    t        | j                        S rb   )ra  rI  r   s    r   r   zBXMLPullParserTest.test_events_sequence.<locals>.DummyIter.__next__d  s    DKK((r   N)rO   rP   rQ   r  r  r   r   r   r   	DummyIterr  _  s    A)r   r  )r   r  r  r  )rE   eventsetr-  r  s       r   test_events_sequencez&XMLPullParserTest.test_events_sequenceX  s    7#!!!2

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

6+,v(8.'IJr   c                     | j                  t              5  t        j                  d       d d d        y # 1 sw Y   y xY w)NrY  rH  )r   r   r   r  r   s    r   test_unknown_eventz$XMLPullParserTest.test_unknown_eventk  s.    z*$=> +**s   6?r      r   zExpat z" does not support reparse deferralc                 .   t         j                  d      }dD ]  }|j                  |        | j                  |g        t         t        u r3| j                  |j                  j                  j                                |j                          | j                  |dg       t         t        u r3| j                  |j                  j                  j                                |j                  d       |j                          | j                  |dg       y )NrJ  rH  z<docr  rK  r\  </doc>r>  r\  )
r   r  r(  r  r   r   _parserGetReparseDeferralEnabledr  r)  rE   r-  chunks      r   #test_flush_reparse_deferral_enabledz5XMLPullParserTest.test_flush_reparse_deferral_enabledo  s     !!)9!:"EKK # 	vr*:OOFNN22LLNOv(8'9::OOFNN22LLNOHv'78r   c                    t         j                  d      }dD ]  }|j                  |        t        j                  dk\  rTt         t
        ur| j                  d       |j                  j                  j                  d       | j                  |g        t         t
        u r3| j                  |j                  j                  j                                |j                          | j                  |dg       t         t
        u r3| j                  |j                  j                  j                                |j                  d       |j                          | j                  |d	g       y )
NrJ  rH  r  r  zDXMLParser.(Get|Set)ReparseDeferralEnabled methods not available in CFr  r  r   )r   r  r(  pyexpatversion_infor   skipTestr  SetReparseDeferralEnabledr  rb  r  r  r)  r  s      r   $test_flush_reparse_deferral_disabledz6XMLPullParserTest.test_flush_reparse_deferral_disabled  s   !!)9!:"EKK # 9,: !; <NN""<<UC""62.:V^^33MMOPv(8'9::V^^33MMOPHv'78r   )NFrb   )rO   rP   rQ   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  unittestskipIfr  r  r  r  r   r   r   r  r  t  s    
#
**77,
***.6,*\O&MK&? X__W))I5g223 40 01919*9r   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	y)XIncludeTestNc                 ~    	 t         |   }|dk(  rt        j	                  |      }|S # t        $ r t        d      w xY w)Nresource not foundr  )XINCLUDEKeyErrorOSErrorr   r   )rE   hrefr"  rT   r:   s        r   xinclude_loaderzXIncludeTest.xinclude_loader(  sH    	0D>D E>66$<D	  	0.//	0s   	' <c                      y rb   r   )rE   r   r-  rT   s       r   none_loaderzXIncludeTest.none_loader1  s    r   c                     |dk(  r9t        |d      5 }t        j                  |      j                         cd d d        S y # 1 sw Y   y xY w)Nr  r[  )r$  r   r"  r   )rE   r   r"  r,  s       r   
_my_loaderzXIncludeTest._my_loader4  sA     E>dD!Qxx{**, "!  "!s   #A  A	c                     ddl m} | j                  d      }|j                  || j                         | j                  t        |      d       y )Nr   r@   r  z<document>
  <p>Example.</p>
  <root>
   <element key="value">text</element>
   <element>text</element>tail
   <empty-element />
</root>
</document>)rD   rA   r!  includer%  r   r`   )rE   rA   r\  s      r   test_xinclude_defaultz"XIncludeTest.test_xinclude_default=  sB    ,""=1sDOO43	r   c                 ~   ddl m} | j                  d      }|j                  || j                         | j	                  t        |      d       | j                  d      }|j                  || j                         | j	                  t        |      d       | j                  d      }|j                  || j                         | j	                  t        |      d       | j                  d	      }|j                  || j                         | j	                  t        |      d
       | j                  d      }| j                  t              5 }|j                  || j                         d d d        | j	                  t        j                        d       | j	                  t        |      d       y # 1 sw Y   JxY w)Nr   r@   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>)
rD   rA   r!  r'  r   r`   r   r  r   r   rE   rA   r]  r   s       r   test_xincludezXIncludeTest.test_xincludeK  s   , ''1x)=)=>8,	 ''1x)=)=>8,	 ''	2x)=)=>8,	 ''1x)=)=>8,	 ''1w'2""8T-A-AB (R\\*,@A8,		 ('s   F33F<c                     ddl m} | j                  d      }|j                  || j                         | j	                  dt        |j                  d                   y )Nr   r@   r  r   z.//p)rD   rA   r!  r'  r   r   r   )rE   rA   r]  s      r   test_xinclude_repeatedz#XIncludeTest.test_xinclude_repeated  sL    ,''(ABx)=)=>H$4$4V$< =>r   c                 
   ddl m} t        j                  t        d         }| j                  |j                        5 }|j                  || j                         d d d        | j                  t        j                        d       t        j                  t        d         }| j                  |j                        5 }|j                  || j                         d d d        | j                  t        |j                        d       t        j                  t        d         }| j                  |j                        5 }|j                  || j                         d d d        | j                  t        |j                        d	       t        j                  t        d
         }| j                  |j                        5 }|j                  || j                         d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                         d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                  d        d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                  d       d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                  d       d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                  d       d d d        | j                  t        |j                        d       | j                  d      }| j                  |j                        5 }|j                  || j                  d       d d d        | j                  t        |j                        d       y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   %xY w# 1 sw Y   xY w# 1 sw Y   QxY w# 1 sw Y   xY w# 1 sw Y   {xY w# 1 sw Y   xY w# 1 sw Y   xY w)Nr   r@   r  )r{   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  )rD   rA   r   r   r  r   FatalIncludeErrorr'  r#  r   r   r   XINCLUDE_BADr!  LimitedRecursiveIncludeErrorr*  s       r   test_xinclude_failuresz#XIncludeTest.test_xinclude_failures  si   , 66(8,-~??@B""8D4D4D"E AR\\*7	9 66(8,-~??@B""8D4D4D"E AR\\*3	5 66,x01~??@B""8D4D4D"E AR\\*C	E 66,x01~??@B""8D4D4D"E AR\\*@	A
 ''(89~??@B""8T-A-AB AR\\*5	7 ''(89~??@B""8T-A-AT"R AR\\*5	7 ''(89~JJKr""8T-A-AQ"O LR\\*S	U ''(89~JJKr""8T-A-AQ"O LR\\*S	U ''(89~JJKr""8T-A-AQ"O LR\\*S	U ''(89~??@B""8T-A-AQ"O AR\\*5	7} A@ A@ A@ A@ A@ A@ LK LK LK A@sw   S S+S8T;T1T)T,!T9UUS(+S58TTTT),T69UUU)r  Nrb   )
rO   rP   rQ   r!  r#  r%  r(  r+  r-  r3  r   r   r   r  r  &  s'    >@?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 Z#y) BugsTestc                      fd}t         j                  d      } ||       t         j                  d      }d|_         ||       t         j                  d      }d|_         ||       t         j                  d      }|j	                  dd        ||       t         j                  d      }|j	                  dd        ||       y )Nc                     j                  t              5 }t        |        d d d        j                  t	        j
                        d       y # 1 sw Y   /xY w)Nzcannot serialize 123 (type int))r   	TypeErrorr`   r   r   r   )r[   r   rE   s     r   r  z-BugsTest.test_bug_xmltoolkit21.<locals>.check  sD    ""9-$ .S.57 .-s   AA{   r[   123)r   r   r   r   r   )rE   r  r[   s   `  r   test_bug_xmltoolkit21zBugsTest.test_bug_xmltoolkit21  s    	7 zz#dzz&!	dzz&!	dzz&!edzz&!dr   c                     t         j                  t              }t         j                  |      }| j	                  |j                  d      d       | j	                  |j                  d      d       y )Nrd   r   r   ro  )r   r   r   r?   r   r   )rE   r[   r_   s      r   test_bug_xmltoolkit25zBugsTest.test_bug_xmltoolkit25  sR     vvj!~~d#u-v6}5yAr   c                     t         j                  d      }| j                  t        |j	                  d            g        | j                  t        |j	                  d            dg       y )N"<doc><table><tbody/></table></doc>z.//theadz.//tbodytbody)r   r   r   rf   r   rE   r_   s     r   test_bug_xmltoolkit28zBugsTest.test_bug_xmltoolkit28  sQ     vv:;Z(@A2FZ(@AG9Mr   c                     t         j                  d      }t        j                         5 }t         j	                  |       | j                  |j                         d       d d d        y # 1 sw Y   y xY w)Nr?  z$<doc><table><tbody /></table></doc>
)r   r   r   r  r  r   rY   )rE   r_   r  s      r   test_bug_xmltoolkitX1zBugsTest.test_bug_xmltoolkitX1	  sP     vv:;$$&&GGDMV__.0WX '&&s   6A))A2c                    t         j                  d      }| j                  t         j                  |d      d       t         j                  d      }| j                  |j                  ddi       | j                  t         j                  |d      d       t         j                  d      }| j                  t         j                  |d      d	       t         j                  d
      }| j                  t         j                  |d      d       t         j                  d      }|j                  dd       | j                  t         j                  |d      d       y )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   rd   )r   r   r   r  r   r   r   rA  s     r   test_bug_xmltoolkit39zBugsTest.test_bug_xmltoolkit39  s    vvNOT735FGvv 6 7y*&=>T735	7 vv / 0T730	2 zz*%T735FGzz% l+T735	7r   c                     t         j                  d      }| j                  t        |d      d       | j                  t        |      d       y )Nz=<!DOCTYPE doc [<!ENTITY ldots '&#x8230;'>]><doc>&ldots;</doc>r  r  s   <doc>&#33328;</doc>u   <doc>舰</doc>r<  r9  s     r   test_bug_xmltoolkit54zBugsTest.test_bug_xmltoolkit54*  sF     FF ( )1z:&	(1':;r   c                     | j                  t        j                        5 }t        j                  d       d d d        | j	                  t        j                        d       y # 1 sw Y   /xY w)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   )rE   r   s     r   test_bug_xmltoolkit55zBugsTest.test_bug_xmltoolkit553  sU     r}}-FF 7 8 . 	R\\*=	? .-s   A$$A-c                 l     G d d      }| j                  t        t        j                   |              y )Nc                       e Zd Zd Zy)5BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFilec                     t         rb   )r  rE   r   s     r   r%  z:BugsTest.test_bug_xmltoolkit60.<locals>.ExceptionFile.read@  s    r   N)rO   rP   rQ   r%  r   r   r   ExceptionFilerM  ?  s    r   rP  )r   r  r   r"  )rE   rP  s     r   test_bug_xmltoolkit60zBugsTest.test_bug_xmltoolkit60<  s&    	 	 	'288]_=r   c                    ddd}t         j                         }|j                  j                  |       |j	                  d       |j                         }| j                  |j                  d      j                  d       y )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&  r?  updater(  r)  r   r   r   )rE   ENTITIESr-  ts       r   test_bug_xmltoolkit62zBugsTest.test_bug_xmltoolkit62E  sl     &9X& % 	& LLN/44K	Mr   zSkips under coverage.c                     d } |        t        j                  d       }t        d      D ]	  } |         | j                  t        j                  d       |       y )Nc                      t         j                         } | j                  di        | j                  d       | j	                  d       y )Nrd   r   )r   r*  rK  r:   r>  )r_   s    r   xmltoolkit63z4BugsTest.test_bug_xmltoolkit63.<locals>.xmltoolkit63Y  s3    >>#DJJub!IIfHHUOr   i  )rp   getrefcountr   r   )rE   r[  countr   s       r   test_bug_xmltoolkit63zBugsTest.test_bug_xmltoolkit63V  sH    	 	%tAN .6r   c           	         t         j                  dd      }| j                  t         j                  |      d       | j                  t         j	                  t         j                  |            j                  d      d       | j                  t         j                  t         j	                  t         j                  |                  d       y )NSomeTagzdef _f():
  return 3
r   s0   <SomeTag text="def _f():&#10;  return 3&#10;" />r   )r   r   r   r  r   rw   r9  s     r   test_bug_200708_newlinez BugsTest.test_bug_200708_newlinee  s     JJy'@JAQC	EA/33F;)	+RVVBKKN%;<C	Er   c                 b   t         j                         }|j                  d       | j                  |j	                         j
                  d        G d d      }t         j                   |             }|j                  d       | j                  |j	                         j
                  d       y )Nz<element>some text</element>r   c                       e Zd Zd Zy)2BugsTest.test_bug_200708_close.<locals>.EchoTargetc                 ,    t         j                  d      S )Nr   r   r   r   s    r   r)  z8BugsTest.test_bug_200708_close.<locals>.EchoTarget.closex  s    zz),,r   NrO   rP   rQ   r)  r   r   r   
EchoTargetre  w  s    -r   ri  r   )r   r&  r(  r   r)  rd   )rE   r-  ri  s      r   test_bug_200708_closezBugsTest.test_bug_200708_closep  s}    23++Y7	- 	- Z\223++Y7r   c                    t         j                  d      }t         j                  |d      }| j                  t	        |d      d       t         j                  d      }t         j                  |d      }t         j                  |d      }| j                  t	        |d      d       t         j                  d      }t         j                  |d      }t         j                  |d      }| j                  t              5 }t	        |d       d d d        | j                  t        j                        d       y # 1 sw Y   /xY w)	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>r[   z<cannot use non-qualified names with default_namespace option)	r   r   rq  r   r`   r   r   r   r   )rE   r   sr   s       r   !test_bug_200709_default_namespacez*BugsTest.test_bug_200709_default_namespace~  s    JJ'MM!_-1	B7	9 JJ'MM!_-MM!011	B	 JJ'MM!_-MM!V$z*ba95 +R\\*N	P +*s   =D99Ec                    t         j                  d      }| j                  t         j                  |      d       t         j	                  dd       t         j                  d      }| j                  t         j                  |      d       t         j                  d      }| j                  t         j                  |      d       y )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_namespacer9  s     r   "test_bug_200709_register_namespacez+BugsTest.test_bug_200709_register_namespace  s    JJHIQQ	S
e%OPJJHIQQ	S
 JJ@AQG	Ir   c                    t         j                  d      }|j                  t         j                  d             | j	                  |d   j
                  t         j                         t         j                  d      }|j                  t         j                  d             | j	                  |d   j
                  t         j                         y )Nr   r  r   )r   r   r   rr  r   rd   r   )rE   r   s     r   test_bug_200709_element_commentz(BugsTest.test_bug_200709_element_comment  s     JJsO	E"#12::.JJsO	u1255)r   c                 l   t         j                  d      }t         j                  |d      }t         j                  |d      }t         j                  d      }|j                  d|       | j	                  t        |      g d       |j                  d|       | j	                  t        |      g d       y )	Nr   r   r   r   r   )r   r   r   r  )r   r   r   r   )r   r   rq  r   r   rf   rE   r   r   r   r   s        r   test_bug_200709_element_insertz'BugsTest.test_bug_200709_element_insert  s    JJsOMM!S!MM!S!JJsO	A*O<	Q*,@Ar   c                 4   t         j                  d      }t         j                  |d      }t         j                  d      }|j	                  |       | j                  t        |j                  t         j                              t         j                  g       y )Nr   r   zTEST-b)r   r   rq  rr  r   r   rf   r   )rE   r   r   	comment_bs       r   test_bug_200709_iter_commentz%BugsTest.test_bug_200709_iter_comment  sa    JJsOMM!S!JJx(		rzz(:;bjj\Jr   c                     t         j                         }|j                  d      }|j                  di       }|j	                  d      }|j                         }| j                  t        |      d       y )Nr:   rd   r  )r   r*  r:   rK  r>  r)  r   r`   )rE   r   r   s      r   test_bug_1534630zBugsTest.test_bug_1534630  sX    nnHHVIIeR GGENIIK1y1r   c                     t         j                  d      }| j                  t         j                  |d      d       t         j                  d      }| j                  t         j                  |d      d       y )Ns7   <?xml version='1.0' encoding='utf-8'?><body>tãg</body>r2  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  r9  s     r   test_issue6233zBugsTest.test_issue6233  sj    FF . /Q0)	* FF * +Q0)	*r   c                     t         j                  d      }| j                  t        |      dg       t         j                  t              }|d d  |d d  | j                  t        |      g d       y )Nr   rd   rd   rd   r_  )r   r   r   rf   r   )rE   r[   newelems      r   test_issue6565zBugsTest.test_issue6565  sY    vv+,-w7&&$!*Q-/HIr   c                 \    t         j                  dd       t         j                  dd       y )N	test10777zhttp://myuri/)r   ro  r   s    r   test_issue10777zBugsTest.test_issue10777  s$     	k?;
k?;r   c                 2    G fdd      }t         j                  d       |       _        j                         }t	        |      }| j                  ||       | j                  j                  t               | j                  j                  d       y )Nc                       e Zd Z fdZy)%BugsTest.test_lost_text.<locals>.Textc                     d_         y)NchangedTra  r9  s    r   __bool__z.BugsTest.test_lost_text.<locals>.Text.__bool__  s    "r   NrO   rP   rQ   r  r   s   r   r   r        r   r   rd   r  )r   r   r   r   ra  r   r   r   rE   r   r   rW  r   s       @r   test_lost_textzBugsTest.test_lost_text  sr    	 	
 JJuJJLGa&affc*+r   c                     G fdd      }t         j                  d      j                  t         j                  d              |       d   _        j	                         }t        |      }| j                  ||       | j                  d   j                  t               | j                  d   j                  d       y )Nc                       e Zd Z fdZy)%BugsTest.test_lost_tail.<locals>.Textc                     dd   _         yNr  r   T)r   r9  s    r   r  z.BugsTest.test_lost_tail.<locals>.Text.__bool__  s    %!	r   Nr  r  s   r   r   r    r  r   r   rA  rd   r   r  )	r   r   r   r   r   ra  r   r   r   r  s       @r   test_lost_tailzBugsTest.test_lost_tail  s    	 	
 JJv	E"#F!	JJLGa&adii-1I.r   c                     G fdd      }t         j                  d      j                  t         j                   |                    j                  t         j                  d             j                  d      	 t	              }| j                  j                  |       | j                  d   j                  t               | j                  d   j                  d       y # t
        $ r | j                  d       Y {w xY w)Nc                       e Zd Z fdZy)$BugsTest.test_lost_elem.<locals>.Tagc                 L    t         j                  d      d<   t               yr  )r   r   ra  )rE   r
  r   r   s     r   r   z+BugsTest.test_lost_elem.<locals>.Tag.__eq__	  s    zz),!Qr   NrO   rP   rQ   r   )r   r   s   r   r   r  	  s    r   r   rA  rd   zgenerators are not reentrantr   r  )r   r   r   r   ra  r   r	  r   rd   r   r   )rE   r   rW  r   r   s      @@r   test_lost_elemzBugsTest.test_lost_elem	  s    	 	 JJv	CE"#	E"#FF5M	:QA 	aeeS)adhh,19-	  	:MM89	:s   C. .D
Dc                     d|z  }t         j                  |      }| j                  |j                  d      |j	                  d             y )Ns   <a b="%s"/>r   r   )r   r   r   rw   decode)rE   r   r  rA  s       r   check_expat224_utf8_bugz BugsTest.check_expat224_utf8_bug	  s:    t#vvc{#G(<=r   c                 P    d}| j                  |       d}| j                  |       y )Ns   ààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààs  xàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r  r  s     r   test_expat224_utf8_bugzBugsTest.test_expat224_utf8_bug	  s*     "$$T*($$T*r   c                 h   t        t        d      5 }|j                         }d d d        t        j	                        }|j                  d      }|j                  d      j                         }|j                  dd      }|dd }| j                  |j                  d      |       y # 1 sw Y   xY w)Nr[  r   r   r  r  r  )
r$  UTF8_BUG_XMLFILEr%  r   r   rw   r  stripr6   r   )rE   fprawrA  xmlattrr   s         r   test_expat224_utf8_bug_filez$BugsTest.test_expat224_utf8_bug_file*	  s    "D)R'')C *}}S!((3- zz'"((*||FC(Abz#- *)s   B((B1c                     | j                  t        t        j                         j                  d       | j                  t        t        j                         j                  dd        y )Nrd   )r   r8  r   r*  rK  r   s    r   test_39495_treebuilder_startz%BugsTest.test_39495_treebuilder_start7	  sB    )R^^%5%;%;UC)R^^%5%;%;UDIr   c           	         | j                  t        t        j                  d      j                  d t        d      D               | j                  t        t        j                  d      j                  d        d | j                  t        dt        j                  d      j                  fdt        d      D               y )Nrd   c              3   &   K   | ]	  }d dz    ywr   r   Nr   .0r   s     r   	<genexpr>zEBugsTest.test_issue123213_correct_extend_exception.<locals>.<genexpr>>	  s     111Q3   r   c                      t        d      N	mymessager8  r   r   r   r,  z=BugsTest.test_issue123213_correct_extend_exception.<locals>.fD	      K((r   r  c              3   ,   K   | ]  }          y wrb   r   r  r   r,  s     r   r  zEBugsTest.test_issue123213_correct_extend_exception.<locals>.<genexpr>I	  s     &=HqqsH   )r   ZeroDivisionErrorr   r   r   r   r8  r  )rE   r,  s    @r   )test_issue123213_correct_extend_exceptionz2BugsTest.test_issue123213_correct_extend_exception;	  s    +RZZ->-E-E1a1	3 	)RZZ%6%=%=tD	) 	{JJu$$&=E!H&=	?r   N)$rO   rP   rQ   r;  r=  rB  rD  rF  rH  rJ  rQ  rX  r  r  rp   gettracer^  rb  rj  rm  rp  rr  ru  rx  rz  r|  r  r  r  r  r  r  r  r  r  r  r   r   r   r5  r5    s    8BNY72<?>M" X__\S\\^%<=7 >7	E8P.I
*BK2
*J<,/ .(>

+.J?r   r5  c                   B    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)BasicElementTestc                    d}ddi}t         j                  ||      }| j                  |t         j                         | j                  dt	        |             | j                  dt	        |             | j                  dt	        |             | j                  dt	        |             | j                  |j                  |       | j                  |j                         | j                  |j                         | j                  |j                  |       | j                  |j                  |       d|d	<   | j                  |j                  |       | j                  |j                  |       y )
Nr  zixwyprd   r   r   r   bazr   )r   r   r   r   r   r   rd   r   r   r   r  r   r  )rE   rd   r   element_foos       r   test___init__zBasicElementTest.test___init__R	  s&   %!jjf- 	k2::6eS-.hK 01fc+./fc+./ 	#.+**++**+ 	++V4++V4 u++V4K..7r   c                    t         j                  dddi      }|j                  t         j                  dddi             t        j                  |      }| j	                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |             t        j                  ||      D ]  \  }}| j                  ||        | j                  |j                  |j                         y Nr  r  r  r   r  qix)r   r   r   r  r  r   rd   r   r   r   	itertoolszip_longestassertIsr   rE   r  element_foo2r  r  s        r   test___copy__zBasicElementTest.test___copy__m	  s   jj%(892::eue-=>?yy- 	{3 	));??;**K,<,<=**K,<,<= 	\*C,<= !* 5 5k< PVVMM&&) !Q 	,,k.@.@Ar   c                    t         j                  dddi      }|j                  t         j                  dddi             t        j                  |      }| j                  ||       | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         | j                  t        |      t        |             t        j                  ||      D ]  \  }}| j                  ||        | j                  |j                  |j                         | j                  |j                  |j                         d|j                  d<   | j                  |j                  |j                         | j                  |j                  |j                         y r  )r   r   r   r  r  r  r   rd   r   r   r   r  r  r   r  r  s        r   test___deepcopy__z"BasicElementTest.test___deepcopy__	  sx   jj%(892::eue-=>?}}[1 	{3 	));??;**K,<,<=**K,<,<= 	\*C,<= !* 5 5k< PVVVV, !Q 	,,k.@.@A,,k.@.@A %*5!,,k.@.@AL//1C1CDr   c                 R   t         j                  d      }| j                  t        |j                  d       | j                  t        |j
                  t         j                  d      dg       | j                  t        |j                  dd       t         j                  d      g|d d  | j                  t              5  d|d<   d d d        | j                  t              5  t         j                  d      dg|d d  d d d        t        |d      r*dd gdd	d
d}| j                  t        |j                  |       t        |d      rK G d dt         j                        } |d      g|d d  | j                  t        t        j                  |       y y # 1 sw Y   xY w# 1 sw Y   xY w)Njoer   r   r  r   __setstate__rd   r   r   r   )rd   	_childrenr   r   r   __deepcopy__c                       e Zd Zd Zy)9BasicElementTest.test_augmentation_type_errors.<locals>.Ec                      y rb   r   )rE   memos     r   r  zFBasicElementTest.test_augmentation_type_errors.<locals>.E.__deepcopy__	  s    r   N)rO   rP   rQ   r  r   r   r   Er  	  s     r   r  )r   r   r   r8  r   r   r   r   r  r  r  )rE   r   stater  s       r   test_augmentation_type_errorsz.BasicElementTest.test_augmentation_type_errors	  sO   JJu)QXXs3)QXX

50A5/IJ)QXXq%8

5!"!y)AaD *y)JJu%u-AaD * 1n%"V E i?1n% BJJ   eH:AaDi: & *)))s   =F FFF&c                     G d d      } |       }t         j                  d|      |_        t        j                  |      }~t                | j                   |              t         j                  d      } |       }||_        t        j                  |      }t         j                  |d|      }~~~t                | j                   |              t         j                  d      }t         j                  d      }t         j                  d      }|j                  |       |j                  |       |j                  |       t        j                  |      }~~~t                | j                   |              y )	Nc                       e Zd Zy).BasicElementTest.test_cyclic_gc.<locals>.DummyNrO   rP   rQ   r   r   r   Dummyr  	      r   r  r  )r   r  r  r  r  )	r   r   dummyrefweakrefrefr   r   rq  r   )rE   r  r   wrefr   r  r  r  s           r   test_cyclic_gczBasicElementTest.test_cyclic_gc	  s   	 	 GZZAZ.
{{1~$&! JJuG
{{1~]]1e!],q"$&! ZZZZZZ
		"
		"
		"{{2B$&!r   c                    dfd}t         j                  d      }t        j                  ||      }| j	                   |       j
                  d       ~t                | j	                  d       | j	                   |       d        y )NFc                 
    dy NTr   )wflags    r   wref_cbz.BasicElementTest.test_weakref.<locals>.wref_cb	  s    Dr   r   T)r   r   r  r  r   rd   r   )rE   r  r   r  r  s       @r   test_weakrefzBasicElementTest.test_weakref	  sl    	 JJsO{{1g&S)t$&r   c                     t         j                  dddd      }| j                  |j                  dd      d       | j                  |j                  d	d      d       y )
Nr  r   r   r  )r   r   zr      )r	  r  )r   r   r   rw   )rE   r  s     r   test_get_keyword_argsz&BasicElementTest.test_get_keyword_args	  sR    ZZ!qAZ.Q/3Q/3r   c           	         t        dt        j                  dz         D ]6  }t        | j                  d      D ]  \  }}|j                  dd      }d|_        d|_        |j                  |d	      j                  |j                  d
             |j                  |j                  d	             |j                  d      d   j                  dd       | j                  |d|||      }| j                  |j                  d       | j                  |j                  d   d       | j                  t!        |      d       | j#                  ||        9 y )Nr   r   repeatr  *   )r   ztext goes herezopposite of headchild
grandchildz.//grandchildr   r   zother valuerH   r   )r   rq   HIGHEST_PROTOCOLr   rk   r   r   r   rq  r   r   r   r   r   rd   r   r   r   )rE   r|   rz   r{   r   r  s         r   test_picklezBasicElementTest.test_pickle	  s"   1f559:E")$,,q"A"ANN5bN1)+!!!W-44V^^L5QR01		/*1-11&-H))!-D*0&%A   /  5!126  R!,((B/ #B ;r   c           	         t        dt        j                  dz         D ]  }t        | j                  d      D ]  \  }}d}|j                  |      }| j                  |j                         d   d       | j                  |d|||      }| j                  |j                  d       | j                  |d   j                  d	         y )
Nr   r   r  z\<?xml version="1.0"?>
                    <group><dogs>4</dogs>
                    </group>rd   grouprH   r   dogs)
r   rq   r  r   rk   r   r   __getstate__r   rd   )rE   r|   rz   r{   XMLTEXTr  r  s          r   test_pickle_issue18997z'BasicElementTest.test_pickle_issue18997
  s    1f559:E")$,,q"A  &&w/  !25!97C))".E*0&%A  1  AF3 #B ;r   N)rO   rP   rQ   r  r  r  r  r  r  r  r  r  r   r   r   r  r  P	  s2    86B0E<;8!"F'4
0&4r   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 ej                  d      d        Zd Zd Zd Zd Zd Zd Zy)BadElementTestc                 ,    G fdd      } |       gt         j                  d      }	 |j                          G d d|t         j                        } |d      gt         j                  d      }|j                         y # t        $ r Y Uw xY w)Nc                   "    e Zd Ze fd       Zy)2BadElementTest.test_extend_mutable_list.<locals>.Xc                 V    t         j                  d      gd d  t         j                  S )Nr  rg  rE   Ls    r   	__class__z<BadElementTest.test_extend_mutable_list.<locals>.X.__class__
  s"    

5)*!zz!r   NrO   rP   rQ   propertyr  r  s   r   Xr  
      " "r   r  r  c                       e Zd Zy)2BadElementTest.test_extend_mutable_list.<locals>.YNr  r   r   r   Yr  $
  r  r   r  r   r   r   r   r8  rE   r  r   r  r  s       @r   test_extend_mutable_listz'BadElementTest.test_extend_mutable_list
  s    	" 	"
 SEJJu	HHQK	2:: 	sVHJJu	  		s   B 	BBc                 |    G fdd      } |       t         j                  d      gt         j                  d      }	 |j                          G d d|t         j                        } |d      t         j                  d      gt         j                  d      }|j                         y # t        $ r Y iw xY w)Nc                   "    e Zd Ze fd       Zy)3BadElementTest.test_extend_mutable_list2.<locals>.Xc                 .    d d = t         j                  S rb   rg  r  s    r   r  z=BadElementTest.test_extend_mutable_list2.<locals>.X.__class__,
  s    aDzz!r   Nr  r
  s   r   r  r  +
  r  r   r  r  r  c                       e Zd Zy)3BadElementTest.test_extend_mutable_list2.<locals>.YNr  r   r   r   r  r  7
  r  r   r  r   r  r  s       @r   test_extend_mutable_list2z(BadElementTest.test_extend_mutable_list2*
  s    	" 	"
 S"**U#$JJu	HHQK	2:: 	uXrzz%()JJu	  		s    B/ /	B;:B;c                 (    | j                  d       y NTraisesdo_test_remove_with_clearr   s    r   %test_remove_with_clear_assume_missingz4BadElementTest.test_remove_with_clear_assume_missing=
  s     	&&d&3r   c                 (    | j                  d       y NFr  r  r   s    r   &test_remove_with_clear_assume_existingz5BadElementTest.test_remove_with_clear_assume_existingB
  s     	&&e&4r   c          	           G d dt         j                        } G fdd|      } G fdd|      }r fd}nt        } j                  |j                  t
        j                         |df|d	ffD ]b  \  }} j                   j                  |
             ||df||df||dffD ]g  \  }}	}
 j                  |
      5   |d      j                   |	d      g        |       5  j                   |d             d d d        d d d        i  j                  ||      }|D ]o  \  }}	}}
 j                  |
      5   |d      j                   |	d       |d      g        |       5  j                   |d             d d d        d d d        q  j                  d      5   |d      j                   |d             t        |      5 }t        |      5 }j                  d          d d d        d d d        j                          j                          d d d        t               xr xr ||u }t               rr||u r j                  ||      }|D ]k  \  }}	}
 j                  |
      5   |d      j                   |	d       |d      g        |       5  j                  d          d d d        d d d        m e y # 1 sw Y   xY w# 1 sw Y   HxY w# 1 sw Y   oxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   rxY w# 1 sw Y   xY w)Nc                       e Zd ZdZy)3BadElementTest.do_test_remove_with_clear.<locals>.Ez:Local class to be able to mock E.__eq__ for introspection.N)rO   rP   rQ   __doc__r   r   r   r  r&  N
  s    Lr   r  c                       e Zd Z fdZy)3BadElementTest.do_test_remove_with_clear.<locals>.Xc                     d d =  S rb   r   rE   or  rA  s     r   r   z:BadElementTest.do_test_remove_with_clear.<locals>.X.__eq__R
  s    G!z!r   Nr  r  rA  s   r   r  r)  Q
      "r   r  c                       e Zd Z fdZy)3BadElementTest.do_test_remove_with_clear.<locals>.Yc                 *    j                           S rb   )r   r+  s     r   r   z:BadElementTest.do_test_remove_with_clear.<locals>.Y.__eq__W
  s    

!z!r   Nr  r-  s   r   r  r0  V
  r.  r   r  c                  .     j                  t              S rb   r   r   r   s   r   <lambda>z:BadElementTest.do_test_remove_with_clear.<locals>.<lambda>\
      $*;*;J*Gr   zdel root[:]zroot.clear())side_effectzremove missing E() from [Z()]zremove missing Z() from [E()]zremove missing Z() from [Z()]toponemissingtwozremove root[0] from [Z()]remr   r   )r   r   r   r  r   r"   enterContextr  r   r   'cases_for_remove_missing_with_mutationsr   r%   assert_not_calledr   (cases_for_remove_existing_with_mutations)rE   r  r  r  r  get_checker_contextZr6  RUdescriptioncasesVr,  g
is_specialrA  s   ``              @r   r  z(BadElementTest.do_test_remove_with_clearG
  s   	M

 	M	" 	"
	" 	"
 "G"-ahh. !=1A~3FGNA{dll{lCD A67A67A67&!1k
 \\+.U8DKK5
+,.AiL1 / /.& @@AFE(-$1a\\+.U8DKK51U8 45,.AiL1 / /. ). 9:xAeH%"1%M!,<KKQ( -=%##%##% ; 23II16J')fa EEaK).%Aq+k2 xQuXqx$8902 KKQ0 3 32 */k H /. /. /. /. -=,<%% ;:: 32 32s   (K-/K 	K-/L5K:	L0+L.L!'L	<L!(L./M5L;	
M K*%K--K7:L?LLLL!!L+&L..L8	;M MMc                 (    | j                  d       y r  do_test_remove_with_mutate_rootr   s    r   +test_remove_with_mutate_root_assume_missingz:BadElementTest.test_remove_with_mutate_root_assume_missing
  s     	,,D,9r   c                 (    | j                  d       y r"  rJ  r   s    r   ,test_remove_with_mutate_root_assume_existingz;BadElementTest.test_remove_with_mutate_root_assume_existing
  s     	,,E,:r   c                   
 t         j                  } G 
fdd|      }r fd}nt        } j                  ||      }|D ]o  \  }}}}	 j	                  |	      5   |d      

j                   |d       |d      g        |       5  
j                   |d             d d d        d d d        q  j                  ||      }|D ]k  \  }}}	 j	                  |	      5   |d      

j                   |d       |d      g        |       5  
j                  
d	          d d d        d d d        m y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   -xY w# 1 sw Y   xY w)
Nc                       e Zd Z fdZy)9BadElementTest.do_test_remove_with_mutate_root.<locals>.Zc                     d=  S r  r   r+  s     r   r   z@BadElementTest.do_test_remove_with_mutate_root.<locals>.Z.__eq__
  s    G!z!r   Nr  r-  s   r   rA  rQ  
  r.  r   rA  c                  .     j                  t              S rb   r3  r   s   r   r4  z@BadElementTest.do_test_remove_with_mutate_root.<locals>.<lambda>
  r5  r   r7  r8  r:  r9  r;  r   )r   r   r   r=  r  r   r   r?  )rE   r  r  rA  r@  rE  rB  rC  rF  rD  rA  s   ``        @r   rK  z.BadElementTest.do_test_remove_with_mutate_root
  s;   JJ	" 	"
 "G"- <<QB$) Aq![k*xQuXqx01(*KK)- + +* %* ==aC!&Aq+k*xQuXqx01(*KKQ( + +* "' +* +* +* +*sH   /ED9$E"/EE&E9E>EE	EEE'	c              #   &  K   ||f||f||ffD ]7  \  }}d|j                    d|j                    d|j                    d}||||f 9 ||f||f||f||ffD ]7  \  }}d|j                    d|j                    d|j                    d}||||f 9 y w)Nzremove missing z	() from [(), ()]rO   )rE   r  rA  rC  rF  rD  s         r   r=  z6BadElementTest.cases_for_remove_missing_with_mutations
  s      VaVaV,DAq,QZZL 9 zzl$qzzl#?KQ;&& -
 VaVaVaV4DAq,QZZL 9 zzl$qzzl#?KQ;&& 5s   BBc              #      K   ||df||df||dffD ]7  \  }}}d|j                    d|j                    d|j                    d}|||f 9 y w)Nzremove root[1] from [E(), Z()]zremove root[1] from [Z(), E()]zremove root[1] from [Z(), Z()]zremove root[1] (of type z) from [rU  rV  rW  )rE   r  rA  rC  rB  rD  s         r   r?  z7BadElementTest.cases_for_remove_existing_with_mutations
  sy      343434"
Aq+
 6ajj\ B$$%JJ<tAJJ<sDKQ##"
s   A
A   c                     t         j                  d      }t        |d|      5  | j                  t              5  t        |       d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr  rd   )r   r   r   r   RuntimeErrorr   r9  s     r   test_recursive_reprz"BadElementTest.test_recursive_repr
  sP     JJuq%#""<0Q 1 $#00 $#s"   A"AA"A	A""A+c                 `    G fddt               }t        j                         }|j                  di        |j	                  d       |j	                   |d             |j	                  d       |j                  d       |j                         | j                  j                  d       y )Nc                       e Zd Z fdZy)/BadElementTest.test_element_get_text.<locals>.Xc                 >    	 j                    y # t        $ r Y y w xY wrb   )r   	NameErrorrs  s    r   __del__z7BadElementTest.test_element_get_text.<locals>.X.__del__
  s!    II  s    	NrO   rP   rQ   rb  r[   s   r   r  r_  
      r   r  rd   ABCDEFGHIJKLABCDEFGHIJKL)	r   r   r*  rK  r:   r>  r)  r   r   rE   r  r   r[   s      @r   test_element_get_textz$BadElementTest.test_element_get_text
  s{    	 	 NN	r	v	qy	v	ewwyN3r   c                     G fddt               }t        j                         }|j                  di        |j                  di        |j	                  d       |j                  d       |j                   |d             |j                  d       |j	                  d       |j                         | j                  d   j                  d	       y )
Nc                       e Zd Z fdZy)/BadElementTest.test_element_get_tail.<locals>.Xc                 D    	 d   j                    y # t        $ r Y y w xY wr  )r   ra  rs  s    r   rb  z7BadElementTest.test_element_get_tail.<locals>.X.__del__
  s%    GLL  s    	Nrc  rd  s   r   r  rn  
  re  r   r  rA  rd   rf  rg  rh  r   ri  )	r   r   r*  rK  r>  r:   r)  r   r   rj  s      @r   test_element_get_tailz$BadElementTest.test_element_get_tail
  s    	 	 NN		r	e	v	qy	v	fwwya~6r   c                     G fdd      }t         j                  d      j                  t         j                  d             d  |         j                  t         j                  d             dd |           y )Nc                       e Zd Z fdZy)%BadElementTest.test_subscr.<locals>.Xc                     d d = yNr   r   r9  s    r   	__index__z/BadElementTest.test_subscr.<locals>.X.__index__  s    aDr   NrO   rP   rQ   rv  r  s   r   r  rs        r   r  r[   r  r   r   )r   r   r   )rE   r  r   s     @r   test_subscrzBadElementTest.test_subscr  sa    	 	
 JJv	G$%	$13	G$%	!Bqs(r   c                      G fdd      }t         j                  d      t        d      D ]'  }j                  dt         j                  d             ) g dd |       <   y )Nc                       e Zd Z fdZy))BadElementTest.test_ass_subscr.<locals>.Xc                     g d d  yru  r   r9  s    r   rv  z3BadElementTest.test_ass_subscr.<locals>.X.__index__!  s    !r   Nrw  r  s   r   r  r|     rx  r   r  r[   r   r   r  )r   r   r   r   )rE   r  r9  r   s      @r   test_ass_subscrzBadElementTest.test_ass_subscr  sU    	 	
 JJvrAHHQ

7+,  !Bqs(r   c                     d }t         j                  |      }|j                  di        |j                  d       | j	                  t
        |j                  di        ~t                y )Nc                     g S rb   r   r   r   s     r   element_factoryz>BadElementTest.test_treebuilder_start.<locals>.element_factory-      Ir   r  rd   rf  r   )r   r*  rK  r:   r   AttributeErrorr   rE   r  r   s      r   test_treebuilder_startz%BadElementTest.test_treebuilder_start+  sP    	NN?N;	r	v.!''62>r   c                     d }t         j                  |      }|j                  di        |j                  d       | j	                  t
        |j                  d       ~t                y )Nc                     g S rb   r   r  s     r   r  z<BadElementTest.test_treebuilder_end.<locals>.element_factory9  r  r   r  rd   rf  )r   r*  rK  r:   r   r  r>  r   r  s      r   test_treebuilder_endz#BadElementTest.test_treebuilder_end7  sN    	NN?N;	r	v.!%%7r   N)rO   rP   rQ   r  r  r   r#  r  rL  rN  rK  r=  r?  r   infinite_recursionr\  rk  rp  ry  r~  r  r  r   r   r   r   r   
  su    &&4
5
U1n:
;
)>'
$  W# $4&7*

r   r   c                   0    e Zd Zd Zd Zej                  Zy)MutationDeleteElementPathc                 @    t        j                  | g| }||_        |S rb   r   __new__r[   r#   r[   r+   rE   s       r   r  z!MutationDeleteElementPath.__new__E  !    {{3&&	r   c                 "    | j                   d d = yr  rd  rE   r,  s     r   r   z MutationDeleteElementPath.__eq__J  s    IIaLr   NrO   rP   rQ   r  r   r   __hash__r   r   r   r  r  D      
 ||Hr   r  c                   0    e Zd Zd Zd Zej                  Zy)MutationClearElementPathc                 @    t        j                  | g| }||_        |S rb   r  r  s       r   r  z MutationClearElementPath.__new__R  r  r   c                 8    | j                   j                          yr  )r[   r   r  s     r   r   zMutationClearElementPath.__eq__W  s    		r   Nr  r   r   r   r  r  Q  r  r   r  c                   *    e Zd Zd Zej
                  Zy)BadElementPathc                     ddz  )Nr   r   r   r  s     r   r   zBadElementPath.__eq___  s    c	r   N)rO   rP   rQ   r   r   r  r   r   r   r  r  ^  s     ||Hr   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                 ^    t         |           ddlm} |j                  | _        i |_        y Nr   rB   )supersetUprD   rC   r   
path_cacherE   rC   r  s     r   r  zBadElementPathTest.setUpf  s$    )%,,r   c                 P    ddl m} | j                  |_        t        |           y r  )rD   rC   r  r   r  tearDownr  s     r   r  zBadElementPathTest.tearDownl  s    )!__r   c                    t         t        fD ]n  }| j                  |      5  t        j	                  d      }|j                  t        j	                  d      g       |j                   ||d             d d d        p y # 1 sw Y   {xY wNr  r   r   )r  r  r  r   r   r   r   rE   r#   r   s      r   test_find_with_mutatingz*BadElementPathTest.test_find_with_mutatingq  sf    -/GHCc"JJu%"**U+,-s1c{# #" I""   AA??B	c                     t         j                  d      }|j                  t         j                  d      g       	 |j                  t	        d             y # t
        $ r Y y w xY wr  )r   r   r   r   r  r  r9  s     r   test_find_with_errorz'BadElementPathTest.test_find_with_errorx  sP    JJu	"**U#$%	FF>#&'  		   A 	A#"A#c                    t         t        fD ]n  }| j                  |      5  t        j	                  d      }|j                  t        j	                  d      g       |j                   ||d             d d d        p y # 1 sw Y   {xY wr  )r  r  r  r   r   r   r   r  s      r   test_findtext_with_mutatingz.BadElementPathTest.test_findtext_with_mutating  sf    -/GHCc"JJu%"**U+,-

3q#;' #" I""r  c                     t         j                  d      }|j                  t         j                  d      g       	 |j                  t	        d             y # t
        $ r Y y w xY wr  )r   r   r   r   r  r  r9  s     r   test_findtext_with_errorz+BadElementPathTest.test_findtext_with_error  sP    JJu	"**U#$%	JJ~c*+  		r  c                     t         j                  d      }t         j                  |d      }dddg di g}|D ]*  }||_        | j	                  |j                  d      |       , y )Nr  r   rR  r   Fr   ./barr   r   rq  r   r   r   )rE   	root_elemsub_elemfalseyvals        r   (test_findtext_with_falsey_text_attributez;BadElementPathTest.test_findtext_with_falsey_text_attribute  s^    JJu%	==E2aB+CHMY//8#> r   c                     t         j                  d      }t         j                  |d      }d |_        | j	                  |j                  d      d       y )Nr  r   r  rR  r  )rE   r  r  s      r   &test_findtext_with_none_text_attributez9BadElementPathTest.test_findtext_with_none_text_attribute  sB    JJu%	==E2++G4b9r   c                    t         t        fD ]n  }| j                  |      5  t        j	                  d      }|j                  t        j	                  d      g       |j                   ||d             d d d        p y # 1 sw Y   {xY wr  )r  r  r  r   r   r   r   r  s      r   test_findall_with_mutatingz-BadElementPathTest.test_findall_with_mutating  sf    -/GHCc"JJu%"**U+,-		#a+& #" I""r  c                     t         j                  d      }|j                  t         j                  d      g       	 |j                  t	        d             y # t
        $ r Y y w xY wr  )r   r   r   r   r  r  r9  s     r   test_findall_with_errorz*BadElementPathTest.test_findall_with_error  sP    JJu	"**U#$%	IInS)*  		r  )rO   rP   rQ   r  r  r  r  r  r  r  r  r  r  __classcell__)r  s   @r   r  r  e  s5     
$(?:'r   r  c                   *    e Zd Zd Zd Zd Zd Zd Zy)ElementTreeTypeTestc                    | j                  t        j                  t               | j                  t        j                  t               | j                  t        j
                  t               | j                  t        j                  t               | j                  t        j                  t               | j                  t        j                  t               y rb   )	r   r   re  rr  rI  r?   r   r*  r&  r   s    r   test_istypezElementTreeTypeTest.test_istype  sz    bmmT2bhh-bnnd3bjj$/bnnd3bllD1r   c                 (    G d dt         j                        } |d      }| j                  |t         j                         | j                  ||       | j                  |j                  d       d|_        | j                  |j
                  d       y )Nc                       e Zd Zy)DElementTreeTypeTest.test_Element_subclass_trivial.<locals>.MyElementNr  r   r   r   	MyElementr    r  r   r  r  r  )r   r   r   r   rd   r   rE   r  myes      r   test_Element_subclass_trivialz1ElementTreeTypeTest.test_Element_subclass_trivial  ss    	

 	 c2::.c9-%( 5)r   c                      G fddt         j                         dddddd	      }| j                  |j                  d
       | j                  t	        |j                               g d       y )Nc                   &     e Zd Zi f fd	Z xZS )HElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElementc                 .    t        |   |dz   |fi | y )N__)r  r  )rE   rd   r   extrar  r  s       r   r  zQElementTreeTypeTest.test_Element_subclass_constructor.<locals>.MyElement.__init__  s    i/d
FLeLr   )rO   rP   rQ   r  r  )r  r  s   @r   r  r    s    +- M Mr   r  r  r   r   )r   r   r     )r   r   foo__))r   r   )r   r   )r   r  )r   r  )r   r   r   rd   r  r   )rE   r  r  s     @r   !test_Element_subclass_constructorz5ElementTreeTypeTest.test_Element_subclass_constructor  s^    	M

 	M QQ/1:'*		,4	6r   c                      G d dt         j                        } |d      }| j                  |j                         d       y )Nc                       e Zd Zd Zy)GElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElementc                     | j                   S rb   rc   r   s    r   	newmethodzQElementTreeTypeTest.test_Element_subclass_new_method.<locals>.MyElement.newmethod  s    xxr   N)rO   rP   rQ   r  r   r   r   r  r    s     r   r  r  )r   r   r   r  r  s      r    test_Element_subclass_new_methodz4ElementTreeTypeTest.test_Element_subclass_new_method  s4    	 

 	  %0r   c                     G d dt         j                        }t         j                  d      }d|_         |d      }d|_        |j                  |       | j	                  |j                  d      d       | j	                  |j                  d      j                  d       t        |j                  d            }| j	                  t        |      d|       | j	                  |d   j                  d       y )	Nc                       e Zd Zy)AElementTreeTypeTest.test_Element_subclass_find.<locals>.MyElementNr  r   r   r   r  r    r  r   r  r  r   r   ro  r   r   )r   r   r   r   r   r   r   rd   r   r   r   )rE   r  r   subfounds        r   test_Element_subclass_findz.ElementTreeTypeTest.test_Element_subclass_find  s    	

 	 JJu	E*I6**E2QYYu%&UQ.qu-r   N)rO   rP   rQ   r  r  r  r  r  r   r   r   r  r    s    2*61.r   r  c                   <    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
y	)
ElementFindTestc                    t         j                  t              }| j                  |j	                  d      j
                  d       | j                  |j	                  d      j
                  d       | j                  |j	                  d      j
                  d       t         j                  t              |d<   | j                  |j	                  d      j
                  d       | j                  |j                  d      d       | j                  |j                  d      d       | j                  |j                  d      d	       | j                  |j                  dd
      d	       | j                  |j                  d             | j                  |j                  dd
      d
       | j                  t         j                  d      j                  d      d	       y )Nrd   r   ./tagr   zsection/nexttagnexttagr   ro  rR  r	  togz<tag><empty /></tag>empty)	r   r   r   r   r   rd   SAMPLE_SECTIONr   r   r9  s     r   test_find_simplez ElementFindTest.test_find_simple  sb   FF:**E2.22E:,,e4vvn%! 1266	BG,f5M2I> 	$56;$5yA2F 	!**U+,E95yA 	 67@@I2Nr   c                    d}t         j                  |      }| j                  |j                  d      j                  d   d       | j                  |j                  d      j                  d   d       | j                  |j                  d      j                  d   d       | j                  |j                  d	      j                  d   d
       | j                  |j                  d      j                  d   d       | j                  t        d|j                  d       | j                  t        d|j                  d       | j                  t        d|j                  d       | j                  t        d|j                  d       y )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   r   r  SyntaxError)rE   
LINEAR_XMLr   s      r   test_find_xpathzElementFindTest.test_find_xpath  s3   
 FF: 	
+227;SA
+227;SA077@#F 1299'BCH 1299'BCH{GQVVZH{GQVV[I{GQVV=NO{GQVV=NOr   c                    t         j                  t              }t         j                  t              |d<   | j	                  t        |j                  d            dg       | j	                  t        |j                  d            ddg       | j	                  t        |j                  d            g        | j	                  t        |j                  d            g        | j	                  t        |j                  d            g d       | j	                  t        |j                  d	            dgd
z         | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            g d       | j	                  t        |j                  d            g d       | j	                  t        |j                  d            g d       | j	                  t        |j                  d            g d       | j	                  t        |j                  d            g d       | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            dgdz         | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dg       | j	                  t        |j                  d            d g       | j	                  t        |j                  d!            g        | j	                  t        |j                  d"            g        | j	                  t        |j                  d#            dgdz         | j	                  |j                  d$      |j                  d             | j	                  t        |j                  d%            d g       | j	                  t        |j                  d&            d g       | j	                  t        |j                  d'            d g       | j	                  t        |j                  d(            d g       | j	                  t        |j                  d)            d g       | j	                  t        |j                  d*            g        | j	                  t        |j                  d+            g        | j	                  t        |j                  d,            g        | j	                  t        |j                  d-            g        | j	                  t        |j                  d.            g        | j	                  t        |j                  d/            dg       | j	                  t        |j                  d0            dg       | j	                  t        |j                  d1            dg       | j	                  t        |j                  d2            dg       | j	                  t        |j                  d3            dg       | j	                  t        |j                  d4            g        | j	                  t        |j                  d5            g        | j	                  t        |j                  d6            dgdz         | j	                  t        |j                  d7            dgdz         | j	                  t        |j                  d8            dgdz         | j	                  t        |j                  d9            dgdz         | j	                  t        |j                  d:            dgdz         | j	                  t        |j                  d;            dgd
z         | j	                  t        |j                  d<            dgd
z         |d   |d=<   | j	                  t        |j                  d(            d d g       | j	                  t        |j                  d3            ddg       y )>Nr   rd  r3  rd   r  ztog/foor   r~  z.//tagr  r   zsection//tagz	section/*)rd   r  nextsectionz
section//*)rd   r  r  rd   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]r_  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   rf   r   r9  s     r   test_findallzElementFindTest.test_findall  s   FF:vvn%!		#7&B		%(89E5>J		%(892>		)(<=rB		#7%	'		((;<GaK			-(@AE7K		.(ABUGaKP		+(>?-	/		,(?@4	6		.(AB4	6		%(89-	/		&(9:4	6		'(:;eWE		)(<=wG		'(:;eWq[I		)(<=w{K		2B(CDGaK			2F(GHG			2G(HIGaK			2F(GHGaK			2G(HIG			-(@AG			2C(DEK			2G(HI2N		((;<bA		2B(CDGaK	;/<1HI		2M(NOK			2N(OPK			2N(OPK			2O(PQK			2Q(RSK	
 			2N(OP			2O(PQ			2O(PQ			2P(QR			2R(ST	 			2G(HI	"		2H(IJ	"		2H(IJ	"		2K(LM	"		2I(JK	"		2J(KL			2I(JK	
 			2H(IJ1	&		2I(JK1	&		2I(JK1	&		2L(MN1	&		2J(KL1	& 			2K(LM1	&		2J(KL1	& t!		2O(PQ#Y/	1		2I(JK	)r   c                 B   t         j                  t              }| j                  t	        |j                  d            g        | j                  t	        |j                  d            dgdz         | j                  t	        |j                  d            dgdz         y )Nrd   z{http://effbot.org/ns}tagr   z.//{http://effbot.org/ns}tagr  )r   r   rD  r   rf   r   r9  s     r   test_test_find_with_nsz&ElementFindTest.test_test_find_with_ns  s    FF=!		%(892>199%@AB()A-	/ 	199%CDE()A-	/r   c                 X   t         j                  d      }ddi}| j                  t        |j	                  d|            d       | j                  t        |j	                  d|            d       ddi}| j                  t        |j	                  d|            d	       | j                  t        |j	                  d|            d       ddd
}| j                  t        |j	                  d|            d       | j                  t        |j	                  d|            d	       y )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)rR  r   .//br  r   )r  rR  )r   r   r   r   r   )rE   rA  nsmaps      r   test_findall_different_nsmapsz-ElementFindTest.test_findall_different_nsmaps  s    vv   sT\\)\FGKT\\&U\CDaHsT\\)\FGKT\\&U\CDaH$T\\)\FGKT\\&U\CDaHr   c                 ~   t         j                  d      }|j                  t         j                  d             | j	                  t        |j                  d            g d       | j	                  t        |j                  d            dg       | j	                  t        |j                  d            dg       | j	                  t        |j                  d	            d
g       | j	                  t        |j                  d            ddg       | j	                  t        |j                  d            dg       | j	                  t        |j                  d            t        |j                  d                   | j	                  t        |j                  d            g d       | j	                  t        |j                  d      |d   gz         t        |j                  d                   | j	                  t        |j                  d            g d       | j	                  t        |j                  d            ddg       | j	                  t        |j                  d            ddg       | j	                  t        |j                  d            d
g       | j	                  t        |j                  d            g d       | j	                  t        |j                  d            ddg       | j	                  t        |j                  d            t        |j                  d                   y )Nr  r.   z{*}b){X}br   {Y}bz{*}cr   z{X}*r  z{Y}*r   rm  r   z{}bro  )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   rr  r   rf   r   r  s     r   test_findall_wildcardz%ElementFindTest.test_findall_wildcard  s   vv   	BJJv&'V(<=.	0V(<=	 V(<= 	#V(<= 	#U(;<s	%U(;<	 U(;<'S(9:	<V(<=3	5 	V(<Rz(IJ'S(9:	< 	Y(?@;	=Y(?@s	%Y(?@ &)	+Y(?@ 	#X(>?-	/X(>?s	%X(>?'V(<=	?r   c                     t         j                  t              }| j                  t        d      5  |j                  d       d d d        y # 1 sw Y   y xY w)Nzcannot use absolute pathz/tag)r   r   r   r  r  r   r9  s     r   test_bad_findzElementFindTest.test_bad_find  s:    FF:##K1KLIIf MLLs   AAc                 |   t         j                  t              }| j                  t         j	                  |      j                  d      j                  d       | j                  t         j	                  |      j                  d      d       | j                  t        t         j	                  |      j                  d            dgdz         d}| j                  t        |      5  t         j	                  |      j                  d      }d d d        | j                  t              dgdz         y # 1 sw Y   )xY w)Nrd   r   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   rd   r   rf   r   assertWarnsRegexFutureWarning)rE   r   r   r   s       r   test_find_through_ElementTreez-ElementFindTest.test_find_through_ElementTree  s    FF:*//6::EB*33E:FCq(9(A(A%(HIGaK	# ""=#6"**73B 7+eWq[9 76s   %%D22D;N)rO   rP   rQ   r  r  r  r  r  r  r  r  r   r   r   r  r    s0    O.P,n)`/I"*?X
:r   r  c                   2    e Zd ZddZd Zd Zd Zd Zd Zy)	ElementIterTestNc                 6    t        |j                  |            S rb   )rf   r   )rE   r[   rd   s      r   _ilistzElementIterTest._ilist  s    diin--r   c                    t         j                  d      }| j                  | j                  |      g d       | j                  | j                  |j	                  d            ddg       | j                  t        |j                               j                  d       | j                  dj                  |j                               d       | j                  dj                  |j	                  d      j                               d       | j                  t        |j                               d	       t        |d
      }| j                  t        t         j                  |            d   d       t        |d
      }t         j                  t         j                               }| j                  t        t         j                  ||            d   d       t         j                  d       }| j                  t         |j                         t         j                  d      }| j                  dj                  |j                               d       y )Nz7<html><body>this is a <i>paragraph</i>.</body>..</html>)r8  r3  r   r3  r   r8  rR  zthis is a paragraph...zthis is a paragraph.z
this is a F)r\   r   r>  r   )r-  z*<root>a&amp;<sub>b&amp;</sub>c&amp;</root>za&b&c&)r   r   r   r  r   ra  r   rd   r5  r   r`   r`  r&  r*  r?   r   r  )rE   r\  
sourcefiler-  r_   s        r   
test_basiczElementIterTest.test_basic  s   ffNOS)+@ASXXf%56Fchhj)--v602JK&!1!:!:!<="	$clln-|< se4
bll:67:EB se4
R^^%56bll:flEFqI	  ~~d#.$))4 ffAB0(;r   c                 $   t         j                  d      }| j                  | j                  |      dg       t         j	                  |d      }| j                  | j                  |      ddg       t         j	                  |d      }| j                  | j                  |      g d       t         j	                  |d      }| j                  | j                  |      g d       |d   |d<   |d= | j                  | j                  |      ddg       y )	Nr   r   r   )r   r   r   r   )r   r   r   r   r   r   )r   r   r   r  rq  rt  s        r   test_cornerszElementIterTest.test_corners  s    JJsOQ#/ MM!S!Q#s4 MM!S!Q9 MM!S!Q)=> t!aDQ#s4r   c                    t         j                  d      }| j                  | j                  |d      dgdz         | j                  | j                  |d      dgdz         | j                  t	        |j                  d            dgdz         g d}| j                  t	        |j                               |       | j                  | j                  |      |       | j                  | j                  |d      |       y )	NaJ  
            <document>
                <house>
                    <room>bedroom1</room>
                    <room>bedroom2</room>
                </house>
                <shed>nothing here
                </shed>
                <house>
                    <room>bedroom8</room>
                </house>
            </document>roomr  houser   rc   )r]  r  r  r  shedr  r  r   )r   r   r   r  rf   r   )rE   r\  all_tagss      r   test_iter_by_tagz ElementIterTest.test_iter_by_tag  s    ff   	S&1F8a<@S'2WIMB 	3888/0HqL	
-
3X>S)84S#.9r   c                     t         j                  d      }|j                         }| j                  t              5  t        j
                  |       d d d        y # 1 sw Y   y xY w)Nr   )r   r   r   r   r8  r  )rE   r   r   s      r   r  zElementIterTest.test_copy0  s?    JJsOVVXy)IIbM *))s   AA#c                 0   t         j                  d      }|j                         }t        t        j
                  dz         D ]F  }| j                  t        t        j                  f      5  t	        j                  ||       d d d        H y # 1 sw Y   SxY w)Nr   r   )
r   r   r   r   rq   r  r   r8  rt   rr   )rE   r   r   r|   s       r   r  zElementIterTest.test_pickle6  sk    JJsOVVX622Q67E""Iv/C/C#DER' FE 8EEs   *BB	rb   )	rO   rP   rQ   r  r  r  r  r  r  r   r   r   r	  r	    s     .<65,::(r   r	  c                   n    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y)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                  |j                  d       | j                  |j                  d       | j                  |j                  d        | j                  |j                  i        t        |      }| j                  t        |      d       |d   }| j                  |j                  d       | j                  |j                  d       | j                  |j                  d       | j                  |j                  i        y )Nr8  r   r   r   divro  r   )r   rd   r   r   r   r   r   )rE   r   childrenr  s       r   _check_sample1_elementz&TreeBuilderTest._check_sample1_elementF  s    '(&2&7X*E*Y/V,r*r   c                 6    G d d      } G d d|      }t         j                   |             }|j                  | j                         | j	                  |j                         d       t         j                   |             }|j                  | j                         | j	                  |j                         d       t         j                  t                     }|j                  | j                         | j                  |j                                y )Nc                       e Zd Zd Zy)<TreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilderc                      y)Nr  r   r   s    r   r)  zBTreeBuilderTest.test_dummy_builder.<locals>.BaseDummyBuilder.closeU  s    r   Nrh  r   r   r   BaseDummyBuilderr!  T  s    r   r#  c                       e Zd Zd xZxZZy)8TreeBuilderTest.test_dummy_builder.<locals>.DummyBuilderc                       y rb   r   )r   s    r   r4  zATreeBuilderTest.test_dummy_builder.<locals>.DummyBuilder.<lambda>Y  s    Dr   N)rO   rP   rQ   r:   rK  r>  r   r   r   DummyBuilderr%  X  s    !00D053r   r'  r   r  )r   r&  r(  sample1r   r)  r"   r   )rE   r#  r'  r-  s       r   test_dummy_builderz"TreeBuilderTest.test_dummy_builderS  s    	 		1+ 	1 \^4DLL!,%5%78DLL!,VX.DLL!&,,.)r   c                    t         j                         }| j                  |j                  d      j                  t         j
                         | j                  |j                  d      j                  d       t         j                  t         j
                        }| j                  |j                  d      j                  t         j
                         | j                  |j                  d      j                  d       t         j                  t              }| j                  |j                  d      t        d             y )Nctext)comment_factory)r   r*  r   rp  rd   rr  r   r   rE   r   s     r   test_treebuilder_commentz(TreeBuilderTest.test_treebuilder_commentg  s    NN7+//<7+00':NN2::N67+//<7+00':NN3N/7+S\:r   c                    t         j                         }| j                  |j                  dd       j                  t         j
                         | j                  |j                  dd       j                  d       t         j                  t         j
                        }| j                  |j                  d      j                  t         j
                         | j                  |j                  d      j                  d       | j                  |j                  dd      j                  t         j
                         | j                  |j                  dd      j                  d       t         j                  d       }| j                  |j                  d      t        d      d f       | j                  |j                  dd      t        d      df       y )Nr!  )
pi_factoryr  z text zpitarget  text c                     t        |       |fS rb   )r   )r!  r   s     r   r4  z5TreeBuilderTest.test_treebuilder_pi.<locals>.<lambda>~  s    CK;Nr   )r   r*  r   r  rd   r   r   r   r-  s     r   test_treebuilder_piz#TreeBuilderTest.test_treebuilder_pis  sE   NNh-112559h-22H=NNbeeN,h++RUU3h,,h7j(377?j(388:KLNN&NNOh#h-)>?j(3c*ox5PQr   c                 f    G d dt         j                        }d}t         j                  |      }| j                  |j                  d       t         j                   |             }|j                  |       |j                         }| j                  |j                  d       d}t         j                  |      }| j                  |j                  d       d}t         j                   |             }|j                  |       |j                         }| j                  |j                  d       y )Nc                       e Zd Zy);TreeBuilderTest.test_late_tail.<locals>.TreeBuilderSubclassNr  r   r   r   TreeBuilderSubclassr5    r  r   r6  z<a>text<!-- comment -->tail</a>texttailr   z<a>text<?pi data?>tail</a>)r   r*  r   r   r   r&  r(  r)  )rE   r6  r  r   r-  s        r   test_late_tailzTreeBuilderTest.test_late_tail  s    	".. 	 0MM#,%8%:;CLLN,*MM#,*%8%:;CLLN,r   c                 2    G d dt         j                        }d}t         j                  t         j                  d            }|j                  |       |j	                         }| j                  |d   j                  d       | j                  |d   j                  d	       | j                  |j                  d
       t         j                   |d            }|j                  |       |j	                         }| j                  |d   j                  d       | j                  |d   j                  d	       | j                  |j                  d
       d}t         j                  t         j                  d            }|j                  |       |j	                         }| j                  |d   j                  d       | j                  |d   j                  d       | j                  |j                  d       t         j                   |d            }|j                  |       |j	                         }| j                  |d   j                  d       | j                  |d   j                  d       | j                  |j                  d       y )Nc                       e Zd Zy)KTreeBuilderTest.test_late_tail_mix_pi_comments.<locals>.TreeBuilderSubclassNr  r   r   r   r6  r;    r  r   r6  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 datar   ztext
)r   r*  r&  r(  r)  r   r   r   )rE   r6  r  r-  r   s        r   test_late_tail_mix_pi_commentsz.TreeBuilderTest.test_late_tail_mix_pi_comments  s   	".. 	 AR^^D^%IJCLLN1K01H-)%8%NOCLLN1K01H-)<R^^t^%DECLLN1I.1F+*%8D%IJCLLN1I.1F+*r   c                     t         j                  t         j                  d             }|j                  | j                         |j                         }| j                  |       y Nr  r   )r   r&  r*  r(  r(  r)  r  rE   r-  r   s      r   $test_treebuilder_elementfactory_nonez4TreeBuilderTest.test_treebuilder_elementfactory_none  sF    R^^D^%IJDLL!LLN##A&r   c                 *    G d dt         j                        } |       }| j                  |j                  d      d       t         j	                  |      }|j                  | j                         |j                         }| j                  |       y )Nc                       e Zd Zd Zy)4TreeBuilderTest.test_subclass.<locals>.MyTreeBuilderc                     |dz  S Nr   r   rO  s     r   r  z;TreeBuilderTest.test_subclass.<locals>.MyTreeBuilder.foobar      1ur   NrO   rP   rQ   r  r   r   r   MyTreeBuilderrE        r   rJ  r   r   r   )	r   r*  r   r  r&  r(  r(  r)  r  rE   rJ  tbr-  r   s        r   test_subclasszTreeBuilderTest.test_subclass  sl    	BNN 	 _2+R(DLL!LLN##A&r   c                     G d dt         j                        } |t         j                  t         j                        }| j	                  |j                  d      d       t         j                  |      }|j                  | j                         |j                  d       |j                         }| j                  |       y )Nc                       e Zd Zd Zy)?TreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilderc                     |dz  S rG  r   rO  s     r   r  zFTreeBuilderTest.test_subclass_comment_pi.<locals>.MyTreeBuilder.foobar  rH  r   NrI  r   r   r   rJ  rQ    rK  r   rJ  )r,  r0  r   r   r   z<!-- a comment--><?and a pi?>)r   r*  rr  r   r   r  r&  r(  r(  r)  r  rL  s        r   test_subclass_comment_piz(TreeBuilderTest.test_subclass_comment_pi  s    	BNN 	 2::"%%H2+R(DLL!34LLN##A&r   c                     g fd}t         j                  |      }t         j                  |      }|j                  | j                         |j                          | j                  dg       y )Nc                 R    j                  |        t        j                  | |      S rb   )r   r   r   )rd   r   lsts     r   	myfactoryz7TreeBuilderTest.test_element_factory.<locals>.myfactory  s    JJsO::c6**r   r  r   toplevel)r   r*  r&  r(  sample2r)  r   )rE   rW  rM  r-  rV  s       @r   test_element_factoryz$TreeBuilderTest.test_element_factory  sZ    	+
 ^^I^6R(DLL!zl+r   c                     t         j                  |      }t         j                  |      }|j                  | j                         |j                         }| j                  ||       | j                  |       y r@  )r   r*  r&  r(  r(  r)  r   r  )rE   r#   rM  r-  r   s        r   _check_element_factory_classz,TreeBuilderTest._check_element_factory_class  s[    ^^C^0R(DLL!LLNa%##A&r   c                 X     G d dt         j                        }| j                  |       y )Nc                       e Zd Zy)@TreeBuilderTest.test_element_factory_subclass.<locals>.MyElementNr  r   r   r   r  r_    r  r   r  )r   r   r\  )rE   r  s     r   test_element_factory_subclassz-TreeBuilderTest.test_element_factory_subclass  s     	

 	)))4r   c                     t         j                  }| j                  |j                  d        G d d|t              }| j                  |       y )NrH   c                       e Zd Zy)LTreeBuilderTest.test_element_factory_pure_python_subclass.<locals>.MyElementNr  r   r   r   r  rc    r  r   r  )r   _Element_Pyr   rP   r   r\  )rE   baser  s      r   )test_element_factory_pure_python_subclassz9TreeBuilderTest.test_element_factory_pure_python_subclass  s>     ~~*AB	j 	)))4r   c                      G d d      }t         j                   |             }|j                  | j                         | j	                  |j                         d       y )Nc                       e Zd ZdZd Zd Zy)3TreeBuilderTest.test_doctype.<locals>.DoctypeParserNc                     |||f| _         y rb   _doctype)rE   ry   pubidsystems       r   doctypez;TreeBuilderTest.test_doctype.<locals>.DoctypeParser.doctype  s    !%uf 5r   c                     | j                   S rb   rk  r   s    r   r)  z9TreeBuilderTest.test_doctype.<locals>.DoctypeParser.close  s    }}$r   )rO   rP   rQ   rl  ro  r)  r   r   r   DoctypeParserri    s    H6%r   rq  r   r8  z&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r   r&  r(  r(  r   r)  )rE   rq  r-  s      r   test_doctypezTreeBuilderTest.test_doctype
  sM    	% 	% ]_5DLL!H	Ir   c                     G d d      }t         j                   |              dD ]=  }| j                  t        |      5  t         j                   ||             d d d        ? t         j                   |t                     dD ]^  }t         j                   ||t                    }|j                  | j                         | j                  |j                                ` y # 1 sw Y   xY w)Nc                       e Zd ZdefdZd Zy)BTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilderNc                      || _         || _        y rb   raise_inwhat)rE   ry  rz  s      r   r  zKTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__init__  s     ( 	r   c                 `    || j                   k(  r| j                  | j                         d }|S )Nc                       y rb   r   )r+   s    r   handlez^TreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__.<locals>.handle$  s    r   rx  )rE   ry   r}  s      r   __getattr__zNTreeBuilderTest.test_builder_lookup_errors.<locals>.RaisingBuilder.__getattr__!  s+    4==())DMM22r   )rO   rP   rQ   r   r  r~  r   r   r   RaisingBuilderrv    s    (,: !r   r  r   )rK  r:   r>  rp  r  )rz  )	r   r&  r  r   r  r(  r(  r   r)  )rE   r  r  r-  s       r   test_builder_lookup_errorsz*TreeBuilderTest.test_builder_lookup_errors  s    
	 
	 	N,->E''
E:N5$9: ;: ? 	N?@>E\\N)S\TFKK%flln- ?	 ;:s   C--C6	N)rO   rP   rQ   r(  rY  r  r)  r.  r2  r8  r>  rB  rN  rS  rZ  r\  r`  rf  rs  r  r   r   r   r  r  >  s^    2G
 2G+*(
;R-0"+H''','5
5I".r   r  c                   B    e Zd ZdZdZdZd Zd Zd Zd Z	d Z
d	 Zd
 Zy)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                  |j                  d       | j                  |d   j                  d       | j                  |d   j                  d       y )Nr^   r   line22)r   rd   r   r9  s     r   _check_sample_elementz#XMLParserTest._check_sample_element>  sF    '16*1D)r   c                     t         j                  dt         j                               }|j                  | j                         | j                  |j                                y )Nr   )rT   r!  )r   r&  r*  r(  r(  r  r)  )rE   r  s     r   test_constructor_argsz#XMLParserTest.test_constructor_argsC  sE    ,,&(nn&6  8T\\"""7==?3r   c                      G d dt         j                        } |       }|j                  | j                         | j	                  |j                                y )Nc                       e Zd Zy)-XMLParserTest.test_subclass.<locals>.MyParserNr  r   r   r   MyParserr  J  r  r   r  )r   r&  r(  r(  r  r)  )rE   r  r-  s      r   rN  zXMLParserTest.test_subclassI  s=    	r|| 	DLL!""6<<>2r   c                    t        j                         5  t        j                  dt               t        j                         }|j                  | j                         |j                          d d d        y # 1 sw Y   y xY w)Nerror)	warningscatch_warningssimplefilterDeprecationWarningr   r&  r(  rY  r)  r  s     r   test_doctype_warningz"XMLParserTest.test_doctype_warningP  sO    $$&!!'+=>\\^FKK%LLN	 '&&s   AA88Bc                    d  G fddt         j                        } |       }| j                  t        d      5  |j	                  | j
                         d d d        |j                          | j                         d xt        j                         5  t        j                  dt               t        j                  dt                G fdd      } | |             }|j	                  | j
                         |j                          | j                         | j                  d       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)	Nc                       e Zd Z fdZy)@XMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctypec                     ||fy rb   r   )rE   r+   r,   rl  s      r   ro  zHXMLParserTest.test_subclass_doctype.<locals>.MyParserWithDoctype.doctypeZ  s     &>r   NrO   rP   rQ   ro  rk  s   r   MyParserWithDoctyper  Y  s    *r   r  ro  r  c                       e Zd Z fdZy):XMLParserTest.test_subclass_doctype.<locals>.DoctypeParserc                     |||fy rb   r   )rE   ry   rm  rn  	_doctype2s       r   ro  zBXMLParserTest.test_subclass_doctype.<locals>.DoctypeParser.doctypei  s    !%uf 5Ir   Nr  )r  s   r   rq  r  h  s    6r   rq  r   rr  )r   r&  r  RuntimeWarningr(  rY  r)  r   r  r  r  r  r   )rE   r  r-  rq  rl  r  s       @@r   test_subclass_doctypez#XMLParserTest.test_subclass_doctypeW  s   	*",, 	*
 %&"">9=KK% >(###9$$&!!'+=>!!'>:6 6
 )@FKK%LLNh'YLM '& >= '&s   E BE E	Ec                 T   t        j                         5  t        j                  dt               t        j                  dt                G d dt
        j                        } |       }|j                  | j                         |j                          ddd       y# 1 sw Y   yxY w)z:Ensure that ordinary usage is not deprecated (Issue 19176)r  c                       e Zd Zy)DXMLParserTest.test_inherited_doctype.<locals>.MyParserWithoutDoctypeNr  r   r   r   MyParserWithoutDoctyper  z  s    r   r  N)
r  r  r  r  r  r   r&  r(  rY  r)  )rE   r  r-  s      r   test_inherited_doctypez$XMLParserTest.test_inherited_doctypeu  sl    $$&!!'+=>!!'>: +-FKK%LLN '&&s   B BB'c                 X   t         j                  t         j                               }|j                  | j                         |j                         }| j                  |j                  d       | j                  |j                  d   d       | j                  |j                  d       y )Nr   moneyr   u
   $£€𐅻)
r   r&  r*  r(  sample3r)  r   rd   r   r   rA  s      r   test_parse_stringzXMLParserTest.test_parse_string  sw    R^^%56DLL!LLN('*,CD!89r   N)rO   rP   rQ   r(  rY  r  r  r  rN  r  r  r  r  r   r   r   r  r  5  s:    -GGMG*
43M<	:r   r  c                       e Zd Zd Zy)NamespaceParseTestc                 B   ddd}t         j                  t              }| j                  t	        |j                  d|            d       | j                  t	        |j                  d|            d       | j                  t	        |j                  d|            d       y )	Nhellor  )hr,  z{hello}tabler   z.//{hello}tdr   z.//{foo}name)r   r   SAMPLE_XML_NS_ELEMSr   r   r   )rE   r  r\  s      r   test_find_with_namespacez+NamespaceParseTest.test_find_with_namespace  s{    E*mm/0S[[?@!DS[[?@!DS[[?@!Dr   N)rO   rP   rQ   r  r   r   r   r  r    s    Er   r  c                   Z    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y)ElementSlicingTestc                 @    |D cg c]  }|j                    c}S c c}w rb   rc   )rE   elemlistr   s      r   
_elem_tagszElementSlicingTest._elem_tags  s    '(x!x(((rg   c                 6    | j                  t        |            S rb   )r  r   rs  s     r   _subelem_tagsz ElementSlicingTest._subelem_tags  s    tDz**r   c                     t         j                  d      }t        |      D ]  }t         j                  |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   rq  )rE   numchildrenr   r   s       r   _make_elem_with_childrenz+ElementSlicingTest._make_elem_with_children  s7    
 JJsO{#AMM!UQY' $r   c                    | j                  d      | j                  d   j                  d       | j                  d   j                  d       | j                  t        fd       | j                  t        fd       y )Nr   r   a1a8c                       d   S )N   r   r  s   r   r4  z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>  s	    aer   c                       d   S )Nir   r  s   r   r4  z?ElementSlicingTest.test_getslice_single_index.<locals>.<lambda>  s	    afr   )r  r   rd   r   
IndexErrorr9  s    @r   test_getslice_single_indexz-ElementSlicingTest.test_getslice_single_index  sc    ))"-14(2D)*m4*n5r   c                    | j                  d      }| j                  | j                  |dd        g d       | j                  | j                  |dd       g d       | j                  | j                  |dd       g d       | j                  | j                  |dd       ddg       | j                  | j                  |dd       ddg       | j                  | j                  |d d	       d
dg       y )Nr  r  )a3a4a5   r  r  r  r  r   a0r  )r  r   r  r9  s     r   test_getslice_rangez&ElementSlicingTest.test_getslice_range  s    ))!,12/1CD1Q02DE1R13EF1Q04,?1R1D$<@2A/$>r   c           	      L   | j                  d      }| j                  | j                  |ddd         ddg       | j                  | j                  |d d d         g d       | j                  | j                  |d d d         ddg       | j                  | j                  |dd d         d	dg       | j                  | j                  |dd t        j                           d
g       | j                  | j                  |dd t        j                  dz           d
g       y )Nr      r   r  a9r  )r  r  a6r  r  r  r  @   r  r   r  rp   maxsizer9  s     r   test_getslice_stepsz&ElementSlicingTest.test_getslice_steps  s   ))"-1R63dD\B3Q302JK3Q304,?14a41D$<@1>ckk>):;dVD1+=ckk2o+=)>?$Hr   c           	          | j                  d      }| j                  | j                  |d d d         g d       | j                  | j                  |d d d         ddg       | j                  | j                  |dd t        j                            dg       | j                  | j                  |dd t        j                   dz
           dg       | j                  | j                  |dd t        j                   d	z           dg       y )
Nr  r  )r  a2r  r  r  r  r  r  r   r  r  r9  s     r   test_getslice_negative_stepsz/ElementSlicingTest.test_getslice_negative_steps  s    ))!,4R413KL4R41D$<@1?s{{l?);<tfE1+<s{{l1n+<)=>G1+>s{{lB.>+>)?@4&Ir   c                    | j                  d      }|dd= | j                  | j                  |      ddg       | j                  d      }|dd = | j                  | j                  |      g        | j                  d      }|d d d= | j                  | j                  |      g        | j                  d      }|d d d= | j                  | j                  |      ddg       | j                  d      }|d	d d= | j                  | j                  |      ddg       | j                  d      }|d d d= | j                  | j                  |      d
g       y )Nr  r   r   r  r  r  r  r  r   r  )r  r   r  r9  s     r   test_delslicez ElementSlicingTest.test_delslice  sT   ))!,acF++A.t=))!,abE++A.3))!,ddG++A.3))!,ddG++A.t=))!,addG++A.t=))!,ccF++A.7r   c                 `   | j                  d      }t        j                  d      |d<   | j                  | j	                  |      g d       t        j                  d      |d<   | j                  | j	                  |      g d       | j                  t              5  t        j                  d      |d	<   d d d        | j                  t              5  t        j                  d      |d
<   d d d        | j                  | j	                  |      g d       y # 1 sw Y   cxY w# 1 sw Y   9xY w)Nr  r   r   r  r   r  r  r   r  )r  r   r   r  r   r  )r  r   r   r   r  r   r  r9  s     r   test_setslice_single_indexz-ElementSlicingTest.test_setslice_single_index  s    ))!,zz#!++A.0GH

3"++A.0FGz*::c?AaD +z*JJsOAbE +++A.0FG	 +***s   DD$D!$D-c                 J   | j                  d      }t        d      D cg c]  }t        j                  d|z         c}|dd | j	                  | j                  |      g d       | j                  d      }t        j                  d      g|dd | j	                  | j                  |      g d       | j                  d      }t        d      D cg c]  }t        j                  d|z         c}|dd | j	                  | j                  |      g d	       y c c}w c c}w )
Nr  r   b%sr   r  )r  b0b1r  r   )r  r   r  )r  r  r  b2r  )r  r   r   r   r   r  rE   r   r   s      r   test_setslice_rangez&ElementSlicingTest.test_setslice_range  s    ))!,16q:A"**UQY':!A++A.0HI))!,**S/"!A++A.0AB))!,16q:A"**UQY':!A++A.0NO ; ;s   DD c                 `   | j                  d      }t        d      D cg c]  }t        j                  d|z         c}|ddd<   | j	                  | j                  |      g d       | j                  d      }| j                  t              5  t        j                  d      g|ddd<   d d d        | j                  t              5  t        d      D cg c]  }t        j                  d|z         c}|ddd<   d d d        | j                  t              5  g |ddd<   d d d        | j	                  | j                  |      g d	       | j                  d
      }t        j                  d      g|dd t        j                  <   | j	                  | j                  |      g d       t        j                  d      g|dd t        j                  dz  <   | j	                  | j                  |      g d       y c c}w # 1 sw Y   ZxY wc c}w # 1 sw Y   xY w# 1 sw Y   xY w)Nr  r   r  r   r  )r  r  r  r  r  r  r   r  )r  r  r  r  r  r  r  r  r   r  r  r   r  r  
r  r   r   r   r   r  r   r   rp   r  r  s      r   test_setslice_stepsz&ElementSlicingTest.test_setslice_steps  s   ))!,388<8aBJJuqy)8<!Aa%++A.0TU))!,z*

3(Aa!eH +z*7<Qx@x!

519-x@Aa!eH +z*Aa!eH +++A.0TU))!,ZZ_-!.S[[.++A.0GH!#C 1!
S[["_
++A.0GH! = +* A +***s;   H H
HH7	H	H$HHH!$H-c                    | j                  d      }t        d      D cg c]  }t        j                  d|z         c}|ddd<   | j	                  | j                  |      g d       | j                  d      }| j                  t              5  t        j                  d      g|ddd<   d d d        | j                  t              5  t        d      D cg c]  }t        j                  d|z         c}|ddd<   d d d        | j                  t              5  g |ddd<   d d d        | j	                  | j                  |      g d	       | j                  d      }t        j                  d      g|d
d t        j                   <   | j	                  | j                  |      g d       t        j                  d      g|d
d t        j                   d
z
  <   | j	                  | j                  |      g d       t        j                  d      g|d
d t        j                   dz  <   | j	                  | j                  |      g d       y c c}w # 1 sw Y   xY wc c}w # 1 sw Y   lxY w# 1 sw Y   SxY w)Nr  r   r  r   r  )r  r  r  r  r   r  )r  r  r  r  r   r  r   r  r   r  )r  r   r  r  r  r  s      r   test_setslice_negative_stepsz/ElementSlicingTest.test_setslice_negative_steps  s   ))!,49!H=HqRZZ	*H=!Ab&	++A.0HI))!,z*C)Aa"fI +z*8=aA1EAI.AAa"fI +z*Aa"fI +++A.0HI))!, jjo.!/ckk\/++A.0GH "

30!
ckk\!^
++A.0GH"$**S/!2!
ckk\2
++A.0GH% > +* B +***s;   II
I*I%7	I*	I7I"%I**I47Jc                    t         j                  d      }| j                  t              5  d t	        d      D        |d d d d d        | j                  t
              5  d |d d d d d        d | j                  t
        d      5  fdt	        d      D        |d d d d d        y # 1 sw Y   fxY w# 1 sw Y   OxY w# 1 sw Y   y xY w)Nrd   c              3   &   K   | ]	  }d dz    ywr  r   r  s     r   r  zIElementSlicingTest.test_issue123213_setslice_exception.<locals>.<genexpr>,  s     +(QQqS(r  r   r   c                      t        d      r  r  r   r   r   r,  zAElementSlicingTest.test_issue123213_setslice_exception.<locals>.f3  r  r   r  c              3   ,   K   | ]  }          y wrb   r   r  s     r   r  zIElementSlicingTest.test_issue123213_setslice_exception.<locals>.<genexpr>7  s     +(QQS(r  )r   r   r   r  r   r8  r  )rE   r   r,  s     @r   #test_issue123213_setslice_exceptionz6ElementSlicingTest.test_issue123213_setslice_exception(  s    JJu01+%(+AbqE 2 y)AbqE *	) ##I{;+%(+AbqE <; 21 *) <;s#   B'B3B?'B03B<?CN)rO   rP   rQ   r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r  r    sI    )+6?IJ82HPI(I,,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 G d d      Zd Zd Zd Zd Zd Zd Zd Zy)IOTestc           	         t         j                  d      }d|_        | j                  t	        |      d       dD ]d  }| j                  |      5  | j                  t	        ||      d       | j                  t	        ||j                               d       d d d        f dD ]  }| j                  |      5  | j                  t	        ||      d|z  j                  |             |j                         }| j                  t	        ||      d|z  j                  |             d d d         t         j                  d      }d	|_        | j                  t	        |      d
       | j                  t	        |d      d       | j                  t	        |d      d       dD ]1  }| j                  t	        ||      d|z  j                  |             3 t         j                  d      }d	|j                  d<   | j                  t	        |      d       | j                  t	        |d      d       | j                  t	        |d      d       dD ]1  }| j                  t	        ||      d|z  j                  |             3 t         j                  d      }d|_        | j                  t	        |      d       | j                  t	        |d      d       | j                  t	        |d      d       dD ]1  }| j                  t	        ||      d|z  j                  |             3 t         j                  d      }d|j                  d<   | j                  t	        |      d       | j                  t	        |d      d       | j                  t	        |d      d       dD ]1  }| j                  t	        ||      d|z  j                  |             3 y # 1 sw Y   xY w# 1 sw Y   QxY w)Nrd   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   r   r   r`   r  upperr9   r   )rE   r[   encr  s       r   r5  zIOTest.test_encoding:  s   zz% 	4*:;(Cc"  4#!>)+  4#))+!F)+ #" ) 6Cc"  4#!>*,/017> 		  4%!@*,12396#;@ #" 6 zz% 	4*GH4':.	04*=.	05CYtc:3589:@&+G 6
 zz% &E4*OP4':6	84*=6	85CYtc:<>ABCI6#;P 6
 zz% $	4*KL4':>	@4*=8	:5CYtc:13678>sE 6
 zz% -E4*NO4':A	C4*=;	=MCYtc:68;<=CVC[J Nu #" #"s   A	O7A/O*O'	*O4	c                 P   | j                  t        j                  t               t        j                  t        j                  d            }|j                  t               t        t        d      5 }| j                  |j                         d       d d d        y # 1 sw Y   y xY w)N   <site>ø</site>r[     <site>&#248;</site>)rf  r   rg  r   r   r?   r   rX   r$  r   r%  rE   r_   r,  s      r   test_write_to_filenamezIOTest.test_write_to_filename  si    	((&1~~bff%<=>

6&$1QVVX'AB  s   2!BB%c                    | j                  t        j                  t               t        j                  t        j                  d            }|j                  t        d       t        t        d      5 }| j                  |j                         d       d d d        |j                  t        d       t        t        d      5 }| j                  |j                         t        d             d d d        y # 1 sw Y   cxY w# 1 sw Y   y xY w)Nr  r   r  r[     <site>ø</site>r  :   <?xml version='1.0' encoding='ISO-8859-1'?>
<site></site>)rf  r   rg  r   r   r?   r   rX   r$  r   r%  r;   r  s      r   $test_write_to_filename_with_encodingz+IOTest.test_write_to_filename_with_encoding  s    	((&1~~bff%<=>

6G
,&$1QVVX'CD   	

6L
1&$1QVVX{6(7 8  	    s   4!C7*D7D Dc                    | j                  t        j                  t               t	        t        d      5 }|j
                  }d d d        t        j                  t               t        j                  t        j                  d            }|j                  t        d       t	        t        d      5 }| j                  |j                         d       d d d        y # 1 sw Y   xY w# 1 sw Y   y xY w)Nr  r  rS   r  r[  r  )rf  r   rg  r   r$  rT   r   r?   r   rX   r   r%  )rE   r,  rT   r_   s       r   !test_write_to_filename_as_unicodez(IOTest.test_write_to_filename_as_unicode  s    	((&1&#!zzH  ~~bff%<=>

6I
.&$1QVVX'?@     s   C2!C(C%(C1c                 >   | j                  t        j                  t               t        j                  t        j                  d            }t        t        dd      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        t        t        ddd	
      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        t        t        dd      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        y # 1 sw Y   IxY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   uxY w# 1 sw Y   y xY w)Nr  r  r   r  rS   r[  r  r2  xmlcharrefreplace)rT   errorsr  r  s   <site></site>rf  r   rg  r   r   r?   r   r$  rX   rb  rc  r   r%  r  s      r   test_write_to_text_filezIOTest.test_write_to_text_file  s   	((&1~~bff%<=>&#0AJJq9J-QXX& 1 &$1QVVX'CD   &#8KLPQJJq9J-QXX& M &$1QVVX(BC   &#5JJq9J-QXX& 6 &$1QVVX'?@   10   ML   65  sH   /G&!G""/G/)!G;$/H+!HG"G,/G8;HHHc                    | j                  t        j                  t               t        j                  t        j                  d            }t        t        d      5 }|j                  |       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        y # 1 sw Y   CxY w# 1 sw Y   y xY w)Nr  r^  r[  r  r  r  s      r   test_write_to_binary_filez IOTest.test_write_to_binary_file  s    	((&1~~bff%<=>&$1JJqMQXX&   &$1QVVX'AB      s   -C"!CCC!c                    | j                  t        j                  t               t        j                  t        j                  d            }t        t        d      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        t        t        d      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         d       d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   [xY w# 1 sw Y   y xY w)	Nr  r^  r   r  r[  r  r  r  r  r  s      r   'test_write_to_binary_file_with_encodingz.IOTest.test_write_to_binary_file_with_encoding  s   	((&1~~bff%<=>&$1JJq7J+QXX&   &$1QVVX'CD   &$1JJq<J0QXX&   &$1QVVX67          s0   /E$!E/E&$!E2EE#&E/2E;c                 <   | j                  t        j                  t               t        j                  t        j                  d            }t        t        d      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         dj                  d             d d d        t        t        dd      5 }|j                  |d       | j                  |j                         d d d        t        t        d      5 }| j                  |j                         dj                  d             d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   jxY w# 1 sw Y   y xY w)	Nr  r^  r  r  r[  u7   <?xml version='1.0' encoding='utf-16'?>
<site>ø</site>r   )	buffering)rf  r   rg  r   r   r?   r   r$  rX   rb  rc  r   r%  r9   r  s      r   "test_write_to_binary_file_with_bomz)IOTest.test_write_to_binary_file_with_bom  s/   	((&1~~bff%<=>&$1JJq8J,QXX&   &$1QVVX,,2F8,<>  
 &$!,JJq8J,QXX& - &$1QVVX,,2F8,<>      
 -,  s0   /E.$0E:./F50F.E7:FFFc                     t         j                         }t        j                  d      }|j	                  |       | j                  |j                         j                  d       y Nz"<?xml version="1.0"?><site></site>site)r   r?   rU   rW   r"  r   r   rd   rE   r_   r+  s      r   test_read_from_stringiozIOTest.test_read_from_stringio  sE    ~~EF

6++V4r   c                     t         j                  t         j                  d            }t        j                         }|j                  |d       | j                  |j                         d       y Nr  rS   r  )r   r?   r   rU   rW   rX   r   rY   r  s      r   test_write_to_stringiozIOTest.test_write_to_stringio  sM    ~~bff%<=>

6I
.*,CDr   c                     t         j                         }t        j                  d      }|j	                  |       | j                  |j                         j                  d       y Ns"   <?xml version="1.0"?><site></site>r  )r   r?   rU   rV   r"  r   r   rd   rE   r_   r  s      r   test_read_from_bytesiozIOTest.test_read_from_bytesio  sD    ~~jjBC

3++V4r   c                     t         j                  t         j                  d            }t        j                         }|j                  |       | j                  |j                         d       y Nr  r  )r   r?   r   rU   rV   rX   r   rY   r  s      r   test_write_to_bytesiozIOTest.test_write_to_bytesio  sG    ~~bff%<=>jjl

3)CDr   c                       e Zd Zy)IOTest.dummyNr  r   r   r   dummyr    s    r   r  c                    t        j                  d      }| j                         }|j                  |_        t        j                         }|j                  |       | j                  |j                         j                  d       y r  )
rU   rW   r  r%  r   r?   r"  r   r   rd   )rE   r+  readerr_   s       r   test_read_from_user_text_readerz&IOTest.test_read_from_user_text_reader  s[    EFkk~~

6++V4r   c                 $   t         j                  t         j                  d            }t        j                         }| j                         }|j                  |_        |j                  |d       | j                  |j                         d       y r  )	r   r?   r   rU   rW   r  rX   r   rY   )rE   r_   r+  writers       r   test_write_to_user_text_writerz%IOTest.test_write_to_user_text_writer  sc    ~~bff%<=>||

6I
.*,CDr   c                 6   t        j                  d      }| j                         }|j                  |_        t        j                         }|j                  |       | j                  |j                         j                  d       t        j                         }y r  )
rU   rV   r  r%  r   r?   r"  r   r   rd   )rE   r  r  r_   s       r   !test_read_from_user_binary_readerz(IOTest.test_read_from_user_binary_reader  sg    jjBChh~~

6++V4~~r   c                     t         j                  t         j                  d            }t        j                         }| j                         }|j                  |_        |j                  |       | j                  |j                         d       y r  )	r   r?   r   rU   rV   r  rX   r   rY   rE   r_   r  r   s       r    test_write_to_user_binary_writerz'IOTest.test_write_to_user_binary_writer  s^    ~~bff%<=>jjlyy

6)CDr   c                 t   t         j                  t         j                  d            }t        j                         }| j                         }|j                  |_        d |_        |j                  |_        |j                  |d       | j                  |j                         dj                  d             y )Nz<site />c                       yr  r   r   r   r   r4  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   rU   rV   r  rX   seekabletellr   rY   r9   r%  s       r   )test_write_to_user_binary_writer_with_bomz0IOTest.test_write_to_user_binary_writer_with_bom  s    ~~bff^45jjlyy&hh

6H
-%vh/	1r   c           	      R   t         j                  d      }| j                  t         j                  |d      dj	                  t         j                  |d                   | j                  t         j                  |d      dj	                  t         j                  |d                   y )Nz<tag>foo</tag>rS   rR  r  r   )r   r   r   r  r5  r6  r  s     r   test_tostringlist_invariantz"IOTest.test_tostringlist_invariant)  sy    }}-.KKi(GGBOOD)45	7 	KKh'HHR__T845	7r   c                    t         j                  d      }| j                  t         j                  |d      d       | j                  t         j                  |dd      d       | j                  t         j                  |dd      d       y )Nz<tag>a<x />b<y></y>c</tag>rS   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_elements2  sz    }}9:KKi(&	( 	KKidKC&	( 	KKieKD*	,r   N)rO   rP   rQ   r5  r  r  r  r  r  r  r	  r  r  r  r  r  r  r!  r#  r&  r+  r-  r0  r   r   r   r  r  9  sv    CJJC8	AA*C7">(5E5E 5E E
17
,r   r  c                   $    e Zd Zd Zd Zd Zd Zy)ParseErrorTestc                 T    | j                  t        j                         t               y rb   )r   r   re  r  r   s    r   rN  zParseErrorTest.test_subclass@  s    bmmo{;r   c                 t    	 t         j                  |       y # t         j                  $ r}|cY d }~S d }~ww xY wrb   )r   r   re  )rE   rl  r   s      r   
_get_errorzParseErrorTest._get_errorC  s,    	MM!}} 	H	s    7277c                    | j                  | j                  d      j                  d       | j                  | j                  d      j                  d       | j                  | j                  d      j                  d       y )Nr  )r   r   z<tag>&foo;</tag>)r   r  zfoobar<)r   r  )r   r5  positionr   s    r   test_error_positionz"ParseErrorTest.test_error_positionI  s`    /88&A);<EEvN3<<fEr   c                     dd l mc mc m} | j	                  | j                  d      j                  |j                  |j                            y )Nr   r  )	xml.parsers.expat.errorsparsersexpatr   r   r5  codecodesXML_ERROR_SYNTAX)rE   ERRORSs     r   test_error_codezParseErrorTest.test_error_codeN  s9    11/44V445	7r   N)rO   rP   rQ   rN  r5  r8  rA  r   r   r   r2  r2  ?  s    <F
7r   r2  c                       e Zd Zd Zy)KeywordArgsTestc                    t         j                  d      }| j                  |j                  dd       |j                  dd              | j                  |j	                  dd d       |j	                  dd d              | j                  |j                  dd       |j                  dd              | j                  t        |j                  dd             t        |j                  dd                    | j                  t         j                  d      j                  i        t         j                  dt        dd            t         j                  dt        dd            t         j                  dt        d	      d
      t         j                  ddd      t         j                  dt        dd      dd      g}|D ]E  }| j                  |j                  d       | j                  |j                  t        dd             G t         j                  |d   dddi      }| j                  |j                  d   d       | j                  t        d      5  t         j                  dd       d d d        | j                  t        d      5  t         j                  dd       d d d        y # 1 sw Y   @xY w# 1 sw Y   y xY w)Nz
<a>foo</a>r   )pathrR  )rE  r	  rR  #r  )r   r  )r   )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   r   ru   rd   rq  r  r8  )rE   r   elementsr   r  s        r   test_issue14818zKeywordArgsTest.test_issue14818W  s7   FF< T*ST:	<Ct4dtL	N3-=	?ajjd34ajjcdjCD	F 	C//4JJsDce45JJs4SU#;J<JJsDcNuJ5JJsJ/JJsDce435JI
 AQUUC(QXXt'?@  ]]8A;&(9K]L6*H5##I/FGJJs,- H##I/FGJJs#3J4 HG HGGGs   J5K5J>K
N)rO   rP   rQ   rJ  r   r   r   rC  rC  T  s    5r   rC  c                   "    e Zd Zed        Zd Zy)NoAcceleratorTestc                 F    t         t        urt        j                  d      y )Nzonly for the Python version)r   r   r  SkipTestrl   s    r   rm   zNoAcceleratorTest.setUpClassy  s     T>##$ABB r   c                     | j                  t        j                  j                  t        j
                         | j                  t        j                  j                  t        j
                         y rb   )r   r   r   r  typesFunctionTyper&  r   s    r   test_correct_import_pyETz*NoAcceleratorTest.test_correct_import_pyET  sD     	dll33U5G5GHdnn55u7I7IJr   N)rO   rP   rQ   r   rm   rR  r   r   r   rL  rL  x  s    C C
Kr   rL  c                       e Zd Zd Zy)BoolTestc                 ~   t         j                  d      }d}| j                  t        |      5  t	        |      }d d d        | j                  d       t         j                  |d       | j                  t        |      5  t	        |      }d d d        | j                  d       y # 1 sw Y   nxY w# 1 sw Y   (xY w)Nz<a style="new"></a>zTesting an element's truth value will always return True in future versions.  Use specific 'len\(elem\)' or 'elem is not None' test instead.Fr   T)r   r   r  r  boolr  rq  )rE   r   r   r~   
new_results        r   test_warningzBoolTest.test_warning  s    MM/0N 	 ""#5s;!WF < 	fe$ 	a""#5s;aJ <j$' <; <;s   B' B3'B03B<N)rO   rP   rQ   rX  r   r   r   rT  rT    s    (r   rT  c                 .    t        j                  | fi |S rb   )r   canonicalize)r  r]   s     r   c14n_roundtripr[    s    S,G,,r   c                   "    e Zd ZdZd Zd Zd Zy)C14NTestNc                 :   | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d	      d
       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       | j                  t        d      d       d}| j                  t        |      |       d}| j                  t        |      |       d}| j                  t        |      |       y )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[  rE   r  s     r   test_simple_roundtripzC14NTest.test_simple_roundtrip  s   1=A(<=)	+(JK:	<(UVE	G  )M  N	 	(TU&	((?@	 (qrW	Y  )B  C J	K(ab?	A(`aK	M(abA	C F,c2Z,c2^,c2r   c                 "   t        j                  d      }| j                  t        |d      d       | j                  t        |ddg      d       | j                  t        |ddg	      d
       | j                  t        |ddgdg      d       | j                  t        |dddg	      d       | j                  t        |ddg      d       | j                  t        |dddg	      d       | j                  t        |ddg      d       y )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)rb  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)rb  exclude_tagszb<root><a xmlns:x="http://example.com/x" x:attr="attrx"><b>abtext</b></a><b>btext</b><c></c></root>)rb  rc  rd  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>)rd  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  sA   oo 
 
 	340	 	34@\?]^	 	34?X>YZ	 	34@\?])B(CE	 	34sCjI	
 	3c3Z8	 	34?XZ]>^_	 	3.G-MN
	r   c                 	   t        dd      }t        t        j                  j                  |      }t        t        j                  |            D cg c]  }|j                  d      r|d d  }}|D cg c]  }|j                  d      r| }}|D ci c]  }|j                  d      rv|t        j                   ||      dz         j                         D ci c]?  }|j                  j                  d      d	   |j                  xs d
j                         |fA c} }}}|D ci c]W  }||D cg c]H  }|j                  d| d      r1|j!                  dd      d	   |v r|||j!                  dd      d	      fJ c}Y }	}}| j#                  dt%        |	j'                         D 
cg c]  }
|
D ]  }|  c}}
             d.d}|	j)                         D ]  \  }}
|
D ]  \  }} ||d      dk(  } ||d      dk(  } ||d      dk(  }d|v r|d   d   j+                  d      D cg c](  }d|j-                  d       d|j-                  d       * }}|d   d   j+                  d      D cg c](  }d|j-                  d       d|j-                  d       * }}nd x}}dj	                  d t        |j)                               D              }| j/                  | d| d      5  |dk(  r|s| j1                  d |        |d!k(  r|s| j1                  d |        d|v r,|d   d   j3                  d"      	 | j1                  d#|         ||dz         }|d$k(  rqt5         |d%      d&      5 }t5        |d&      5 }t7        j8                  |j;                         j=                  d'|j;                                     }d d d        d d d        t        j?                  ||||||(      }t5         ||dz         d)d*+      5 }|j;                         }|d,k(  r$|j=                  d-d
      }|j=                  d-d
      }d d d        | j#                  |       d d d          y c c}w c c}w c c}w c c}}w c c}w c c}}w c c}}
w c c}w c c}w # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   rxY w# 1 sw Y   xY w)/Nzc14n-20r   r   z.xmlr  inc14n}r  rR  out_r9  r      c                 0    | j                  ||df      d   S )Nr   r   )rw   )configoption_namer	  s      r   
get_optionz+C14NTest.test_xml_c14n2.<locals>.get_optionA  s    ::kGR=9!<<r   IgnoreCommentstrueTrimTextNodesPrefixRewrite
sequential
QNameAwarez/{http://www.w3.org/2010/xml-c14n2}QualifiedAttr{NSNamez){http://www.w3.org/2010/xml-c14n2}Element,c              3   j   K   | ]+  \  }\  }}| d |xs dj                  d |D                - yw)=ry  c              3   X   K   | ]"  }|j                   j                  d       d    $ yw)ri  r  N)rd   split)r  r   s     r   r  z4C14NTest.test_xml_c14n2.<locals>.<genexpr>.<genexpr>\  s#     /WhC0@0Dhs   (*N)r5  )r  ry   r   r  s       r   r  z*C14NTest.test_xml_c14n2.<locals>.<genexpr>[  sB      (3I//uh fAeWsxx/Wh/W'WXY3Is   13()
inNsRedeclz2Redeclared namespace handling is not supported in inNsSuperfluousz.{http://www.w3.org/2010/xml-c14n2}XPathElementz2QName rewriting in XPath text is not supported in inC14N5z	world.txtr[  s   &ent2;)	from_filewith_commentsrb  rewrite_prefixesqname_aware_tagsqname_aware_attrsrr  r  inC14N3z attr="default"rb   ) r
   r   r7   rE  r5  r  listdirendswith
startswithr   r"  r   rd   r}  r   r  rsplitr   r   valuesr   r   rw   r  r	  r   r$  rU   rV   r%  r6   rZ  )rE   datadir	full_pathfilenamefilesinput_filesoptionconfigs
input_filetestsoutput_filesoutput_filero  rm  keep_commentsrb  r  r  qattrsqtagsconfig_descrr,  entity_filer   r   s                            r   test_xml_c14n2zC14NTest.test_xml_c14n2  sx   9];BGGLL'2	/5bjj6I/J //J8%%f- #2/J / &+
%*""4( U 	 
 "
 """6*  !hhy':V'CDLLN OF 

  %b)V[[->B,E,E,G+PPN 
 " 	 
" *
 *
  % %H&&j\';<OOC+B/7: 78??3#:2#>?@ %  * 	 
 	S,1LLN"-,:L+ + N"- . 	/	= ).$J'3#V *,!.17!8'O-067
#-O$-0<$= 6) #)"6q"9"A"AM#O#OB RVVD\N"RVVF^,<=#O   #)"6q"9"A"AG#I#IB RVVD\N"RVVF^,<=#I   &*)EF  #xx (39&,,.3I(  
 \\[M<."BC!\1:JPQ\P]^`!%66?OPQ\P]^`#v-&2Fq2I2N2NL3NUY3ZPQ\P]^` "*v"56A!Y.!)K"8$?;!%a!$&JJqvvx/?/?	;K[K[K]/^$_ "/ @ ??"#&3#-)9).& + JD if(<=sVTXY#$668%2'/'7'78I2'NH#'<<0A2#FD U $$Xt4A DC7 (4 )6E/



"- 
< "/ @? UT5 DCs   Q/5Q4AQ>AQ9Q>,
R	6ARR	/R0-R8-R2B	S;R+	AR
R+	:S:R7	S9Q>R	R($R+	+R40S7S <SS)rO   rP   rQ   maxDiffr`  re  r  r   r   r   r]  r]    s    G
&3PG`b5r   r]  c                    t        ddg      a| t        } | ad }t        j                  |       ddlm} t        j                  j                  }|j                         }t        j                  |j                  |       t        j                  |j                         |j                  }t        j                  t        |d|       |j                         |_        t        t        d      rWt        j                  t        j                   t        j"                        }t        j                  t        j                  g|  y y )	NrH   rI   )blockedc                      d xa ay rb   r   r   r   r   cleanupzsetUpModule.<locals>.cleanup  s    Tr   r   rB   r   _set_factories)r   r   r   r  addModuleCleanuprD   rC   ro  _namespace_mapr  rU  r   r   setattrr   r  rr  r   )moduler  rC   r  
nsmap_copyr  old_factoriess          r   setUpModuler    s     6(6'79D~ 
B g& &!!00EJellJ7ekk* ##Jg{HjI#*K r#$))"**bee<!!""3"3DmD %r   __main__)TrS   rb   )[r  r0   r8  rU   r  r   r7   rq   r  rp   r  rP  r  unittest.mockr    r  r  
contextlibr   r   r   r   r.   r   test.supportr   r	   r
   r   r   r   test.support.import_helperr   test.support.os_helperr   r   r   r   r9   UnicodeEncodeErrorrN  r#  r  r   r  rD  r  r@  rA  r  r   r%   r3   r;   TestCaser=   r`   rf   ri   r   r  r  formatescaper1  r  r5  r  r   r   r  r  r  r  r  r  r	  r  r  r  r  r  r2  rC  rL  rT  r[  r]  r  rO   mainr   r   r   <module>r     s
      	   	   
       "  %  " ( C C : ) 	,}=A'" _]C 3MJ 
 "
 E #( 4
L"" 
L&= =@YPh'' YPx$l9)) l9b	  	   !      F;4;;~t,- 	 	'	" # X X 	 	 	 p78$$ p7lm?x   m?hB4(9(9 B4Jl_h&7&7 l^	
 

s 
S E(*;*; EP5.(++ 5.pv:h'' v:r](h'' ](@t.h'' t.nQ:H%% Q:hE** Ed,** d,LC,X C,L7X&& 7* 5h''  5HK)) K (x   ((-`5x   `5H"EJ zHMMO wK  A
(

?
@@As   M M&