a 5dgi@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl Z ddlZddlmZddlmZmZddlmZddlmZmZmZmZmZdadaedddZzed Wneye d Yn0ed ddZ ed ddZ!d Z"dZ#dZ$dZ%dZ&dZ'ddddZ(Gddde j)Z*dnddZ+ddZ,Gdd d Z-Gd!d"d"e j)Z.Gd#d$d$e j)Z/iZ0d%e0d&<d'e0d(<d)e0d*<d+e0d,<d-e0d.<d/e0d0<d1e0d2<d3e0d4<d51e2ede0d6<d7e0d8<iZ3d9e3d:<d;e3d<<d=e0d><d?e0d@<dAe0dB<GdCdDdDe j)Z4GdEdFdFe j)Z5GdGdHdHe-e j)Z6GdIdJdJe-e j)Z7GdKdLdLe8Z9e8j:e9_:GdMdNdNe8Z;e8j:e;_:GdOdPdPe-e j)ZGdUdVdVe j)Z?GdWdXdXe j)Z@GdYdZdZe j)ZAGd[d\d\e j)ZBGd]d^d^e j)ZCGd_d`d`e j)ZDGdadbdbe j)ZEGdcdddde j)ZFGdedfdfe j)ZGdgdhZHGdidjdje j)ZIdodkdlZJeKdmkreJdS)pN)partial)productislice)support)TESTFNfindfileimport_fresh_module gc_collect swap_attrz simple.xml xmltestdataZsubdirutf-8z!filename is not encodable to utf8z simple-ns.xmlzexpat224_utf8_bug.xmlz text
subtext
zz
subtext
zy text
subtext
z Apples Bananas African Coffee Table 80 120 zy %user-entities; ]> &entity; zl ]> &entity; F)quietcsfdd}|S)Ncs fdd}t||S)NcsBtjdi|i|Wdn1s40YdS)Nr)rZcheck_warnings)argskwargs)filtersrtest//usr/local/lib/python3.9/test/test_xml_etree.pynewtestlsz1checkwarnings..decorator..newtest) functoolsupdate_wrapper)rrrr)rr decoratorks z checkwarnings..decoratorr)rrrrrr checkwarningsjsrc@seZdZddZddZdS) ModuleTestcCs(ddlm}ddlm}ddlm}dS)Nr) ElementTreeElementInclude ElementPath) xml.etreerrr )selfrrr rrr test_sanityus  zModuleTest.test_sanitycCsd}tj|t|dddS)N)xml.etree.ElementTree _elementtree)Z HTML_EMPTY)Z blacklist)rZ check__all__ET)r"namesrrrtest_all|szModuleTest.test_allN)__name__ __module__ __qualname__r#r(rrrrrtsrTunicodecKsX|dkrt}nt}t|}|j|fd|i||rF|S|d|SdS)Nr,encodingr)ioBytesIOStringIOr&rwritegetvalueseek)elem to_stringr-optionsfiletreerrr serializes   r9cCsdd|DS)NcSsg|] }|jqSrtag.0r4rrr z"summarize_list..r)seqrrrsummarize_listsrAc@s(eZdZeddZddZddZdS)ElementTestCasecCstth|_dSN)pyETr&modules)clsrrr setUpClassszElementTestCase.setUpClassc Cstj|}zz.|tj|<t||}|tj|<t|}Wn`tjy} zFttdftdfg} t d|| ||| ||f| WYd} ~ n d} ~ 00W|tj|<n |tj|<0|S)NZcETrDz%Failed to round-trip %r from %r to %r) sysrEpickledumpsloads PicklingErrordictr&rDrZ TestFailedget) r"objnamedumperloaderprotoZsave_mZtempresultpeZhumanrrrpickleRoundTrips$      zElementTestCase.pickleRoundTripcCs||tjtjf||tjtjf|tt|tt|t||D]\}}|||qNt dddd}|||||dS)Nr;tailtextattrib) assertIsInstancer&ElementrD assertEquallenlistzipassertEqualElementsoperator attrgetter)r"ZalicebobxyZ propertiesrrrr`sz#ElementTestCase.assertEqualElementsN)r)r*r+ classmethodrGrVr`rrrrrBs rBc@sdeZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dQdRZ+dSdTZ,dUdVZ-dWS)XElementTreeTestcCs|t||dSrC)r\r9)r"r4expectedrrrserialize_checkszElementTreeTest.serialize_checkcsfddfddfddtd}|t|}|tjdd d }t|}t|d tjdd d }fd d |j|j|j|j |j |j |j |j |j|j|j|j|j|j|jfdd}|| d|| d|| d|| dtjtjtjtjdS)NcsJt||D]}jt|dd|dq |d}|d}|dddS)Nz%expected one-character string, got %rmsg r)r]r\)stringcharZ new_stringr"rr check_strings z4ElementTreeTest.test_interface..check_stringcsRt||}|}|D] }||}qd|d<j|ddd|dddS)Nvaluekeyzexpected value string, got %rrk)r]keysitemsr\)mappingrurvrtitemrqrr check_mappings   z5ElementTreeTest.test_interface..check_mappingcsjt|ddt|}dD]0}jt||d|dj||d|dq |j|j|jdurz|j|j dur|j |D] }|qdS)Nznot an elementrk)r;rYrXrWz no %s memberzno %s visible by dir) assertTruer&Z iselementdirhasattrassertInr;rYrXrW)elementZdirelemattrr4) check_elementryrrr"rrrs"       z5ElementTreeTest.test_interface..check_elementr;tägrsrtz^$csjt|dd|ddS)N__call__z%s not callablerk)rzr|methodrqrr check_methods z4ElementTreeTest.test_interface..check_methodcs|jdSrC)__next__)it)rrr check_itersz2ElementTreeTest.test_interface..check_iter*)r&r[rgetroot assertRegexreprappendextendinsertremovefinditerfindfindallfindtextclearrNsetrurviteritertextr\XML fromstringPIProcessingInstruction)r"r~r8rr)rryrrrr"rtest_interfacesD                      zElementTreeTest.test_interfacecCstd}||jdd|_||jdd|_||jd||jd|_||jdd|_||jd||jd|_||jdd|_||jd||jidd d |_||jdd d d d d |_||jd d d dS)Nr;TagZTAGTextZTEXTZTailZTAILbd)acBD)AC)r&r[r\r; assertIsNonerXrWrY)r"r~rrrtest_set_attributes*     z"ElementTreeTest.test_set_attributecCstd}||dtd}||||d||||d|d|||d||||g||d|||t|g||d||tjddd }||d td }||||d |d|||d ||||d ||||d | t }||Wdn1s`0Y| t |j d||d |||g|dd<||dd| |dd|d|dg| |ddd|d|dg|dd=||d dS)Ntag2zrzr;rsrzsubtagz!z+zlist.remove(x): x not in listrjz )r&rrir[rrrrr assertRaises ValueErrorr\str exception)r"r4er~Z subelementcmrrrtest_simpleops+sR                         *  " zElementTreeTest.test_simpleopscCs:|tdd|tdd|tdddS)Nzhelloz)helloz)rir&rrqrrr test_cdataWs   zElementTreeTest.test_cdatacCs|ttd}tj|d}||djd||djdtjt d}||djd||djddS)Nr )r7r; section/tagr~zelement/../empty-element empty-element) r.r/ SAMPLE_XMLencoder&rr\rr;SIMPLE_XMLFILE)r"Z stringfiler8rrrtest_file_initas  zElementTreeTest.test_file_initcCsddlm}tt}tdD]}t|dt|qt |j }tdD]}t|dt|qN| t |j |tdD]}t|dt|q| t |j |tdD]}t|dt|q| t |j ddS)Nrr z./iXi)r!r r&rrrangerrrr]_cacher\Z assertGreaterZ assertLess)r"r r4iZ cache_len_10rrrtest_path_cachels  & &&&zElementTreeTest.test_path_cachecCsZddl}td}||}||}d|d_||d||d||ddS)Nrzhellobarfoozhellozhello)copyr&rdeepcopyrr;ri)r"re1e2e3rrr test_copy{s      zElementTreeTest.test_copycCs&td}|d||ddd|dd||ddtjddd}||dd||jddiddi}td|}|||dd||jddiddi}tjdi|}|||dd||jdditjdddidd}||dd||jdditd}d|_|d d |d d |t|d |t | d d g|t | ddg||jd d d|jd <d |jd<|t|dtd}|dd|dd|dd|dd|t|ddS)Nr;rtdefaultrsrotherrZaatestatestvaltestbtest2s-aa)rr)rrZtest1Ztestcs;aar r rz rz s[)r;) r&r[rNr\rrYrrXtostringsortedrurv)r"r4rYrrr test_attribs\                 zElementTreeTest.test_attribcCstd}ddi}|d|}|j|j|dd||||d|||d||||d|||g||d |g|dd<||dt |g|dd<||ddS) Nr;rtrsrzattrib aliasingrkz!zM) r&r[Z makeelement assertIsNotrYrrirrtuple)r"r4rYsubelemrrrtest_makeelements$        z ElementTreeTest.test_makeelementcCstt}t}|j|dd||dtt}t}|j|dd||dt t}| }Wdn1s0Yt }| |j d||||dt}tj |d}||||ddS)Nr,r-zi text texttail z text texttail z^Expat target)r&parserr.r0r1r\r2SIMPLE_NS_XMLFILEopenread XMLParserrversionfeedriclose TreeBuilder)r"r8streamfdataparserrrrrtest_parsefiles4     &     zElementTreeTest.test_parsefilecCstd}|tj|dddtd}|tj|dddgd}t|}|t|d|dt|d|t|ddtd\}}|t |d td \}}|t |d ||d j d dS) Ntextr,r)z ztexttextr?asciisE textrz(textrjbody) r&rr\rrZfromstringlistjoin tostringlistZXMLIDr]r;)r"r~Zsequence_Zidsrrrtest_parseliterals0    z!ElementTreeTest.test_parseliteralc Cstj}|t}t|\}}|||jfd|dd|Dgd||jjd|t}|dd|Dgdd}|t|}|d d|Dgd}|t|d }|d d|Dgd }|t|}|d d|Dgdd}|t|}|dd|Dgdd}|t d|}dd|D}||ddgd}t tdR}| t }|||Wdn1s0Y| |jWdn1s0Y|t|jdt|Z| t }|t|Wdn1s0Y|t|jd~Wdn1s40Ytd} d}|| |}|dd|Dddgt d} || } t| \}}|||jfd | tj}t| Wdn1s0Y|t|jd!|tjtt td"}|d#Wdn1s"0Y|t} t| \}}|||jfd t|\| tj}t| Wdn1s0Y|t|jd!~~ Wdn1s0YdS)$Nendr~cSsg|]\}}||jfqSrr:r=actionr4rrrr>r?z2ElementTreeTest.test_iterparse..)rrrrrootrcSsg|]\}}||jfqSrr:rrrrr>&r?)r{namespace}elementrr{namespace}empty-elementr{namespace}rootrcSsg|]\}}||jfqSrr:rrrrr>/r?eventscSsg|]\}}||jfqSrr:rrrrr>3r?startrcSsg|]\}}||jfqSrr:rrrrr>7r?rrrr~rr r)rrrr)rrstart-nsend-nscSs*g|]"\}}|dvr||jfn||fqS)rr:rrrrr>Ds) r )rm namespacerrrrrrrrrrrr Nr r zcSsg|] \}}|qSrrrrrrr>Ur?r r rrZbogusrbzunknown event 'bogus's text )r cSsg|]\}}||fqSrrrrrrr>kr?)r )rmuhttp://éffbot.org/ns)r )ucléhttp://effbot.org/nszjunk)rdocumentz.junk after document element: line 1, column 12wbsjunk)r& iterparsernextr\r;rrr.r0rrr assertFalseclosedrrrZcheck_no_resource_warningr/ ParseError addCleanupunlinkrr1) r"rcontextrr4rresrrsourcerrrrtest_iterparses         *,  *"   (  *  ( zElementTreeTest.test_iterparsecCstd}d|_||ddt|d_||dd|_||d|dtd ||d td d |d<||d dS)Nr;rXztextsubtextrz'textsubtextztextsubtextrcommentz*textsubtextrtrsz)textsubtext) r&r[rXri SubElementr;rCommentrr"r4rrrtest_writefiles    zElementTreeTest.test_writefilecCstt}|}Wdn1s&0YGdddt}|}tj|d}||||gdtt}|}Wdn1s0YGdddt}|}tj|d}||||gddS)Nc@s$eZdZddZddZddZdS)4ElementTreeTest.test_custom_builder..BuildercSs|d|fdSNrrr"r;rYrrrrs:ElementTreeTest.test_custom_builder..Builder.startcSs|d|fdSNrr+r"r;rrrrs8ElementTreeTest.test_custom_builder..Builder.endcSsdSrCrr"rXrrrrs9ElementTreeTest.test_custom_builder..Builder.dataN)r)r*r+rrrrrrrBuildersr3rrc@sDeZdZddZddZddZddZd d Zd d Zd dZ dS)r)cSs|d|fdSr*r+r,rrrrsr-cSs|d|fdSr.r+r/rrrrsr0cSsdSrCrr1rrrrsr2cSs|d||fdS)Npir+)r"rrrrrr4sz7ElementTreeTest.test_custom_builder..Builder.picSs|d|fdS)Nr$r+)r"rrrrr$sz.Builder.commentcSs|d||fdS)Nr r+)r"prefixurirrrstart_nssz=ElementTreeTest.test_custom_builder..Builder.start_nscSs|d|fdSNr r+r"r5rrrend_nssz;ElementTreeTest.test_custom_builder..Builder.end_nsN) r)r*r+rrrr4r$r7r:rrrrr3s) )r4r4r)r$ comment )r rmr rrrrrrrrr rm) rrrr^r&rrr\r)r"rrr3builderrrrrtest_custom_builders &   &  z#ElementTreeTest.test_custom_buildercCsFGdddt}|}tj|d}|td||gddS)Nc@seZdZddZdS)z@ElementTreeTest.test_custom_builder_only_end_ns..BuildercSs|d|fdSr8r+r9rrrr:szGElementTreeTest.test_custom_builder_only_end_ns..Builder.end_nsN)r)r*r+r:rrrrr3sr3ra text texttail ))r r)r pr<)r^r&rrtextwrapdedentr\)r"r3r=rrrrtest_custom_builder_only_end_nss   z/ElementTreeTest.test_custom_builder_only_end_nscCs|ttd}t|}Wdn1s*0Y|dd|Dgdgggg|dd|Dgdggggtt}|t t |d|t t |dd||ddt ||d }|d}|dd=|t t |d|||d |||d||g|d d<|||d |||d| ||d | |t |gdS) NrcSsg|] }t|qSrrAr<rrrr>sz1ElementTreeTest.test_children..)r~r~rcSsg|] }t|qSrrCr<rrrr>srrjr) rrr&rr\rrrrr]r^assertNotEqualr)r"rr8r4child1child2rrr test_childrensH (     zElementTreeTest.test_childrencCs<td}|t|dtd}|t|ddS)Nrr)r&rr\rrr'rrrtest_writestrings  z ElementTreeTest.test_writestringcCstd}t||t|dtd}t||t|dtd}t||t|dtd}t||t|dtd}t||t|d td }t||t|d dS) Nz srs" text z! text z"texttails% texttailz=

par

text


s^

par

text


8

pre
post

text

sJ

pre
post

text

r&rindentr\rr'rrr test_indents0            zElementTreeTest.test_indentcCsXtd}tj|dd|t|dtd}tj|dd|t|ddS)NrJ )spacesD

pre
post

text

rms>

pre
post

text

rKr'rrrtest_indent_spaceAs  z!ElementTreeTest.test_indent_spacecCstd}t||dd|Dhd|dd|Dhd|tdd|Dtdd|DdS) Nz@

par

text


cSsh|] }|jqSrrWr=elrrr ^r?z.>N   cSsh|] }|jqSrrXrRrrrrTbr?>NZparrXrUz rWcSsh|] }|jqSrrQrRrrrrTfr?cSsh|]}t|jqSr)idrWrRrrrrTgr?)r&rrLr\rr]r'rrrtest_indent_space_cachingZs  z)ElementTreeTest.test_indent_space_cachingcCstd}|ttj|ddWdn1s80Y|t|dtj|dd|t|dtd}tj|ddd |t|d dS) NrJ)levels9

pre
post

text

rs^

pre
post

text

rjrn)r\rOsI

pre
post

text

)r&rrrrLr\rr'rrrtest_indent_leveljs$  , z!ElementTreeTest.test_indent_levelcCs<td}|tj|ddd|tj|dddddS)N0r,rArr-default_namespace1r&rr\rr'rrrtest_tostring_default_namespaces  z/ElementTreeTest.test_tostring_default_namespacecCs&td}|tj|dddddS)Nr^r,foobarr`zPrcr'rrr3test_tostring_default_namespace_different_namespaces  zCElementTreeTest.test_tostring_default_namespace_different_namespacecCsNtd}d}|t| tj|dddWdn1s@0YdS)Nrz>^cannot use non-qualified names with default_namespace option$r,rer`)r&rassertRaisesRegexrr)r"r4Z EXPECTED_MSGrrr5test_tostring_default_namespace_original_no_namespaces zEElementTreeTest.test_tostring_default_namespace_original_no_namespacecCs$td}|tj|ddddS)Nrr,rrrcr'rrr test_tostring_no_xml_declarations   z0ElementTreeTest.test_tostring_no_xml_declarationcCs&td}|tj|dddddS)Nrutf8Tr-xml_declarations: rcr'rrrtest_tostring_xml_declarations  z-ElementTreeTest.test_tostring_xml_declarationcCs6td}t}|d|dtj|ddddS)Nr r,Trk)r&rlocalegetpreferredencodingr\r)r"r4preferredencodingrrr.test_tostring_xml_declaration_unicode_encodings   z>ElementTreeTest.test_tostring_xml_declaration_unicode_encodingcCstd}t}dddddddd d d d d ddd|dddfg}|D]X\}}}|d|d|(|tj|||d|WdqF1s0YqFdS)Nø)øNN)øUTF-8N)ruUS-ASCIIN)E ISO-8859-1N)rtr,N)ruNF)rvrwF)rurxF)srzF)rtr,F)sH øNT)sA ørwT)sH ørxT)ryrzTrnu'?> ør,Tz encoding=z xml_declaration=rk)r&rrprqsubTestr\r)r"r4rrZ TESTCASESZexpected_retvalr-rlrrr#test_tostring_xml_declaration_casess@    z3ElementTreeTest.test_tostring_xml_declaration_casesc CsHtd}|dtj|ddd|dtj|dddddS) Nr^rmr,rr_rr`rb)r&rr\rrr'rrr#test_tostringlist_default_namespaces z3ElementTreeTest.test_tostringlist_default_namespacecCstd}|dtj|ddd|dtj|ddd t}tj|ddd }|d|d |d ||d d|gd|dddS)Nrrmr,rrr?T)rls> rkrnrorz%^<\?xml version='1.0' encoding='.+'?>)zzzrj)r&rr\rrrprqr)r"r4rrZ stringlistrrr!test_tostringlist_xml_declarations"  z1ElementTreeTest.test_tostringlist_xml_declarationc sdfdd }|dd|dd|dd|d d |d d |d dddfdd}gd}|D] }tt||dqjgd}|D]}ttj||qgd}|D]}tjtj||qttjddttjdddS)Nrmcs>d||f}t||j|t|j|dS)Nz0%s)r\r&rrrX)r-rxmlrqrrchecks z,ElementTreeTest.test_encoding..checkrrus-ascii iso-8859-1½z iso-8859-15u€cp437u√ mac-romanu˚cSsd|S)Nz*rrrrrrsz*ElementTreeTest.test_encoding..xmlcs||SrC)rr)rrrbxmlsz+ElementTreeTest.test_encoding..bxml)Crr z utf-8-sigutf-16utf-16beutf-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-16rZcp720Zcp737cp775cp850cp852cp855Zcp856cp857cp858cp860cp861cp862cp863cp865cp866cp869Zcp874Zcp1006cp1125cp1250cp1251cp1252cp1253cp1254cp1255cp1256cp1257cp1258z mac-cyrillicz mac-greekz mac-icelandz mac-latin2rz mac-turkishz iso2022-jpz iso2022-jp-1z iso2022-jp-2ziso2022-jp-2004z iso2022-jp-3ziso2022-jp-extzkoi8-rzkoi8-tzkoi8-ukz1048hzptcp154s)big5 big5hkscscp932cp949cp950zeuc-jpz euc-jis-2004z euc-jisx0213zeuc-krgb2312gbkgb18030z iso2022-krjohabz shift-jiszshift-jis-2004zshift-jisx0213zutf-7) cp037cp424cp500cp864Zcp875cp1026cp1140utf_32 utf_32_be utf_32_leZ undefinedZxxx)rm) r\r&rrrrrr LookupError)r"rrZsupported_encodingsr-Z&unsupported_ascii_compatible_encodingsZ(unsupported_ascii_incompatible_encodingsrr"rr test_encodings(        zElementTreeTest.test_encodingcCsttd}d|_|t|d|t|ddd|t|ddd|t|ddd|t|ddd dS) Nz-rVz/ rrhtmlz* rXz1 < 2 )r&rrWr\r9r"rrrr test_methods?s  zElementTreeTest.test_methodscCs2td}|t|d|t|ddddS)Nz(textrrr&rr\r9rrrrtest_issue18347Ns  zElementTreeTest.test_issue18347cCs8td}|t|ddd||d|tj}tdWdn1sV0Y|t|jd|tj}tt Wdn1s0Y|t|jdt }d |j d <| t | }||d |tj}ttWdn1s0Y|t|jd dS) Nz*testrrs*testu%testz&entity;z#undefined entity: line 1, column 10z,undefined entity &entity;: line 5, column 10rXentityztextz,undefined entity &entity;: line 4, column 10)r&rr\r9rirrrr ENTITY_XMLrrrrEXTERNAL_ENTITY_XML)r"rrrrrrr test_entityUs2  ( (    * zElementTreeTest.test_entitycCsrtd}||dtd}||dtd}||dtd}||dtt}||d dS) NzzzCzCz7z7zGzEz text subtext )r&rri SAMPLE_XML_NSr'rrrtest_namespacezs$      zElementTreeTest.test_namespacecCstd}||dttd}||dttdd}||dttdd}t|tdd}t|tdd}||d|d|jd <||d |d|jtd <||d |d |jd <||d |td |jd <||d |td}td|jd<||||||d|t tddd|t tddtdd}tdd}|||tdd}| ||| |d||ddS)Nz{uri}tagzr6r;Ztag1rz;rsz{uri}keyz+z {uri}valuez0z/z {uri2}valuez {uri1}keyz{nsz{ns}tagz other-tagzns:tag) r&r[riQNamer%rrYrr\rrE)r"r4rZq1Zq2rrr test_qnamesb               zElementTreeTest.test_qnamecCstd}dS)Nztext)r&rr'rrrtest_doctype_publicsz#ElementTreeTest.test_doctype_publiccsddlmd?fdd }|ddg|dddg|d d d g|d d dg|d gd|dgd|dgd|dgd|dgd|dddg|dgd|ddg|dgd|ddg|d gd!|d"gd#|d$gd%|d&d d'g|d(d(g|d)gd*|d+gd,|d-d-g|d.d.g|d/d/g|d0d0g|d1gd2|d3gd4d5d6i|d7d8gd9d6i|d:d d8gd5d6i|d;d d7gd9d6i|ddS)@Nrrcs"dd||D|dS)NcSsg|]\}}|p|qSrr)r=opr;rrrr>szGElementTreeTest.test_xpath_tokenizer..check..)r\Zxpath_tokenizer)r?rh namespacesr r"rrrs   z3ElementTreeTest.test_xpath_tokenizer..checkrztext()rX()z@name@rPz@*zpara[1])para[1]z para[last()])rrZlastrrz*/para)r/rz/doc/chapter[5]/section[2]) rdocrchapterr5rrsectionr2rz chapter//para)r//rz//pararrz //olist/item)rZolistrrx.z.//para)rrr..z../@lang)rrrlangzchapter[title])rrtitlerz#employee[@secretary and @assistant]) ZemployeerrZ secretaryrmandrmrZ assistantrz @{ns}attrz{ns}attr{http://spam}eggz ./spam.egg)rrzspam.eggz.//{http://spam}egg)rrrz{ns}*{}*{*}tag{*}*z .//{*}tag)rrrz ./xsd:type)rr&{http://www.w3.org/2001/XMLSchema}typeZxsdz http://www.w3.org/2001/XMLSchematyperrmz @xsd:typez@typez@{*}typez{*}type)rmr)N)r!r )r"rrrrtest_xpath_tokenizersd              z$ElementTreeTest.test_xpath_tokenizercCsn|ttddd|ttddd|ttddd|ttdddddS) NrZ instructionsz s?>u ãzlatin-1s= ?>)r\r&rrrrqrrrtest_processinginstructionsz*ElementTreeTest.test_processinginstructioncCspdD]f}||fD]T}d|}ttd|dd}|||ttd||fdd}|||qqdS)N) ZAREAZBASEZBASEFONTZBRZCOLFRAMEZHRZIMGZINPUTZISINDEXZLINKZMETAZPARAMz<%s>z<%s />rrz <%s>)lowerr9r&rr\)r"r~r4rhZ serializedrrr#test_html_empty_elems_serialization.s z3ElementTreeTest.test_html_empty_elems_serializationcCsVtjdddd}t}t|Wdn1s80Y||ddS)N cirriculumpublicexamplestatusZcompanyz1 )r&r[rcaptured_stdoutdumpr\r2)r"rstdoutrrrtest_dump_attribute_order;s  ( z)ElementTreeTest.test_dump_attribute_ordercCs8tjdddd}|t|d|t|ddddS) Nrrrrz0rrz;)r&r[r\r9r"rrrrtest_tree_write_attribute_orderCs z/ElementTreeTest.test_tree_write_attribute_orderN).r)r*r+rirrrrrrrrrrrr"r(r>rBrHrIrMrPrZr]rdrfrhrirmrsr|r}rrrrrrrrrrrrrrrrrrgsVV,   6-p=%,  - ;%!A: rgc@seZdZd ddZd!ddZd"ddZd#dd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZddZddZdS)$XMLPullParserTestNcCsD|dur||n,tdt||D]}|||||q$dSNr)rrr])r"rr chunk_sizerrrr_feedNs zXMLPullParserTest._feedcCs$|ddt||D|dS)NcSs g|]\}}||j|jffqSr)r;rX)r=eventr4rrrr>Wsz3XMLPullParserTest.assert_events..)r\r read_eventsr"rrh max_eventsrrr assert_eventsUs  zXMLPullParserTest.assert_eventscCs|tt|||dSrC)r\r^rrrrrrassert_event_tuples[sz%XMLPullParserTest.assert_event_tuplescCs(t||}|dd|D|dS)NcSsg|]\}}||jfqSrr:rrrrr>br?z7XMLPullParserTest.assert_event_tags..)rrr\)r"rrhrrrrrassert_event_tags`sz#XMLPullParserTest.assert_event_tagsc CsdD]}|j|dt}||g||d|||g||d|||g||d|||dg||d|||d|||dd g||d |||d g||Wdq1s0YqdS) N)Nrj)r z+ text rtexttail  r r)r{r& XMLPullParserrrrr)r"rrrrrtest_simple_xmles,   z!XMLPullParserTest.test_simple_xmlcCst}|}||dt|\}}|||jfd||dt|\}}|||jfd|tt|Wdn1s0YdS)Nz- text rrr) r&rrrrr\r;r StopIteration)r"rrrr4rrrtest_feed_while_iterating|s     z+XMLPullParserTest.test_feed_while_iteratingcCst}||g||d||g||d||g||d||g||d||dg||d||d||ddg||d ||d g||dS) Nr "text r )rmabcr )r?Zxyzrrr{abc}tagrj r {abc}childrr rrr&rrrrrr rrrtest_ns_events_starts.    z&XMLPullParserTest.test_ns_events_startcCstjdd}||d|j|ddgdd|j|dgd d||d ||d d g||d ||j|dgd d||ddgdS)N)r rrr rrrrrrrrjrrrrrrrr rrrtest_ns_events_start_ends:    z*XMLPullParserTest.test_ns_events_start_endcCstjdd}||d||gtjdd}||d||gtjdd}||d||dg||d||d g||d ||d g||d ||gd ||d||||dgtjdd}||d||g||d||dg||d||d g||d ||g||d ||ddg||d||dS)Nrrz r z rr r rrz8texttail )r {foo}elementr{foo}empty-element)rr")rr zr)rrrr!)r&rrrrrrr rrr test_eventssL                   zXMLPullParserTest.test_eventscCstjdd}||d||dtjdffg||d||dtjdffg||d||d g||d ||dtjd ffg||d ||d g||d||dtjdffgtjdd}||d||dtjdffgdS)N)rr$rrrr$z text here z z more text here ztext)rroot-tagz z inner commentz )rr$z z outer comment )r$)r&rrrr&rr rrrtest_events_comment s          z%XMLPullParserTest.test_events_commentcCsdtjdd}||d||dtjdffgtjdd}||d||dtjdffgdS) N)rr4rrz r4pitarget)r4z zpitarget some text )r&rrrrr rrrtest_events_pis     z XMLPullParserTest.test_events_picCslddh}tj|d}||d||ddgGddd}tj|d}||d||ddgdS) Nrrrzbar)rr)rrc@s$eZdZddZddZddZdS)z9XMLPullParserTest.test_events_sequence..DummyItercSstgd|_dS)N)rrr )rrrqrrr__init__/szBXMLPullParserTest.test_events_sequence..DummyIter.__init__cSs|SrCrrqrrr__iter__1szBXMLPullParserTest.test_events_sequence..DummyIter.__iter__cSs t|jSrC)rrrqrrrr3szBXMLPullParserTest.test_events_sequence..DummyIter.__next__N)r)r*r+r(r)rrrrr DummyIter.sr*)r&rrr)r"Zeventsetrr*rrrtest_events_sequence's   z&XMLPullParserTest.test_events_sequencecCs:|ttjddWdn1s,0YdS)Nrr)rrr&rrqrrrtest_unknown_event:s z$XMLPullParserTest.test_unknown_event)N)N)N)N)r)r*r+rrrrrrr r rrr#r%r'r+r,rrrrrLs     .rz

120 Mz is adequate for an average home user.

C1.xmlz

The opinions represented herein represent those of the individual and should not be interpreted as official policy endorsed by this organization.

zdisclaimer.xmlz

This document has been accessed times.

C2.xmlZ324387z count.txtz

This document has been accessed times.

C2b.xmlz

The following is the source of the "data.xml" resource:

C3.xmlzQ zdata.xmlaW C5.xmlz

Example.

default.xmla 

The following is the source code of Recursive1.xml:

include_c1_repeated.xmlz

120 Mz is adequate for an average home user.

B1.xmlzn
B2.xmlz

The following is the source code of Recursive2.xml:

Recursive1.xmlz

The following is the source code of Recursive3.xml:

zRecursive2.xmlz

The following is the source code of Recursive1.xml:

zRecursive3.xmlc@sHeZdZdddZdddZddZd d Zd d Zd dZddZ dS) XIncludeTestrNcCs>z t|}Wnty&tdYn0|dkr:t|}|S)Nresource not foundr)XINCLUDEKeyErrorOSErrorr&r)r"hrefrr-rrrrxinclude_loaders   zXIncludeTest.xinclude_loadercCsdSrCr)r"r<rr-rrr none_loaderszXIncludeTest.none_loadercCsJ|dkrBt|d}t|WdS1s60YndSdS)Nrr)rr&rr)r"r<rrrrr _my_loaders .zXIncludeTest._my_loadercCs8ddlm}|d}|||j|t|ddS)Nrrr2z

Example.

text texttail
)r!rr=includer?r\r9)r"rrrrrtest_xinclude_defaults    z"XIncludeTest.test_xinclude_defaultcCsddlm}|d}|||j|t|d|d}|||j|t|d|d}|||j|t|d|d }|||j|t|d |d }|t}|||jWdn1s0Y|t|j d |t|d dS)Nrrr-a

120 Mz is adequate for an average home user.

The opinions represented herein represent those of the individual and should not be interpreted as official policy endorsed by this organization.

r.zO

This document has been accessed 324387 times.

r/zX

This document has been accessed 324387 times.

r0z

The following is the source of the "data.xml" resource:

<?xml version='1.0'?> <data> <item><![CDATA[Brooks & Shields]]></item> </data>
r1r8aI) r!rr=r@r\r9rr;rrr"rrrrrr test_xincludes8           , zXIncludeTest.test_xincludecCs>ddlm}|d}|||j|dt|ddS)Nrrr3rz.//p)r!rr=r@r\r]r)r"rrrrrtest_xinclude_repeated(s  z#XIncludeTest.test_xinclude_repeatedcCsddlm}ttd}||j }|j||jdWdn1sL0Y| t |j dttd}||j }|j||jdWdn1s0Y| t |j dtt d}||j }|j||jdWdn1s0Y| t |j d tt d }||j }|j||jdWdn1sd0Y| t |j d | d }||j}|||j Wdn1s0Y| t |j d | d }||j"}|j||j ddWdn1s0Y| t |j d | d }||j"}|j||j ddWdn1st0Y| t |j d| d }||j"}|j||j ddWdn1s0Y| t |j d| d }||j"}|j||j ddWdn1s,0Y| t |j d| d }||j"}|j||j ddWdn1s0Y| t |j d dS)Nrrr-)rRz%cannot load 'disclaimer.xml' as 'xml'r.z!cannot load 'count.txt' as 'text'r4z1unknown parse type in xi:include tag ('BAD_TYPE')r5zYxi:fallback tag must be child of xi:include ('{http://www.w3.org/2001/XInclude}fallback')r6z#recursive include of Recursive2.xml)Z max_depthzAmaximum xinclude depth reached when including file Recursive2.xmlrjzAmaximum xinclude depth reached when including file Recursive3.xmlrzAmaximum xinclude depth reached when including file Recursive1.xmlrD)r!rr&rr9rZFatalIncludeErrorr@r>r\rr XINCLUDE_BADr=ZLimitedRecursiveIncludeErrorrBrrrtest_xinclude_failures/sz . . 0 0  .  2  2  2  2  2 z#XIncludeTest.test_xinclude_failures)rN)N) r)r*r+r=r>r?rArCrDrFrrrrr7s  @r7c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ e edddZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5Z d6d7Z!d8d9Z"d:d;Z#d.check{r4Z123)r&r[rXrWr)r"rr4rrqrtest_bug_xmltoolkit21{s        zBugsTest.test_bug_xmltoolkit21cCs<tt}t|}||dd||dddS)Nr;rXrr#)r&rrrr\r)r"r4r8rrrtest_bug_xmltoolkit25s  zBugsTest.test_bug_xmltoolkit25cCs<td}|t|dg|t|ddgdS)N"
z.//theadz.//tbodyZtbody)r&rr\rArr"r8rrrtest_bug_xmltoolkit28s zBugsTest.test_bug_xmltoolkit28cCsPtd}t*}t|||dWdn1sB0YdS)NrLz$
)r&rrrrr\r2)r"r8rrrrtest_bug_xmltoolkitX1s   zBugsTest.test_bug_xmltoolkitX1cCstd}|t|ddtd}||jddi|t|ddtd}|t|dd td }|t|ddtd }|dd|t|dddS) Ns2r ssDuättruväluess:textstextrr;)r&rr\rrYr[rrMrrrtest_bug_xmltoolkit39s$      zBugsTest.test_bug_xmltoolkit39cCs2td}|t|ddd|t|ddS)Nz=]>&ldots;rrsurrrrrtest_bug_xmltoolkit54s  zBugsTest.test_bug_xmltoolkit54cCsL|tj}tdWdn1s,0Y|t|jddS)Ns?&ldots;&ndots;&rdots;z+undefined entity &ldots;: line 1, column 36)rr&rrr\rr)r"rrrrtest_bug_xmltoolkit55s ( zBugsTest.test_bug_xmltoolkit55cCs$Gddd}|ttj|dS)Nc@seZdZddZdS)z5BugsTest.test_bug_xmltoolkit60..ExceptionFilecSstdSrC)r;r"rdrrrrsz:BugsTest.test_bug_xmltoolkit60..ExceptionFile.readN)r)r*r+rrrrr ExceptionFilesrT)rr;r&r)r"rTrrrtest_bug_xmltoolkit60szBugsTest.test_bug_xmltoolkit60cCsHddd}t}|j||d|}||djddS)Nu’u‘)ZrsquoZlsquoaF A new cultivar of Begonia plant named ‘BCT9801BEG’. z .//paragraphu7A new cultivar of Begonia plant named ‘BCT9801BEG’.) r&rrupdaterrr\rrX)r"ZENTITIESrtrrrtest_bug_xmltoolkit62s   zBugsTest.test_bug_xmltoolkit62zSkips under coverage.cCsBdd}|td}tdD] }|q |td|dS)NcSs,t}|di|d|ddS)Nr;rX)r&rrrr)r8rrr xmltoolkit63s  z4BugsTest.test_bug_xmltoolkit63..xmltoolkit63i)rH getrefcountrr\)r"rYcountrrrrtest_bug_xmltoolkit63s   zBugsTest.test_bug_xmltoolkit63c Cs`tjddd}|t|d|tt|dd|ttt|ddS)NZSomeTagzdef _f(): return 3 rXs0rX)r&r[r\rrrNrrrrtest_bug_200708_newlines z BugsTest.test_bug_200708_newlinecCs`t}|d||jdGddd}tj|d}|d||jddS)Nzsome textr~c@seZdZddZdS)z2BugsTest.test_bug_200708_close..EchoTargetcSs tdS)Nr~r&r[rqrrrrsz8BugsTest.test_bug_200708_close..EchoTarget.closeNr)r*r+rrrrr EchoTargetsr`r)r&rrr\rr;)r"rr`rrrtest_bug_200708_close s  zBugsTest.test_bug_200708_closecCstd}t|d}|t|dddtd}t|d}t|d}|t|dddtd}t|d}t|d}|t}t|ddWdn1s0Y|t|jddS) Nz {default}elemr)raz%z{not-default}elemzIr4zrz(http://namespace.invalid/does/not/exist/sBz'{http://purl.org/dc/elements/1.1/}titles8)r&r[r\rregister_namespacerrrr"test_bug_200709_register_namespace2s       z+BugsTest.test_bug_200709_register_namespacecCs`td}|td||djtjtd}|td||djtjdS)Nrrr)r&r[rr&r\r;r)r"rrrrtest_bug_200709_element_commentAs   z(BugsTest.test_bug_200709_element_commentcCsptd}t|d}t|d}td}|d||t|gd|d||t|gddS) Nrrrrr)rrrr[)rrrr)r&r[r%rr\rAr"rrrrrrrtest_bug_200709_element_insertMs      z'BugsTest.test_bug_200709_element_insertcCsJtd}t|d}td}|||t|tjtjgdS)NrrzTEST-b)r&r[r%r&rr\rAr)r"rrZ comment_brrrtest_bug_200709_iter_commentWs     z%BugsTest.test_bug_200709_iter_commentcCsDt}|d}|di}|d}|}|t|ddS)Nrr;r)r&rrrrrr\r9)r"rcrrrrtest_bug_1534630as    zBugsTest.test_bug_1534630cCs@td}|t|ddtd}|t|dddS)Ns7tãgrs< tãgs;tgrcrrrrtest_issue6233is  zBugsTest.test_issue6233cCs8td}||jdt|}|t|ddS)Nz+z{${stuff}}localnames&)r&rr\r;rr)r"rrWrrrtest_issue3151us  zBugsTest.test_issue3151cCsRtd}|t|dgtt}|dd|dd<|t|gddS)Nrr;r;r;r)r&rr\rAr)r"r4Znewelemrrrtest_issue6565{s   zBugsTest.test_issue6565cCstddtdddS)NZ test10777z http://myuri/)r&rdrqrrrtest_issue10777s zBugsTest.test_issue10777cs`Gfddd}td|_}t|}||||jt|jddS)NcseZdZfddZdS)z%BugsTest.test_lost_text..Textcs d_dS)NchangedTrXrqrrr__bool__sz.BugsTest.test_lost_text..Text.__bool__Nr)r*r+rrrrqrrrsrr;rp)r&r[rXrrrZrr\r"rrrWrrqrtest_lost_texts  zBugsTest.test_lost_textcs|Gfddd}tdtd|d_}t|}||||djt|djddS)NcseZdZfddZdS)z%BugsTest.test_lost_tail..Textcsdd_dSNrprTrQrqrqrrrrs z.BugsTest.test_lost_tail..Text.__bool__Nrsrrqrrrsrrr;rrp) r&r[rrWrrrZrr\rtrrqrtest_lost_tails   zBugsTest.test_lost_tailcsGfddd}tdt|tddz t}Wntyr|dYn0||j||djt | djddS)NcseZdZfddZdS)z$BugsTest.test_lost_elem..Tagcstdd<tdSrv)r&r[r)r"rrrrr__eq__sz+BugsTest.test_lost_elem..Tag.__eq__Nr)r*r+ryrrxrrrsrrr;zgenerators are not reentrantrrp) r&r[rrrrskipTestrZr;rr\)r"rrWrrxrtest_lost_elems    zBugsTest.test_lost_elemcCs.d|}t|}||d|ddS)Ns rr )r&rr\rNdecode)r"rXrrrrrcheck_expat224_utf8_bugs z BugsTest.check_expat224_utf8_bugcCs d}||d}||dS)Nsààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààsxàààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààààà)r~r1rrrtest_expat224_utf8_bugs zBugsTest.test_expat224_utf8_bugcCsttd}|}Wdn1s(0Yt|}|d}|d}|dd}|dd}| |d|dS)Nrrr rrn) rUTF8_BUG_XMLFILErr&rrNr}stripreplacer\)r"fprawrZxmlattrrXrrrtest_expat224_utf8_bug_files &    z$BugsTest.test_expat224_utf8_bug_filecCs.|ttjd|ttjdddS)Nr;)rrHr&rrrqrrrtest_39495_treebuilder_startsz%BugsTest.test_39495_treebuilder_startN)$r)r*r+rJrKrNrOrPrQrRrUrXunittestZskipIfrHgettracer\r]rarcrerfrhrirjrkrlrnrorurwr|r~rrrrrrrrGys<           rGc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)BasicElementTestcCsd}ddi}t||}||tj|dt||dt||dt||dt|||j|||j||j | |j |||j |d|d <| |j || |j |dS) Nrzixwypr;rYrXrWbazr) r&r[rZr}r{r\r;rrXrWrrYrE)r"r;rY element_foorrr test___init__s    zBasicElementTest.test___init__cCsdttjvrtdtdddi}|tdddi|t|}Wdn1sf0Y| ||| |j |j | |j |j | |j |j | t|t|t||D]\}}|||q| |j|jdS) NrzElement.copy() not presentrrrrrqix)r{r&r[rSkipTestrZ assertWarnsDeprecationWarningrrr\r;rXrWr] itertools zip_longestassertIsrYr"rZ element_foo2rFrGrrrr s  & zBasicElementTest.test_copycCstdddi}|tdddit|}|||||j|j||j|j||j|j|t |t |t ||D]\}}| ||q||j |j dSNrrrrrr)r&r[rrrr\r;rXrWr]rrrrYrrrr test___copy__ s  zBasicElementTest.test___copy__cCstdddi}|tdddit|}|||||j|j||j|j||j |j |t |t |t ||D]\}}|||q||j |j ||j |j d|j d<||j |j ||j |j dSr)r&r[rrrrr\r;rXrWr]rrrYrErrrrtest___deepcopy__5 s   z"BasicElementTest.test___deepcopy__cCs<td}|t|jd|t|jtddg|t|jddtdg|dd<|td|d<Wdn1s0Y|t&tddg|dd<Wdn1s0Yt|drddgdd d d }|t|j|t|d r8Gd ddtj}|dg|dd<|tt j |dS)Njoerrrr __setstate__r;rrWrX)r; _childrenrYrWrX __deepcopy__c@seZdZddZdS)z9BasicElementTest.test_augmentation_type_errors..EcSsdSrCr)r"memorrrrj szFBasicElementTest.test_augmentation_type_errors..E.__deepcopy__N)r)r*r+rrrrrEi sr) r&r[rrHrrrr|rrr)r"rstaterrrrtest_augmentation_type_errorsS s*  & 4  z.BasicElementTest.test_augmentation_type_errorscCsGddd}|}tjd|d|_t|}~t||td}|}||_t|}tj|d|d}~~~t||td}td}td}||||||t|}~~~t||dS) Nc@s eZdZdS)z.BasicElementTest.test_cyclic_gc..DummyNr)r*r+rrrrDummyp srr)rrrrr) r&r[Zdummyrefweakrefrefr rr%r)r"rrwrefrrrrrrrtest_cyclic_gco s2            zBasicElementTest.test_cyclic_gccsVdfdd}td}t||}||jd~|d||ddS)NFcsddSNTr)wflagrrwref_cb sz.BasicElementTest.test_weakref..wref_cbrT)r&r[rrr\r;)r"rrrrrr test_weakref s    zBasicElementTest.test_weakrefcCsBtjddddd}||jdddd||jd ddddS) NrrjrrD)rdrezrd)rr)r&r[r\rN)r"rrrrtest_get_keyword_args sz&BasicElementTest.test_get_keyword_argsc CstdtjdD]}t|jddD]\}}|jddd}d|_d|_||d  |d | |d | d d  d d| |d|||}| |jd| |jdd| t|d|||q"qdS)Nrrjrepeatr*)rztext goes herezopposite of headchildZ grandchildz .//grandchildrrz other valuer$r)rrIHIGHEST_PROTOCOLrrEr[rXrWr%rrrrVr\r;rYr]r`)r"rSrQrRrrrrr test_pickle szBasicElementTest.test_picklec CstdtjdD]z}t|jddD]f\}}d}||}t|drV||dd| |d|||}||j d||d j d q"qdS) Nrrjrz\ 4 __getstate__r;groupr$rZdogs) rrIrrrErr|r\rrVr;)r"rSrQrRZXMLTEXTrrrrrtest_pickle_issue18997 s  z'BasicElementTest.test_pickle_issue18997N) r)r*r+rrrrrrrrrrrrrrrs# rc@s\eZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ dS)BadElementTestcs|Gfddd}|gtd}z|WntyDYn0Gddd|tj}|dgtd}|dS)NcseZdZefddZdS)z2BadElementTest.test_extend_mutable_list..Xcstdgdd<tjS)Nrr^rqLrr __class__ sz.X.__class__Nr)r*r+propertyrrrrrX srrc@s eZdZdS)z2BadElementTest.test_extend_mutable_list..YNrrrrrY srrdr&r[rrHr"rrrrrrtest_extend_mutable_list s    z'BadElementTest.test_extend_mutable_listcsGfddd}|tdgtd}z|WntyLYn0Gddd|tj}|dtdgtd}|dS)NcseZdZefddZdS)z3BadElementTest.test_extend_mutable_list2..Xcsdd=tjSrCr^rqrrrr s z=BadElementTest.test_extend_mutable_list2..X.__class__Nrrrrrr srrrc@s eZdZdS)z3BadElementTest.test_extend_mutable_list2..YNrrrrrr srrrrrrrtest_extend_mutable_list2 s   z(BadElementTest.test_extend_mutable_list2cszGfdddtj}td|dg|tjtdtdtdg|tj|ddS)NcseZdZfddZdS)z3BadElementTest.test_remove_with_mutating..Xcsdd=dS)NFrr"orqrrry s z:BadElementTest.test_remove_with_mutating..X.__eq__Nrzrrqrrr srrrr)r&r[rrrrr"rrrqrtest_remove_with_mutating s  z(BadElementTest.test_remove_with_mutatingc Csltd}t|d|B|tt|Wdn1s@0YWdn1s^0YdS)Nrr;)r&r[r r RuntimeErrorrrrrrtest_recursive_repr s  z"BadElementTest.test_recursive_reprcsnGfdddt}t}|di|d||d|d|d||jddS)NcseZdZfddZdS)z/BadElementTest.test_element_get_text..Xcs"z jWntyYn0dSrC)rX NameErrorrqr4rr__del__ s  z7BadElementTest.test_element_get_text..X.__del__Nr)r*r+rrrrrr srr;ABCDEFGHIJKL ABCDEFGHIJKL) rr&rrrrrr\rXr"rrrrrtest_element_get_text s    z$BadElementTest.test_element_get_textcsGfdddt}t}|di|di|d|d||d|d|d||djd dS) NcseZdZfddZdS)z/BadElementTest.test_element_get_tail..Xcs&zdjWnty Yn0dSr)rWrrqrrrr s z7BadElementTest.test_element_get_tail..X.__del__Nrrrrrr srrr;rrrrr) rr&rrrrrr\rWrrrrtest_element_get_tail s      z$BadElementTest.test_element_get_tailcs^Gfddd}tdtdd|tddd|dS)NcseZdZfddZdS)z%BadElementTest.test_subscr..Xcsdd=dSNrjrrqrqrr __index__+ s z/BadElementTest.test_subscr..X.__index__Nr)r*r+rrrqrrr* srr4rrr)r&r[rrrrqr test_subscr( s  zBadElementTest.test_subscrcsPGfddd}tdtdD]}dtdq$gdd|<dS)NcseZdZfddZdS)z)BadElementTest.test_ass_subscr..Xcsgdd<dSrrrqrqrrr9 s z3BadElementTest.test_ass_subscr..X.__index__Nrrrqrrr8 srr4rrr)r&r[rr)r"rrrrqrtest_ass_subscr6 s   zBadElementTest.test_ass_subscrcCsHdd}tj|d}|di|d|t|jdi~tdS)NcSsgSrCrrdrerrrelement_factoryE sz>BadElementTest.test_treebuilder_start..element_factoryrr;rr)r&rrrrAttributeErrorr r"rrrrrtest_treebuilder_startC s   z%BadElementTest.test_treebuilder_startcCsFdd}tj|d}|di|d|t|jd~tdS)NcSsgSrCrrrrrrQ sz.element_factoryrr;r)r&rrrrrrr rrrrtest_treebuilder_endO s   z#BadElementTest.test_treebuilder_endN) r)r*r+rrrrrrrrrrrrrrr s   rc@seZdZddZddZdS)MutatingElementPathcGstj|g|R}||_|SrC)r__new__r4)rFr4rr"rrrr] szMutatingElementPath.__new__cCs|jdd=dSrrrrrrrya s zMutatingElementPath.__eq__N)r)r*r+rryrrrrr\ src@seZdZddZdS)BadElementPathcCs dddS)Nrjrrrrrrryg szBadElementPath.__eq__Nrzrrrrrf srcsXeZdZfddZfddZddZddZd d Zd d Zd dZ ddZ Z S)BadElementPathTestcs(tddlm}|j|_i|_dSNrr)supersetUpr!r r path_cacher"r rrrrl s  zBadElementPathTest.setUpcs"ddlm}|j|_tdSr)r!r rrrtearDownrrrrrr s zBadElementPathTest.tearDowncCs0td}|tdg|t|ddSNrrrd)r&r[rrrrrrrtest_find_with_mutatingw s z*BadElementPathTest.test_find_with_mutatingcCsFtd}|tdgz|tdWnty@Yn0dSr)r&r[rrrZeroDivisionErrorrrrrtest_find_with_error| s   z'BadElementPathTest.test_find_with_errorcCs0td}|tdg|t|ddSr)r&r[rrrrrrrtest_findtext_with_mutating s z.BadElementPathTest.test_findtext_with_mutatingcCsFtd}|tdgz|tdWnty@Yn0dSr)r&r[rrrrrrrrtest_findtext_with_error s   z+BadElementPathTest.test_findtext_with_errorcCs0td}|tdg|t|ddSr)r&r[rrrrrrrtest_findall_with_mutating s z-BadElementPathTest.test_findall_with_mutatingcCsFtd}|tdgz|tdWnty@Yn0dSr)r&r[rrrrrrrrtest_findall_with_error s   z*BadElementPathTest.test_findall_with_error) r)r*r+rrrrrrrr __classcell__rrrrrk s  rc@s4eZdZddZddZddZddZd d Zd S) ElementTreeTypeTestcCsX|tjt|tjt|tjt|tjt|tjt|tjtdSrC) rZr&rrrrr[rrrqrrr test_istype s zElementTreeTypeTest.test_istypecCsZGdddtj}|d}||tj|||||jdd|_||jddS)Nc@s eZdZdS)zDElementTreeTypeTest.test_Element_subclass_trivial..MyElementNrrrrr MyElement srrr)r&r[rZr\r;rXr"rmyerrrtest_Element_subclass_trivial s z1ElementTreeTypeTest.test_Element_subclass_trivialcsVGfdddtjddddddd }||jd |t|gd dS) Ncs"eZdZiffdd ZZS)zHElementTreeTypeTest.test_Element_subclass_constructor..MyElementcs"t|j|d|fi|dS)N__)rr()r"r;rYextra)rrrrr( szQElementTreeTypeTest.test_Element_subclass_constructor..MyElement.__init__)r)r*r+r(rrrrrr srrrjr)rrrD)rrZfoo__))rrj)rr)rrD)rr)r&r[r\r;rrv)r"rrrr!test_Element_subclass_constructor s z5ElementTreeTypeTest.test_Element_subclass_constructorcCs.Gdddtj}|d}||ddS)Nc@seZdZddZdS)zGElementTreeTypeTest.test_Element_subclass_new_method..MyElementcSs|jSrCr:rqrrr newmethod szQElementTreeTypeTest.test_Element_subclass_new_method..MyElement.newmethodN)r)r*r+rrrrrr srr)r&r[r\rrrrr test_Element_subclass_new_method sz4ElementTreeTypeTest.test_Element_subclass_new_methodcCsGdddtj}td}d|_|d}d|_||||dd||djdt| d}|t |d|||djddS) Nc@s eZdZdS)zAElementTreeTypeTest.test_Element_subclass_find..MyElementNrrrrrr srrrXrr#rjr) r&r[rXrr\rrr;r^rr])r"rrsubfoundrrrtest_Element_subclass_find s  z.ElementTreeTypeTest.test_Element_subclass_findN)r)r*r+rrrrrrrrrr s   rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)ElementFindTestcCstt}||djd||djd||djdtt|d<||djd||dd||dd||dd ||dd d ||d ||d d d |td d d dS)Nr;r./tagrzsection/nexttagnexttagrXr#rmrtogzempty) r&rrr\rr;SAMPLE_SECTIONrrrrrrtest_find_simple s z ElementFindTest.test_find_simplecCsd}t|}||djdd||djdd||djdd||d jdd ||d jdd|td |jd |td |jd|td |jd|td |jddS)Nz z./tag[1]classrz./tag[2]rz ./tag[last()]rz./tag[last()-1]rz./tag[last()-2]ZXPathz./tag[0]z ./tag[-1]z./tag[last()-0]z./tag[last()+1])r&rr\rrYrg SyntaxError)r"Z LINEAR_XMLrrrrtest_find_xpath s zElementFindTest.test_find_xpathcCs tt}tt|d<|t|ddg|t|dddg|t|dg|t|dg|t|dgd|t|d dgd |t|d dg|t|d dgd|t|d gd|t|dgd|t|dgd|t|dgd|t|dgd|t|ddg|t|ddg|t|ddgd|t|ddgd|t|ddgd|t|ddg|t|ddgd|t|ddg|t|ddg|t|dg|t|d g|t|d!dgd||d"|d|t|d#dg|t|d$dg|t|d%dg|t|d&dg|t|d'dg|t|d(dg|t|d)dg|t|d*dg|t|d+dg|t|d,dg|t|d-g|t|d.g|d|d/<|t|d&ddg|t|d,ddgdS)0Nrrrr;r ztog/foorrmz.//tagrrz section//tagz section/*)r;r  nextsectionz section//*)r;r rr;z section/.//*z*/*z*//*z*/tagz*/./tagr z././tagz.//tag[@class]rDz.//tag[@class="a"]z.//tag[@class="b"]z .//tag[@id]z.//section[tag]rz.//section[element]z../tagzsection/../tagz section//z.//section[tag='subtext']z.//section[tag ='subtext']z.//section[tag= 'subtext']z.//section[tag = 'subtext']z.//section[ tag = 'subtext' ]z.//tag[.='subtext']z.//tag[. ='subtext']z.//tag[.= "subtext"]z.//tag[ . = "subtext" ]z.//tag[. = 'subtext']z.//tag[. = 'subtext ']z.//tag[.= ' subtext']rj)r&rrr r\rArrrrr test_findall s  zElementFindTest.test_findallcCs\tt}|t|dg|t|ddgd|t|ddgddS)Nr;z{http://effbot.org/ns}tagrz.//{http://effbot.org/ns}tagrD)r&rrr\rArrrrrtest_test_find_with_nsR s   z&ElementFindTest.test_test_find_with_nscCstd}ddi}|t|jd|dd|t|jd|ddddi}|t|jd|dd |t|jd|ddddd }|t|jd|dd|t|jd|dd dS) N xxrz.//xx:b)rr.//brrj)rrm)r&rr\r]r)r"rnsmaprrrtest_findall_different_nsmaps\ s  z-ElementFindTest.test_findall_different_nsmapscCstd}|td|t|dgd|t|ddg|t|ddg|t|d d g|t|d d dg|t|d d g|t|d t|d |t|dgd|t|d|dgt|d|t|dgd|t|dddg|t|dddg|t|dd g|t|dgd|t|dd d g|t|dt|ddS)Nrrz{*}b){X}br{Y}bz{*}crz{X}*rz{Y}*rrrz{}br)rrrrr[rz.//{*}b)rrrrrz.//{*}cz.//{X}*z.//{Y}*z.//{}*)rrrrz.//{}br)r&rrr&r\rArrrrrtest_findall_wildcardm sd    z%ElementFindTest.test_findall_wildcardcCsDtt}|td|dWdn1s60YdS)Nzcannot use absolute pathz/tag)r&rrrgrrrrrr test_bad_find s zElementFindTest.test_bad_findcCstt}|t|djd|t|dd|tt| ddgdd}| t | t| d}Wdn1s0Y|t|dgddS)Nr;rXrzThis 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//tagrD) r&rrr\rrr;rrArassertWarnsRegex FutureWarning)r"rrlrrrrtest_find_through_ElementTree s .z-ElementFindTest.test_find_through_ElementTreeN) r)r*r+rrrrrrrr rrrrr sM ,rc@s>eZdZdddZddZddZdd Zd d Zd d ZdS)ElementIterTestNcCst||SrC)rAr)r"r4r;rrr_ilist szElementIterTest._ilistcCs4td}|||gd|||dddg|t|jd|d| d|d|d d|t| d t |d d }|tt |d d t |d d }tj t d}|ttj ||dd d td}|t|jtd}|d| ddS)Nz7this is a paragraph...)rrrrrrrmzthis is a paragraph...zthis is a paragraph.z this is a F)r5rrr)rz*a&b&c&za&b&c&)r&rr\r"rrrr;rrr9rrrrrr)r"rZ sourcefilerr8rrr test_basic s(     zElementIterTest.test_basiccCstd}|||dgt|d}|||ddgt|d}|||gdt|d}|||gd|d|d<|d=|||ddgdS) Nrrr)rrrr)rrrrrjr)r&r[r\r"r%rgrrr test_corners s     zElementIterTest.test_cornerscCstd}|||ddgd|||ddgd|t|jdddgdgd}|t|||||||||d|dS) NaJ bedroom1 bedroom2 nothing here bedroom8 roomrDhouserr:)rr&r%r%Zshedr&r%r)r&rr\r"rAr)r"rZall_tagsrrrtest_iter_by_tag s z ElementIterTest.test_iter_by_tagcCsJtd}|}|tt|Wdn1s<0YdS)Nr)r&r[rrrHr)r"rrrrrr s  zElementIterTest.test_copyc Csftd}|}ttjdD]@}|ttjft ||Wdq 1sV0Yq dS)Nrrj) r&r[rrrIrrrHrLrJ)r"rrrSrrrr s  zElementIterTest.test_pickle)N) r)r*r+r"r#r$r'rrrrrrr! s  r!c@seZdZdZdZddZddZddZd d Zd d Z d dZ ddZ ddZ ddZ ddZddZddZddZddZdd Zd!S)"TreeBuilderTestztext
subtext
tailzsometextcCs||jd||jd||jd||jit|}|t|d|d}||jd||jd||jd||jidS)NrrXrjrZdivr#rW)r\r;rXrWrYr^r])r"rchildrenrrrr_check_sample1_element sz&TreeBuilderTest._check_sample1_elementcCsGddd}Gddd|}tj|d}||j||dtj|d}||j||dtjtd}||j||dS)Nc@seZdZddZdS)z.BaseDummyBuildercSsdS)Nrrrqrrrr$ szBTreeBuilderTest.test_dummy_builder..BaseDummyBuilder.closeNr_rrrrBaseDummyBuilder# sr+c@seZdZddZZZdS)z8TreeBuilderTest.test_dummy_builder..DummyBuildercWsdSrCr)rrrr( r?zATreeBuilderTest.test_dummy_builder..DummyBuilder.N)r)r*r+rrrrrrr DummyBuilder' sr-rr)r&rrsample1r\robjectr)r"r+r-rrrrtest_dummy_builder" s   z"TreeBuilderTest.test_dummy_buildercCst}||djtj||djdtjtjd}||djtj||djdtjtd}||dtddS)NZctext)comment_factory)r&rr\r$r;r&rXr]r"rrrrtest_treebuilder_comment6 s z(TreeBuilderTest.test_treebuilder_commentcCst}||ddjtj||ddjdtjtjd}||djtj||djd||ddjtj||ddjdtjddd}||dtddf||ddtddfdS)Nr) pi_factoryr&z text zpitarget text cSs t||fSrC)r])rrXrrrr,M r?z5TreeBuilderTest.test_treebuilder_pi..)r&rr\r4r;rrXr]r2rrrtest_treebuilder_piB sz#TreeBuilderTest.test_treebuilder_picCsGdddtj}d}t|}||jdtj|d}|||}||jdd}t|}||jdd}tj|d}|||}||jddS)Nc@s eZdZdS)z;TreeBuilderTest.test_late_tail..TreeBuilderSubclassNrrrrrTreeBuilderSubclassS sr6ztexttailZtexttailrztexttail)r&rrr\rXrrr)r"r6rrrrrrtest_late_tailQ s     zTreeBuilderTest.test_late_tailcCszGdddtj}d}tjtjddd}|||}||djd||djd ||jd tj|ddd}|||}||djd||djd ||jd d }tjtjdd d}|||}||djd ||djd||jdtj|dd d}|||}||djd ||djd||jddS)Nc@s eZdZdS)zKTreeBuilderTest.test_late_tail_mix_pi_comments..TreeBuilderSubclassNrrrrrr6l sr6z/text tailT)Zinsert_commentsrrr;z tailztext z+text tail)Z insert_piszpi datarWztext )r&rrrrr\rXrW)r"r6rrrrrrtest_late_tail_mix_pi_commentsi s6    z.TreeBuilderTest.test_late_tail_mix_pi_commentscCs6tjtjddd}||j|}||dSNrr)r&rrrr.rr*r"rrrrr$test_treebuilder_elementfactory_none s z4TreeBuilderTest.test_treebuilder_elementfactory_nonecCsXGdddtj}|}||ddtj|d}||j|}||dS)Nc@seZdZddZdS)z4TreeBuilderTest.test_subclass..MyTreeBuildercSs|dSNrrrSrrrre sz;TreeBuilderTest.test_subclass..MyTreeBuilder.foobarNr)r*r+rerrrr MyTreeBuilder sr>rrr) r&rr\rerrr.rr*r"r>tbrrrrr test_subclass s  zTreeBuilderTest.test_subclasscCslGdddtj}|tjtjd}||ddtj|d}||j|d| }| |dS)Nc@seZdZddZdS)z?TreeBuilderTest.test_subclass_comment_pi..MyTreeBuildercSs|dSr<rrSrrrre szFTreeBuilderTest.test_subclass_comment_pi..MyTreeBuilder.foobarNr=rrrrr> sr>)r1r4rrrz) r&rr&rr\rerrr.rr*r?rrrtest_subclass_comment_pi s   z(TreeBuilderTest.test_subclass_comment_picsNgfdd}tj|d}tj|d}||j||dgdS)Ncs|t||SrC)rr&r[)r;rYZlstrr myfactory s z7TreeBuilderTest.test_element_factory..myfactoryrrZtoplevel)r&rrrsample2rr\)r"rDr@rrrCrtest_element_factory s    z$TreeBuilderTest.test_element_factorycCsFtj|d}tj|d}||j|}|||||dSr9)r&rrrr.rrZr*)r"rFr@rrrrr_check_element_factory_class s     z,TreeBuilderTest._check_element_factory_classcCs Gdddtj}||dS)Nc@s eZdZdS)z@TreeBuilderTest.test_element_factory_subclass..MyElementNrrrrrr sr)r&r[rG)r"rrrrtest_element_factory_subclass sz-TreeBuilderTest.test_element_factory_subclasscCs4tj}||jdGddd|t}||dS)Nr$c@s eZdZdS)zLTreeBuilderTest.test_element_factory_pure_python_subclass..MyElementNrrrrrr sr)r&Z _Element_Pyr\r*rrG)r"baserrrr)test_element_factory_pure_python_subclass sz9TreeBuilderTest.test_element_factory_pure_python_subclasscCs<Gddd}tj|d}||j||ddS)Nc@s eZdZdZddZddZdS)z3TreeBuilderTest.test_doctype..DoctypeParserNcSs|||f|_dSrC_doctyper"rPZpubidsystemrrrdoctype sz;TreeBuilderTest.test_doctype..DoctypeParser.doctypecSs|jSrCrKrqrrrr sz9TreeBuilderTest.test_doctype..DoctypeParser.close)r)r*r+rLrOrrrrr DoctypeParser srPrrz&-//W3C//DTD XHTML 1.0 Transitional//ENz7http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd)r&rrr.r\r)r"rPrrrr test_doctype s    zTreeBuilderTest.test_doctypec CsGddd}tj|ddD]@}|t| tj||dWdq 1sV0Yq tj|tdddD]2}tj||tdd}||j||qxdS)Nc@s"eZdZdefddZddZdS)zBTreeBuilderTest.test_builder_lookup_errors..RaisingBuilderNcSs||_||_dSrCraise_inwhat)r"rTrUrrrr( szKTreeBuilderTest.test_builder_lookup_errors..RaisingBuilder.__init__cSs"||jkr||jdd}|S)NcWsdSrCr)rrrrhandle sz^TreeBuilderTest.test_builder_lookup_errors..RaisingBuilder.__getattr__..handlerS)r"rPrVrrr __getattr__ s  zNTreeBuilderTest.test_builder_lookup_errors..RaisingBuilder.__getattr__)r)r*r+rr(rWrrrrRaisingBuilder srXr)rrrr$r4)rU) r&rrgrrrr.rr)r"rXrrrrrtest_builder_lookup_errors s 0 z*TreeBuilderTest.test_builder_lookup_errorsN)r)r*r+r.rEr*r0r3r5r7r8r;rArBrFrGrHrJrRrYrrrrr( s"  $  r(c@sPeZdZdZdZdZddZddZdd Zd d Z d d Z ddZ ddZ dS) XMLParserTests22stextuX $£€𐅻cCs6||jd||djd||djddS)Nr7rlineZ22)r\r;rXrrrr_check_sample_element sz#XMLParserTest._check_sample_elementcCs0tjdtd}||j||dS)Nr )r-r)r&rrrr.r\r)r"Zparser2rrrtest_constructor_args s  z#XMLParserTest.test_constructor_argscCs6Gdddtj}|}||j||dS)Nc@s eZdZdS)z-XMLParserTest.test_subclass..MyParserNrrrrrMyParser sr^)r&rrr.r\r)r"r^rrrrrA s zXMLParserTest.test_subclasscCsTt8tdtt}||j|Wdn1sF0YdS)Nerror) warningscatch_warnings simplefilterrr&rrrErr rrrtest_doctype_warning s    z"XMLParserTest.test_doctype_warningcsdGfdddtj}|}|td||jWdn1sN0Y||dt pt dt t dtGfddd}||d}||j||| dWdn1s0YdS) NcseZdZfddZdS)z@XMLParserTest.test_subclass_doctype..MyParserWithDoctypecs ||fdSrCr)r"rrrKrrrO) szHXMLParserTest.test_subclass_doctype..MyParserWithDoctype.doctypeNr)r*r+rOrrKrrMyParserWithDoctype( srerOr_cseZdZfddZdS)z:XMLParserTest.test_subclass_doctype..DoctypeParsercs|||fdSrCrrM _doctype2rrrO8 szBXMLParserTest.test_subclass_doctype..DoctypeParser.doctypeNrdrrfrrrP7 srPrrQ) r&rrRuntimeWarningrrErrr`rarbrr\)r"rerrPr)rLrgrtest_subclass_doctype& s&*       z#XMLParserTest.test_subclass_doctypecCsptTtdttdtGdddtj}|}||j| Wdn1sb0YdS)z:Ensure that ordinary usage is not deprecated (Issue 19176)r_c@s eZdZdS)zDXMLParserTest.test_inherited_doctype..MyParserWithoutDoctypeNrrrrrMyParserWithoutDoctypeI srjN) r`rarbrrhr&rrrEr)r"rjrrrrtest_inherited_doctypeD s    z$XMLParserTest.test_inherited_doctypecCsVtjtd}||j|}||jd||jdd||j ddS)NrZmoneyrsu $£€𐅻) r&rrrsample3rr\r;rYrXr:rrrtest_parse_stringO s  zXMLParserTest.test_parse_stringN) r)r*r+r.rErlr\r]rArcrirkrmrrrrrZ s rZc@seZdZddZdS)NamespaceParseTestcCs`ddd}tt}|t|d|d|t|d|d|t|d|ddS) NZhellor)hrz {hello}tablerjz .//{hello}tdrz .//{foo}name)r&rSAMPLE_XML_NS_ELEMSr\r]r)r"rrrrrtest_find_with_namespaceY s   z+NamespaceParseTest.test_find_with_namespaceN)r)r*r+rqrrrrrnX srnc@sleZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZdS)ElementSlicingTestcCsdd|DS)NcSsg|] }|jqSrr:)r=rrrrr>d r?z1ElementSlicingTest._elem_tags..r)r"Zelemlistrrr _elem_tagsc szElementSlicingTest._elem_tagscCs|t|SrC)rsr^r'rrr _subelem_tagsf sz ElementSlicingTest._subelem_tagscCs,td}t|D]}t|d|q|S)zxCreate an Element with a tag 'a', with the given amount of children named 'a0', 'a1' ... and so on. rza%s)r&r[rr%)r"Z numchildrenrrrrr_make_elem_with_childreni s  z+ElementSlicingTest._make_elem_with_childrencsZ|d|djd|djd|tfdd|tfdddS) Nrrja1a8csdS)N rrrqrrr,y r?z?ElementSlicingTest.test_getslice_single_index..csdS)Nirrrqrrr,z r?)rur\r;r IndexErrorrqrrqrtest_getslice_single_indexs s  z-ElementSlicingTest.test_getslice_single_indexcCs|d}|||ddgd|||ddgd|||ddgd|||ddddg|||ddddg|||dd d d gdS) NrrD)a3a4a5rr|r}r[ra0rv)rur\rsrrrrtest_getslice_range| s z&ElementSlicingTest.test_getslice_rangec Cs|d}|||dddddg|||dddgd|||dddddg|||dddd dg|||ddtjd g|||ddtjd >d gdS) Nrrjrxa9rD)rr|Za6rrrvr|@rur\rsrHmaxsizerrrrtest_getslice_steps s      z&ElementSlicingTest.test_getslice_stepsc Cs|d}|||dddgd|||dddddg|||ddtj dg|||ddtj ddg|||ddtj d >dgdS) Nrr[)r|a2rvrrwr|rvrDrjrrrrrrtest_getslice_negative_steps s    "&z/ElementSlicingTest.test_getslice_negative_stepscCs|d}|dd=|||ddg|d}|dd=|||g|d}|ddd=|||g|d}|ddd=|||ddg|d}|d dd=|||ddg|d}|ddd=|||d gdS) Nrrrrr|r[rwrrjrv)rur\rtrrrr test_delslice s$            z ElementSlicingTest.test_delslicecCs|d}td|d<|||gdtd|d<|||gd|ttd|d <Wdn1s0Y|ttd|d <Wdn1s0Y|||gddS) Nrrrjrrrr|rrw)rrrr|rr)rur&r[r\rtrrzrrrrtest_setslice_single_index s  , ,z-ElementSlicingTest.test_setslice_single_indexcCs|d}ddtdD|dd<|||gd|d}tdg|dd<|||gd |d}d dtdD|dd<|||gd dS) NrcSsg|]}td|qSzb%sr^r=rrrrr> r?z:ElementSlicingTest.test_setslice_range..rrjrD)rb0b1r|r)rrr|cSsg|]}td|qSrr^rrrrr> r?)rrrb2r|)rurr\rtr&r[rrrrtest_setslice_range s   z&ElementSlicingTest.test_setslice_rangecCs|d}ddtdD|ddd<|||gd|d}|t&tdg|ddd<Wdn1s|0Y|t,d dtd D|ddd<Wdn1s0Y|tg|ddd<Wdn1s0Y|||gd |d }tdg|ddtj <|||gd tdg|ddtj d><|||gddS)NrcSsg|]}td|qSrr^rrrrr> r?z:ElementSlicingTest.test_setslice_steps..rrjr)rrrrr}r~rcSsg|]}td|qSrr^rrrrr> r?rD)rrvrr|r}r~rrrrrrrr| rurr\rtrrr&r[rHrrrrrtest_setslice_steps s    4 : , z&ElementSlicingTest.test_setslice_stepscCs|d}ddtdD|ddd<|||gd|d}|t&tdg|ddd<Wdn1s|0Y|t,d dtd D|ddd<Wdn1s0Y|tg|ddd<Wdn1s0Y|||gd |d}tdg|d dtj <|||gd tdg|d dtj d <|||gdtdg|d dtj d><|||gddS)NrcSsg|]}td|qSrr^rrrrr> r?zCElementSlicingTest.test_setslice_negative_steps..rrr[)rrrr|rcSsg|]}td|qSrr^rrrrr> r?rD)rrvrr|rjrrrrr)rrrr|rrrrrtest_setslice_negative_steps s$   4 : , z/ElementSlicingTest.test_setslice_negative_stepsN)r)r*r+rsrtrur{rrrrrrrrrrrrrrb s      rrc@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ GdddZ ddZ ddZddZddZddZdd Zd!d"Zd#S)$IOTestc Cstd}d|_|t|ddD]Z}||<|t||dd|t||ddWdq$1st0Yq$dD]r}||T|t||dd|||}|t||dd||Wdq1s0Yqtd}d |_|t|d |t|d dd |t|d dd dD]$}|t||dd||qDtd}d |jd<|t|d|t|d dd|t|d dddD]$}|t||dd||qtd}d|_|t|d|t|d dd|t|d dddD]$}|t||dd||q,td}d|jd<|t|d|t|d dd|t|d dddD]$}|t||dd||qdS)Nr;rzabc)r rrsabc)rrutf-32z2 abcz<&"'>z<&"'>r s<&"'>rz> <&"'>rtz"s"zF uåöö<>uåöö<>såöö<>s%åöö<>u= åöö<>uss()rrrrru@ ) r&r[rXr\r9r{upperrrY)r"r4encrrrrr s  $ $      zIOTest.test_encodingcCsf|tjtttd}|tttd }| | dWdn1sX0YdS)Nr) rrrrr&rrr1rr\rr"r8rrrrtest_write_to_filename>s   zIOTest.test_write_to_filenamecCs|tjtttd}ttddd*}|j|dd| |j Wdn1s\0Yttd }| | dWdn1s0YdS)Nrrr rr,rr rrrrr&rrrr1rrr\rrrrrtest_write_to_text_fileEs* zIOTest.test_write_to_text_filecCs|tjtttd}ttd&}||| |j Wdn1sT0Yttd }| | dWdn1s0YdS)Nrrrrrrrrrtest_write_to_binary_fileNs  * z IOTest.test_write_to_binary_filecCs0|tjtttd}ttd*}|j|dd| |j Wdn1sX0Yttd&}| | d dWdn1s0Yttddd*}|j|dd| |j Wdn1s0Yttd&}| | d dWdn1s"0YdS) Nrrrrr0 r) buffering)rrrrr&rrrr1rrr\rrrrrr"test_write_to_binary_file_with_bomWs( *  "*  z)IOTest.test_write_to_binary_file_with_bomcCs2t}td}||||jddSNz"site)r&rr.r0rr\rr;r"r8rrrrtest_read_from_stringioks  zIOTest.test_read_from_stringiocCs:ttd}t}|j|dd||ddSNrr,r)r&rrr.r0r1r\r2rrrrtest_write_to_stringioqszIOTest.test_write_to_stringiocCs2t}td}||||jddSNs"r)r&rr.r/rr\rr;r"r8rrrrtest_read_from_bytesiows  zIOTest.test_read_from_bytesiocCs6ttd}t}||||ddSNrr)r&rrr.r/r1r\r2rrrrtest_write_to_bytesio}s zIOTest.test_write_to_bytesioc@s eZdZdS)z IOTest.dummyNrrrrrdummysrcCsBtd}|}|j|_t}||||j ddSr) r.r0rrr&rrr\rr;)r"rreaderr8rrrtest_read_from_user_text_readers   z&IOTest.test_read_from_user_text_readercCsJttd}t}|}|j|_|j|dd||ddSr) r&rrr.r0rr1r\r2)r"r8rwriterrrrtest_write_to_user_text_writers z%IOTest.test_write_to_user_text_writercCsJtd}|}|j|_t}||||j dt}dSr) r.r/rrr&rrr\rr;)r"rrr8rrr!test_read_from_user_binary_readers  z(IOTest.test_read_from_user_binary_readercCsFttd}t}|}|j|_||||ddSr) r&rrr.r/rr1r\r2r"r8rrrrr test_write_to_user_binary_writers  z'IOTest.test_write_to_user_binary_writercCsbttd}t}|}|j|_dd|_|j|_|j|dd| | d ddS)NrcSsdSrrrrrrr,r?zBIOTest.test_write_to_user_binary_writer_with_bom..rrr) r&rrr.r/rr1seekabletellr\r2rrrrr)test_write_to_user_binary_writer_with_boms  z0IOTest.test_write_to_user_binary_writer_with_bomc CsRtd}|t|ddt|d|t|ddt|ddS)Nzfoor,rmrr?)r&rr\rrrrrrrtest_tostringlist_invariants   z"IOTest.test_tostringlist_invariantcCsRtd}|t|dd|tj|dddd|tj|dddddS)Nzabcr,zabcT)Zshort_empty_elementsFzabc)r&rr\rrrrrtest_short_empty_elementss  z IOTest.test_short_empty_elementsN)r)r*r+rrrrrrrrrrrrrrrrrrrrrr s"E     rc@s,eZdZddZddZddZddZd S) ParseErrorTestcCs|ttdSrC)rZr&rrrqrrrrAszParseErrorTest.test_subclassc Cs>zt|Wn*tjy8}z|WYd}~Sd}~00dSrC)r&rr)r"rbrrrr _get_errorszParseErrorTest._get_errorcCs@||djd||djd||djddS)Nr)rjrz&foo;)rjrzfoobar<)rjr)r\rZpositionrqrrrtest_error_positionsz"ParseErrorTest.test_error_positioncCs8ddlmmm}||dj|j|jdS)Nrr) Zxml.parsers.expat.errorsparsersZexpaterrorsr\rcodeZcodesZXML_ERROR_SYNTAX)r"ZERRORSrrrtest_error_codes zParseErrorTest.test_error_codeN)r)r*r+rArrrrrrrrsrc@seZdZddZdS)KeywordArgsTestc Cstd}||dd|jddd||ddd|jdddd||dd|jddd|t|ddt|jddd|tdj itdt dddtjdt ddddtjdt dd dd tjddddtjdt ddddddg}|D]*}||j d||j t dddq tj |d d d did}||j d d| tdtddWdn1s0Y| tdtjdddWdn1s0YdS)Nz foor)pathr)rrr#r)r<rY)rY)r<)rYrreZkey1Zvalue1zmust be dict, not strzI'm not a dict)r&rr\rrrr^rr[rYrMr;r%rgrH)r"rdelementsrrrrrtest_issue14818s:   ,zKeywordArgsTest.test_issue14818N)r)r*r+rrrrrrsrc@seZdZddZddZdS)NoAcceleratorTestcCststddS)Nzonly for the Python version)rDrrrqrrrrszNoAcceleratorTest.setUpcCs(|tjjtj|tjjtjdSrC)rZrDr[r(types FunctionTyperrqrrrtest_correct_import_pyETsz*NoAcceleratorTest.test_correct_import_pyETN)r)r*r+rrrrrrrsrcKstj|fi|SrC)rD canonicalize)rr6rrrc14n_roundtripsrc@s(eZdZdZddZddZddZdS)C14NTestNcCs|tdd|tdd|tdd|tdd|td d |td d |td d|tdd|tdd|tdd|tdd|tddd}|t||d}|t||d}|t||dS)Nzz zzz z,z+z7zz z*Hello, world!zHello, world!z2z2zG"0" && value<"10" ?"valid":"error"]]>zIvalue>"0" && value<"10" ?"valid":"error"zSvalidz{validz7z/z6z=z7z1z5zJzN)r\rrrrrtest_simple_roundtripsP           zC14NTest.test_simple_roundtripcCstd}|t|ddd|t|ddgdd|t|ddgd d |t|ddgdgd d |t|dd dgd d|t|d dgdd|t|dddgd d|t|ddgdddS)Nz abtext btext dtext T) strip_textzabtextbtextdtextz{http://example.com/x}attr)r exclude_attrszcabtextbtextdtextz{http://example.com/x}d)r exclude_tagszbabtextbtext)rrrz4abtextbtextrrzCdtext)rza dtext zIzu )r@rAr\rrrrrtest_c14n_exclusionDsF    zC14NTest.test_c14n_exclusionc stddd}ttjj|ddtt|DddD}fddDfd d|D}|d td d| Dd/d d }| D]f\}}|D]V\}}||ddk} ||ddk} ||ddk} d|vrdd|dd dD} dd|dd dD} nd} } dddt| D}| |d|d|dkrz| sz| d||d kr| s| d|d|vr|ddd!dur| d"||d#}|d$krXtd%d&V}t|d&*}t|d'|}Wdn1s.0YWdn1sN0Ytj|| | | | | d(}t|d#d)d*d+:}|}|d,kr|d-d.}|d-d.}Wdn1s0Y|||Wdq1s0YqqdS)0Nzc14n-20r r cSs"g|]}|dr|ddqS).xmlNr)endswithr=filenamerrrr>s z+C14NTest.test_xml_c14n2..cSsg|]}|dr|qS)in) startswithrrrrr>s cs8i|]0}|dr|ddt|dDqS)Zc14ncSs,i|]$}|jdd|jpd|fqS)}r[rm)r;splitrXr)r=optionrrr sz6C14NTest.test_xml_c14n2...r)rr&rrr) full_pathrrrs  z+C14NTest.test_xml_c14n2..cs"i|]fddDqS)csJg|]B}|ddr|dddvr||dddfqS)Zout_rrjr[)rrsplitr)configs input_filerrr>sz6C14NTest.test_xml_c14n2...r)r=)rfiles)rrrscSsg|]}|D]}|q qSrr)r= output_files output_filerrrr>scSs|||dfdS)NrrrN)configZ option_namerrrr get_optionsz+C14NTest.test_xml_c14n2..get_optionZIgnoreCommentstrueZ TrimTextNodesZ PrefixRewriteZ sequentialZ QNameAwarecSs(g|] }d|dd|dqS{ZNSrNamerrRrrrr>srjz/{http://www.w3.org/2010/xml-c14n2}QualifiedAttrcSs(g|] }d|dd|dqSrrrRrrrr>sz){http://www.w3.org/2010/xml-c14n2}Element,css8|]0\}\}}|d|p*ddd|DVqdS)=rcss|]}|jddVqdS)rr[N)r;r)r=rrrr r?z4C14NTest.test_xml_c14n2...N)r)r=rPrsr)rrrrs z*C14NTest.test_xml_c14n2..()Z inNsRedeclz2Redeclared namespace handling is not supported in ZinNsSuperfluousz.{http://www.w3.org/2010/xml-c14n2}XPathElementz2QName rewriting in XPath text is not supported in rZinC14N5z world.txtrs&ent2;)Z from_fileZ with_commentsrrewrite_prefixesZqname_aware_tagsZqname_aware_attrsrrjrZinC14N3z attr="default"rm)N)rrosrrrlistdirr\r]valuesrvrr{r{rrr.r/rrr&r)r"ZdatadirZ input_filesZtestsrrrrrZ keep_commentsrrZqattrsZqtagsZ config_descrrZ entity_filerXrhr)rrrrtest_xml_c14n2s              Z  ,zC14NTest.test_xml_c14n2)r)r*r+ZmaxDiffrrrrrrrrs(PrcCs:tddgda|durt}|attttttt t t t t tttttttg}tturZ|tgddlm}tjj}|}|j}||_ttdrttjtj }nd}zLt!j"|Wddlm}|#|$|||_|durtj|daanBddlm}|#|$|||_|dur,tj|daa0dS)Nr$r%)Zblockedrr_set_factories)%rrDr&rrrrrrrgrrr7rrr!r(rZrrGrrrrr!r rdZ_namespace_maprrr|rr&rrZ run_unittestrrV)moduleZ test_classesr rZ nsmap_copyrZ old_factoriesrrr test_mainsj           r__main__)Tr,)N)Lrrrr.rrprarrIrHr@rrr`rrrrrrZ test.supportrrrr r rDr&rrUnicodeEncodeErrorrrrrr rrprrrZTestCaserr9rArBrgrr9formatescaperEr7rGrrrr__hash__rrrrr!r(rZrnrrrrrrrrrr)rrrrs           # w    7lc48W`xT R$f E