python (3.12.0)

(root)/
lib/
python3.12/
test/
__pycache__/
test_sax.cpython-312.opt-2.pyc

ΑeddlmZmZmZmZmZddlZddlmZ	eddl	m
Z
mZmZm
Z
mZmZddlmZddlmZmZmZddlmZmZmZdd	lmZmZddlZddlZddl Z ddl!Z!dd
l"m#Z#ddl$Z%ddl&m'Z'ddl&m(Z(dd
l)m*Z*m+Z+e(ddZ,e(ddZ-	e,j]de-j]ddZ0ejbjds+	e'jfj]e!jhejne0dZ8dZ9GddejtZ;d@dZ<dAdZ=dAdZ>GddejtZ?Gdd ejtZ@Gd!d"ejtZAGd#d$ejtZBGd%d&ZCGd'd(eCejtZDGd)d*eCejtZEGd+d,eEZFGd-d.eCejtZGGd/d0eCejtZHd1ZIGd2d3ejtZJeKe-d45ZLeLjZNdddGd5d6e;ZOGd7d8ejtZPGd9d:e;ZQGd;d<ejtZRGd=d>ejtZSeTd?k(rejyy#e$rejdwxYw#e/$rejdwxYw#e5e6f$rdZ0YwxYw#1swYxYw)B)make_parserContentHandlerSAXExceptionSAXReaderNotAvailableSAXParseExceptionN)mockzno XML parsers available)XMLGeneratorescapeunescape	quoteattr
XMLFilterBaseprepare_input_source)
create_parser)feature_namespacesfeature_external_gesLexicalHandler)InputSourceAttributesImplAttributesNSImpl)BytesIOStringIO)URLError)	os_helper)findfile)FakePathTESTFNztest.xmlxmltestdata)subdirztest.xml.oututf-8z!filename is not encodable to utf8TFz$Requires non-ascii filenames supportz%http://www.python.org/xml-ns/saxtest/ceZdZdZdZdZy)XmlTestBasec|jt|jd|jt|jd|jt|jd|jt|j
d|jt|jd|j|jd|j|jg|j|jg|jt|d|jd||jt|jg|j|jdd|j|jddd|jt|j!g|jt|j#gy)Nattrrattrs)assertRaisesKeyErrorgetValuegetValueByQNamegetNameByQNamegetQNameByName__getitem__assertEqual	getLengthgetNames	getQNameslenassertNotInlistkeysgetitemsvaluesselfr$s  A/BuggyBox/python/3.12.0/bootstrap/lib/python3.12/test/test_sax.pyverify_empty_attrszXmlTestBase.verify_empty_attrs6sf(ENNF;(E$9$96B(E$8$8&A(E$8$8&A(E$5$5v>*A.)2.*B/UQ''ejjl+R07+T27B/4ekkm,b1elln-r2c,|jt|jtdf|jt|jd|jt|j
d|jt|jtdf|jt|jtdf|j|jd|j|jg|j|jg|jt|d|jtdf||jt|jg|j|j!tdfd|j|j!tdfdd|jt|j#g|jt|j%gy)Nr#ns:attrrr%)r&r'r(ns_urir)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8s  r:verify_empty_nsattrsz XmlTestBase.verify_empty_nsattrsGs(ENNVV4DE(E$9$99E(E$8$8)D(E$8$866:JK(E$5$57GH*A.)2.*B/UQ'&&)51ejjl+R0FF#34d;FF#3R8"=ekkm,b1elln-r2r<c|j|jd|j|jdg|j|jdg|jt	|d|jd||jt
|jdg|j|jdd|j|jddd|jt
|jdg|jt
|jdg|j|jdd|j|jdd|j|jdd|j|dd|j|jddy)Nr#valr%)r#rC)r-r.r/r0r1assertInr3r4r5r6r7r(r)r*r+r8s  r:verify_attrs_wattrzXmlTestBase.verify_attrs_wattrXsw*A.)F84*VH5UQ'

fe$ejjl+fX66*E262.6ekkm,.?@elln-w7/7..v6>--f5v>v.--f5v>r<N)__name__
__module____qualname__r;r@rEr<r:r!r!5s3"3"?r<r!c||Sd|d|SN<?xml version="1.0" encoding=""?>
rI)docencodings  r:xml_strrPjs
8@#FFr<cF|dur|}t||j|dS)N.xmlcharrefreplace)rPencode)rNrO
decl_encodings   r:	xml_bytesrUos* 
3
&--h8KLLr<c|dur|}ttd|d5}|jt||dddy#1swYyxYw)N.wrR)rOerrors)openrwriterP)rNrOrTfs    r:
make_xml_filer\tsH 
	
fcH5H	I-Q	]+,---s	?AcLeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
y)
	ParseTestu,<money value="$£€𐅻">$£€𐅻</money>c6tjtyN)runlinkrr9s r:tearDownzParseTest.tearDown~s r<cddlm}t}||t|d|j	|jt
|jdy)Nr)parser)xml.saxrerr	r-getvaluerPdata)r9r[reresults    r:check_parsezParseTest.check_parses?!
afg./*GDIIw,GHr<c	d}|D]}|jtt|j|t	|j|ttd|5}|j|ddd|jt|jt	|j|dttd|5}|j|dddy#1swYsxYw#1swYxYw)Nus-ascii
iso-8859-1rutf-16utf-16leutf-16berrO)rjrrPrhr\rYrr9	encodingsrOr[s    r:test_parse_textzParseTest.test_parse_texts7	!	$HXgdii&BCD$))X.fcH5
$  #
$Xdii01$))Xt4fcH5
$  #
$
$	$
$
$
$
$sC"C."C+	.C7	c
d}|D]}|jtt|j|t	|j||jt
t
t
d5}|j|ddd|jtt|j|dt	|j|d|jt
t
t
d5}|j|ddd|jtt|jddt	|jdd|jt
t
t
d5}|j|ddd|jtt|jddt	|jdd|jt
t
t
d5}|j|ddd|jtt|jdt	|jd|jt
t
t
d5}|j|ddd|jt5|jtt|jdddddt	|jdd|jt5|jt
dddt
t
d5}|jt5|j|ddddddy#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYxYw#1swYkxYw#1swYyxYw)Nrmrrorprqrb	utf-8-sigrrn)	rjrrUrhr\rrYr&rrts    r:test_parse_byteszParseTest.test_parse_bytessL	!
	$HWYtyy(%CDE$))X.V$fd#
$q  #
$WYtyy(D%IJK$))Xt4V$fd#
$q  #
$
$
	$	
499k7!KLMdiig6 
&$
	 1Q	 499k4!HIJdiid3 
&$
	 1Q	 	
499l!CDEdii. 
&$
	 1Q	 

|
,	PWYtyy,%MNO	Pdiit4


|
,	%V$	%
&$
	$1""<0
$  #
$	$	$=
$
$

$
$	 	 
	 	 	 	 	P	P	%	%
$
$	$	$sx2N7N?NN(N560OOO&O0O&N	N	N%(N25N?OOO#	O&&O/cnt|jdd|jtty)Nr)r\rhrjrrrbs r:test_parse_path_objectz ParseTest.test_parse_path_objects%dii$/&)*r<ct|jddttd5}t	}|j||j
d|j|dddy#1swYyxYw)Nrnry)r\rhrYrr
setByteStreamsetEncodingrj)r9r[inputs   r:test_parse_InputSourcez ParseTest.test_parse_InputSourcesddiit4
&$
	$1ME"l+U#		$	$	$s>A//A8c^tdfd}tjd|5t|jdd|jt5|jtddd|jjdddy#1swY-xYw#1swYyxYw)Nc|Sr`rI)argsbuiltin_openfileobjs r:	mock_openz4ParseTest.test_parse_close_source.<locals>.mock_opens"D)GNr<zxml.sax.saxutils.open)side_effectrn)rYrpatchr\rhr&rrjr
assertTrueclosed)r9rrrs  @@r:test_parse_close_sourcez!ParseTest.test_parse_close_sources	
ZZ/Y
G	,$))\48""<0
)  (
)OOGNN+		,	,
)
)	,	,s#-B#B+#B#B 	B##B,cddlm}t}||t|d|j	|jt
|jdy)Nr)parseStringr)rfrrr	r-rgrPrh)r9srris    r:check_parseStringzParseTest.check_parseStrings?'A|FG45*GDIIw,GHr<cd}|D]'}|jt|j|)|j|jy)Nrl)rrPrhr9rurOs   r:test_parseString_textzParseTest.test_parseString_textsE7	!	AH""7499h#?@	Atyy)r<c.d}|D]M}|jt|j||jt|j|dO|jt|jdd|jt|jdd|jt|jd|jt5|jt|jdddddy#1swYyxYw)Nrxrzrrn)rrUrhr&rrs   r:test_parseString_bytesz ParseTest.test_parseString_bytessL	!	IH""9TYY#AB""9TYY$#GH	I	
yKIJyKFGyLAB


|
,	M""9TYYd#KL	M	M	Ms'DDN)rFrGrHrhrcrjrvr{r}rrrrrrIr<r:r^r^{s=OD!I$($T+$
,I*Mr<r^c$eZdZdZdZdZdZy)MakeParserTestcddlm}|}ddlm}|}ddlm}|}ddlm}|}ddlm}|}ddlm}|}y)Nrr)rfr)r9rps   r:test_make_parser2z MakeParserTest.test_make_parser2s@	(M'M'M'M'M'Mr<ctdgtdtdhttdhtddittdgy)Nmodule)rr	frozensetiterrbs r:test_make_parser3z MakeParserTest.test_make_parser3	sK	XJL!XJIxj)*Xt$%D($%r<ctgtttttttitt	gyr`)rtuplesetrrrbs r:test_make_parser4z MakeParserTest.test_make_parser4s:BEGCEIK BDHr<ctddgtdtddhttddhtdddttddgy)Nmodule1module2)rrrrbs r:test_make_parser5z MakeParserTest.test_make_parser5sX	Y	*+*+Y	*+Iy)45667D)Y/01r<N)rFrGrHrrrrrIr<r:rrs"&2r<rcTeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZy
)SaxutilsTestc:|jtddy)NDonald Duck & CoDonald Duck &amp; Cor-r
rbs r:test_escape_basiczSaxutilsTest.test_escape_basic.s 235KLr<c:|jtddy)N<Donald Duck & Co>&lt;Donald Duck &amp; Co&gt;rrbs r:test_escape_allzSaxutilsTest.test_escape_all1s 457	9r<c@|jtdddidyNuHei på degåz&aring;zHei p&aring; degrrbs r:test_escape_extrazSaxutilsTest.test_escape_extra5s!
y/AB+	-r<c:|jtddy)Nrrr-rrbs r:test_unescape_basicz SaxutilsTest.test_unescape_basic:s"89;MNr<c:|jtddy)Nrrrrbs r:test_unescape_allzSaxutilsTest.test_unescape_all=s"@A-	/r<c@|jtdddidyrrrbs r:test_unescape_extraz SaxutilsTest.test_unescape_extraAs!-$1CD+	-r<c@|jtdddidy)Nz	&amp;foo;z&foo;splatrrbs r:test_unescape_amp_extraz$SaxutilsTest.test_unescape_amp_extraEs+/ABGLr<c:|jtddy)Nrz"Donald Duck &amp; Co"r-rrbs r:test_quoteattr_basicz!SaxutilsTest.test_quoteattr_basicIs#561	3r<c:|jtddy)NzIncludes "double" quotesz'Includes "double" quotes'rrbs r:test_single_quoteattrz"SaxutilsTest.test_single_quoteattrM#=>7	9r<c:|jtddy)NzIncludes 'single' quotesz"Includes 'single' quotes"rrbs r:test_double_quoteattrz"SaxutilsTest.test_double_quoteattrQrr<c:|jtddy)Nz%Includes 'single' and "double" quotesz1"Includes 'single' and &quot;double&quot; quotes"rrbs r:test_single_double_quoteattrz)SaxutilsTest.test_single_double_quoteattrUs#LMN	Pr<ctdg}y)Nzxml.parsers.no_such_parserr)r9rs  r:test_make_parserzSaxutilsTest.test_make_parserZs
567r<N)rFrGrHrrrrrrrrrrrrrIr<r:rr,sBM9-
O/-M399P
8r<rcTeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZy
)PrepareInputSourceTestctj|_t|jd5}|j	ddddy#1swYyxYw)NrWzThis was read from a file.)rrfilerYrZ)r9tmps  r:setUpzPrepareInputSourceTest.setUpbsA$$	
$))S
!	4SII23	4	4	4sAAcBtj|jyr`)rrarrbs r:rczPrepareInputSourceTest.tearDowngs#r<ctdSNsThis is a byte stream.)rrbs r:make_byte_streamz'PrepareInputSourceTest.make_byte_streamjs011r<ctdSNzThis is a character stream.)rrbs r:make_character_streamz,PrepareInputSourceTest.make_character_streamms566r<c|j||j|j||jyr`)assertIsNotNoner-readclose)r9streamcontents   r:checkContentz#PrepareInputSourceTest.checkContentps/V$0r<ct|j}|j|jt	|}|j|j
|j|jdyr)	rrsetCharacterStreamrrassertIsNone
getByteStreamrgetCharacterStreamr9srcpreps   r:test_character_streamz,PrepareInputSourceTest.test_character_streamvsd$))$t99;<#C($,,./$1137	9r<ct|j}|j|jt	|}|j|j
|j|jdyr)	rrrrrrrrrrs   r:test_byte_streamz'PrepareInputSourceTest.test_byte_streamsf$))$$//12#C($1134$,,.3	5r<ct|j}t|}|j|j	|j|j
dyNsThis was read from a file.)rrrrrrrrs   r:test_system_idz%PrepareInputSourceTest.test_system_idsO$))$#C($1134$,,.7	9r<ct|j}|j|j|j	|jdyr)rrrrrrr9rs  r:test_stringz"PrepareInputSourceTest.test_stringsC#DII.$1134$,,.7	9r<ctt|j}|j|j	|j|j
dyr)rrrrrrrrs  r:test_path_objectsz(PrepareInputSourceTest.test_path_objectssH#HTYY$78$1134$,,.7	9r<ct|j}|j|j|j	|jdyr)rrrrrrrs  r:test_binary_filez'PrepareInputSourceTest.test_binary_filesJ$D$9$9$;<$1134$,,.3	5r<ct|j}|j|j|j	|jdyr)rrrrrrrs  r:test_text_filez%PrepareInputSourceTest.test_text_filesJ$D$>$>$@A$,,./$1137	9r<N)rFrGrHrrcrrrrrrrrrrrIr<r:rr`s>4
$279599959r<rceZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdZdZdZdZdZdZdZy)
XmlgenTestc|j}t|}|j|jdi|j	d|j|j
|j|jdy)NrN<doc></doc>	ioclassr	
startDocumentstartElement
endElementendDocumentr-rgxmlr9rigens   r:test_xmlgen_basiczXmlgenTest.test_xmlgen_basicsi6"#u*DHH],CDr<c"|j}t|d}|j|jdi|j	d|j|j
|j|jdy)NTshort_empty_elementsrN<doc/>rrs   r:test_xmlgen_basic_emptyz"XmlgenTest.test_xmlgen_basic_emptysk6=#u*DHHX,>?r<c@|j}t|}|j|jdi|j	d|jd|j
|j|j|jdy)NrNhuhei<doc>huhei</doc>
rr	rr
charactersrrr-rgrrs   r:test_xmlgen_contentzXmlgenTest.test_xmlgen_contentsv6"#wu*DHH5G,HIr<cD|j}t|d}|j|jdi|j	d|jd|j
|j|j|jdy)NTr
rNrrrrs   r:test_xmlgen_content_emptyz$XmlgenTest.test_xmlgen_content_emptysx6=#wu*DHH5G,HIr<cB|j}t|}|j|jdd|j	di|jd|j
|j|j|jdy)NtestrhrNz<?test data?><doc></doc>)
rr	rprocessingInstructionrrrr-rgrrs   r:test_xmlgen_pizXmlgenTest.test_xmlgen_pis}6"!!&&1#u*HH/0	2r<c@|j}t|}|j|jdi|j	d|jd|j
|j|j|jdy)NrNz<huhei&z<doc>&lt;huhei&amp;</doc>rrs   r:test_xmlgen_content_escapez%XmlgenTest.test_xmlgen_content_escapesy6"#y!u*HH01	3r<c|j}t|}|j|jdddi|jdddi|j	d|jdddi|j	d|jdddi|j	d|j	d|j|j
|j|jdy)	NrNa"e'z'"z

	zK<doc a='"'><e a="'"></e><e a="'&quot;"></e><e a="&#10;&#13;&#9;"></e></doc>rrs   r:test_xmlgen_attr_escapez"XmlgenTest.test_xmlgen_attr_escapes6"c
+sCj)ssEl+ssHo.su*DHH
1-2	3r<c^d}|D]}|j}t||}|j|jdddi|j	d|jd|j
|j|j|jd|y)N	ziso-8859-15rrzrorqrpzutf-32zutf-32bezutf-32lersrNr€u<doc a="€">€</doc>rr9rurOrirs     r:test_xmlgen_encodingzXmlgenTest.test_xmlgen_encodings7	"	MH\\^Fv9CUS(O4NN8$NN5!OOV__.7(K
M	Mr<cL|j}t|d}|j|jdddi|j	d|jd|j
|j|j|jddy)NasciirsrNrr$z<doc a="&#8364;">&#8364;</doc>rrs   r:test_xmlgen_unencodablez"XmlgenTest.test_xmlgen_unencodables6G4h0x u*HH5HH	Jr<c@|j}t|}|j|jdi|j	d|jd|j
|j|j|jdy)NrN <doc> </doc>
rr	rrignorableWhitespacerrr-rgrrs   r:test_xmlgen_ignorablez XmlgenTest.test_xmlgen_ignorable,sw6"#$u*DHH^,DEr<cD|j}t|d}|j|jdi|j	d|jd|j
|j|j|jdy)NTr
rNr+r,r-rs   r:test_xmlgen_ignorable_emptyz&XmlgenTest.test_xmlgen_ignorable_empty8sy6=#$u*DHH^,DEr<cd}|D]}|j}t||}|j|jdddi|j	dj||j
dj||jd|j|j|j|jd|y)Nr#rsrNrr$r+u<doc a="€">€ </doc>)rr	rrrrSr.rrr-rgrr%s     r:test_xmlgen_encoding_bytesz%XmlgenTest.test_xmlgen_encoding_bytesDs7	"	NH\\^Fv9CUS(O4NN8??845##CJJx$89NN5!OOV__.88L
N	Nr<c|j}t|}|j|jdt|jtdfdi|jddi|j
dd|j
tdfd|jd|j|j|j|jdtzy)Nns1rNns1:docNudocz/<ns1:doc xmlns:ns1="%s"><udoc></udoc></ns1:doc>rr	rstartPrefixMappingr?startElementNSendElementNSendPrefixMappingrr-rgrrs   r:test_xmlgen_nszXmlgenTest.test_xmlgen_nsVs6"uf-FE?Ir:>44.&%)4U#*DHH<)/0-1	2r<c|j}t|d}|j|jdt|jtdfdi|jddi|j
dd|j
tdfd|jd|j|j|j|jdtzy)NTr
r5rNr6r7z)<ns1:doc xmlns:ns1="%s"><udoc/></ns1:doc>r9rs   r:test_xmlgen_ns_emptyzXmlgenTest.test_xmlgen_ns_emptyhs6=uf-FE?Ir:>44.&%)4U#*DHH6)/0-1	2r<c&|j}t|}|j|jddddi|j	dd|j|j
|j|jdy)NNrrNbcz
<a b="c"></a>	rr	rr;r<rr-rgrrs   r:test_1463026_1zXmlgenTest.test_1463026_1zst6";k#->?c**DHH_,EFr<c*|j}t|d}|j|jddddi|j	dd|j|j
|j|jdy)NTr
rBrrCrEz
<a b="c"/>rFrs   r:test_1463026_1_emptyzXmlgenTest.test_1463026_1_emptysv6=;k#->?c**DHH\,BCr<ch|j}t|}|j|jdd|j	ddi|jdd|j
d|j|j|j|jdy)NquxrKrrz<a xmlns="qux"></a>rr	rr:r;r<r=rr-rgrrs   r:test_1463026_2zXmlgenTest.test_1463026_2s6"tU+<b1s+T"*DHH5J,KLr<cl|j}t|d}|j|jdd|j	ddi|jdd|j
d|j|j|j|jdy)NTr
rKrLrz<a xmlns="qux"/>rMrs   r:test_1463026_2_emptyzXmlgenTest.test_1463026_2_emptys6=tU+<b1s+T"*DHH5G,HIr<cl|j}t|}|j|jdd|j	ddddi|jdd|j
d|j|j|j|jdy)NmyrKrLrrCrEz"<my:a xmlns:my="qux" b="c"></my:a>rMrs   r:test_1463026_3zXmlgenTest.test_1463026_3s6"tU+<{3.?@s+T"*HH9:	<r<cp|j}t|d}|j|jdd|j	ddddi|jdd|j
d|j|j|j|jd	y)
NTr
rRrKrLrrCrEz<my:a xmlns:my="qux" b="c"/>rMrs   r:test_1463026_3_emptyzXmlgenTest.test_1463026_3_emptys6=tU+<{3.?@s+T"*HH34	6r<c2td}t}|jtd|j	}t|}|j
||j||j|j|jdy)Nzb<?xml version="1.0"?><a:g1 xmlns:a="http://example.com/ns"><a:g2 xml:lang="en">Hello</a:g2></a:g1>TM<a:g1 xmlns:a="http://example.com/ns"><a:g2 xml:lang="en">Hello</a:g2></a:g1>)rr
setFeaturerrr	setContentHandlerrer-rgr)r9test_xmlparserrirs     r:test_5027_1zXmlgenTest.test_5027_1s
,d36"  %X*#$	%r<c|j}t|}|j|jdd|j	ddiddi}|j	dd||jd	|j
dd|j
dd|jd|j|j|j|jd
y)Nrhttp://example.com/ns)r^g1r_)z$http://www.w3.org/XML/1998/namespacelangen)r^g2rbHellorW)rr	rr:r;rr<r=rr-rgr)r9rir	lang_attrs    r:test_5027_2zXmlgenTest.test_5027_2s6"s$;<:D"EEtL	:D)Lw8$?8$?S!*#$	%r<cp|j}d}|||j|jy)Nc^t|}|j|jdiy)NrN)r	rr)outrs  r:funcz+XmlgenTest.test_no_close_file.<locals>.funcs(s#CUB'r<)rassertFalser)r9riris   r:test_no_close_filezXmlgenTest.test_no_close_files-	(	
V'r<c	|j}t|}|jdddi|jd|j	d|jdddi|j	d|j|j
|jdt|jd	dy)
Nfoor1.0rcbarrDz2.0z+<foo a="1.0">Hello</foo><bar b="2.0"></bar>)	rr	rrrr-rgrr1rs   r:test_xmlgen_fragmentzXmlgenTest.test_xmlgen_fragments6"	e-wue-u	
*HHBCCQSDUDVW	Yr<N)rFrGrHrr
rrrrr!r&r)r/r1r3r>r@rGrIrNrPrSrUr\rerkrqrIr<r:rrsE@
J
J233(M"J
F
FN$2$2$	G	DMJ<6%4%8(
Yr<rceZdZeZddZdZy)StringXmlgenTestcd|d|SrKrIr9rNrOs   r:rzStringXmlgenTest.xmls
<DcJJr<Nrn)rFrGrHrrrr)rIr<r:rsrssGK#r<rsceZdZeZddZy)BytesXmlgenTestc2d|d|j|dS)NrLrMrRrSrus   r:rzBytesXmlgenTest.xmls3 !'2E!F	Gr<Nrv)rFrGrHrrrrIr<r:rxrxs
GGr<rxc"eZdZGddeZy)WriterXmlgenTestc:eZdZejZdZdZdZdZ	y)WriterXmlgenTest.ioclassFcyNTrIrbs r:seekablez!WriterXmlgenTest.ioclass.seekable(sr<ct|Sr`)r1rbs r:tellzWriterXmlgenTest.ioclass.tell+st9r<c$dj|S)Nr<)joinrbs r:rgz!WriterXmlgenTest.ioclass.getvalue/s88D>!r<N)
rFrGrHr3appendrZrrrrgrIr<r:rr~$s			"r<rN)rFrGrHr3rrIr<r:r|r|#s"$"r<r|ceZdZdZddZy)StreamWriterXmlgenTestctt}tjd|d}|j|_|S)Nr(rR)rcodecs	getwriterrg)r9rawwriters   r:rzStreamWriterXmlgenTest.ioclass3s3i*!!'*30CD,,
r<c2d|d|jddSNrLrMr(rRrzrus   r:rzStreamWriterXmlgenTest.xml93 !'1D!E	Fr<Nrv)rFrGrHrrrIr<r:rr2s
Fr<rc8eZdZejdzZdZddZy)StreamReaderWriterXmlgenTestz-codecsctjjddddfd}j|fd}|_S)NrWr(rRr)rOrX	bufferingcdjtjjyr`)rrrafname)r9rsr:cleanupz5StreamReaderWriterXmlgenTest.ioclass.<locals>.cleanupCsLLNTZZ(r<cjtjd5}|jcdddS#1swYyxYwNry)rrYnamer)r[rs r:rgz6StreamReaderWriterXmlgenTest.ioclass.<locals>.getvalueGs:LLNfkk4(
 Avvx
 
 
 sAA)rrYr
addCleanuprg)r9rrgrs`  @r:rz$StreamReaderWriterXmlgenTest.ioclass@sGTZZw$71F	)	
 	 
#
r<c2d|d|jddSrrzrus   r:rz StreamReaderWriterXmlgenTest.xmlOrr<Nrv)rFrGrHrrrrrrIr<r:rr=sy(E
Fr<rs,<?xml version="1.0" encoding="iso-8859-1"?>
ceZdZdZy)XMLFilterBaseTestc|t}t|}t}|j||j	|jdi|j
d|jd|jd|j|j|jtdzy)NrNrr+s<doc>content </doc>)
rr	r
rYrrrr.rrr-rgstart)r9rirfilters    r:test_filter_basicz#XMLFilterBaseTest.test_filter_basicWs6"  %E2&)$""3'% *E4J,JKr<N)rFrGrHrrIr<r:rrVs
Lr<rryceZdZdZdZedZdZdZGddZ	Gdd	Z
d
ZdZdZ
Gd
dZdZdZGddeZdZdZdZdZdZdZedZdZdZdZdZdZdZed Z y!)"ExpatReaderTestct}t}t|}|j|t	t
d5}|j
|ddd|j|jty#1swY.xYwr
rrr	rYrYTEST_XMLFILErer-rgxml_test_outr9r[rixmlgenr[s     r:test_expat_binary_filez&ExpatReaderTest.test_expat_binary_filessmf%  (
,
%	LLO		
*L9		sBB	ct}t}t|}|j|t	t
dd5}|j
|ddd|j|jty#1swY.xYwNrtrnrsrrs     r:test_expat_text_filez$ExpatReaderTest.test_expat_text_file~sof%  (
,|
<	LLO		
*L9		sBBcvtj}tjt||jtj|t}t}t|}|j||jt|d|j|jtyr)rTESTFN_UNICODEshutilcopyfilerrrarrr	rYrerYr-rgrr9rr[rirs     r:test_expat_binary_file_nonasciiz/ExpatReaderTest.test_expat_binary_file_nonasciis((e,	((%0f%  (T%&'*L9r<cBtjt}t}t	}t|}|j
|t|d5}|j|ddd|j|jty#1swY.xYwr)osfsencoderrrr	rYrYrer-rgr)r9rr[rirr[s      r:!test_expat_binary_file_bytes_namez1ExpatReaderTest.test_expat_binary_file_bytes_names{L)f%  (
%
	!LLO		
*L9		sBBczt}t}t|}|j|t	t
d5}t	|j
dd5}|j|dddddd|j|jty#1swY6xYw#1swY:xYw)NryF)closefd)rrr	rYrYrfilenorer-rgr)r9r[rirr[f2s      r:test_expat_binary_file_int_namez/ExpatReaderTest.test_expat_binary_file_int_namesf%  (
,
%	!ahhj$6
!"R 
!	!	
*L9
!
!	!	!s$B1B%0B1%B.	*B11B:ceZdZdZdZdZy)ExpatReaderTest.TestDTDHandlerc g|_g|_yr`)
_notations	_entitiesrbs r:__init__z'ExpatReaderTest.TestDTDHandler.__init__s DO DNr<c@|jj|||fyr`)rr)r9rpublicIdsystemIds    r:notationDeclz+ExpatReaderTest.TestDTDHandler.notationDeclsOO""D(H#=>r<cB|jj||||fyr`)rr)r9rrrndatas     r:unparsedEntityDeclz1ExpatReaderTest.TestDTDHandler.unparsedEntityDeclsNN!!48U"CDr<N)rFrGrHrrrrIr<r:TestDTDHandlerrs	!	?	Er<rceZdZdZdZy)"ExpatReaderTest.TestEntityRecordercg|_yr`)entitiesrbs r:rz+ExpatReaderTest.TestEntityRecorder.__init__s	DMr<c|jj||ft}|j||j	||Sr`)rrrsetPublicIdsetSystemId)r9rrsources    r:
resolveEntityz0ExpatReaderTest.TestEntityRecorder.resolveEntitysAMM  (H!56 ]Fx(x(Mr<N)rFrGrHrrrIr<r:TestEntityRecorderrs		r<rct}|j}|j||jd|jd|jd|jd|jd|j	|j|jdg|j|jdgy)N<!DOCTYPE doc [
z-  <!ENTITY img SYSTEM "expat.gif" NDATA GIF>
zW  <!NOTATION GIF PUBLIC "-//CompuServe//NOTATION Graphics Interchange Format 89a//EN">
]>
r)GIFz;-//CompuServe//NOTATION Graphics Interchange Format 89a//ENN)imgNz	expat.gifr)rr
setDTDHandlerfeedrr-rr)r9r[handlers   r:test_expat_dtdhandlerz%ExpatReaderTest.test_expat_dtdhandlers%%'W%'(DEnoFM"++
YZ	\**-N,OPr<c|jtjjt	}|jtd|j}|j||jt5|jdddd|j|jdgy#1swY'xYw)NT8<!DOCTYPE external SYSTEM "unsupported://non-existing">
)Nzunsupported://non-existing)rurllibrequest
urlcleanuprrXrrsetEntityResolverr&rrr-rr9r[resolvers   r:test_expat_external_dtd_enabledz/ExpatReaderTest.test_expat_external_dtd_enableds112.5**,  *


x
(	KKK
		
 DE	
			sB88Cct}|j}|j||jd|jd|j	|j|jgy)Nrz<doc />)rrrrrr-rrs   r:test_expat_external_dtd_defaultz/ExpatReaderTest.test_expat_external_dtd_defaultsa**,  *G	
	I**B/r<ceZdZdZy)"ExpatReaderTest.TestEntityResolvercNt}|jtd|S)Ns	<entity/>)rrr)r9rrinpsrcs    r:rz0ExpatReaderTest.TestEntityResolver.resolveEntitys! ]F  !67Mr<N)rFrGrHrrIr<r:TestEntityResolverrs	r<rct}|jtd|j|j	t}|j
t||jd|jd|jd|jd|j|j|jtdzy)NTr#  <!ENTITY test SYSTEM "whatever">
r<doc>&test;</doc>s<doc><entity></entity></doc>)
rrXrrrrrYr	rrr-rgrr9r[ris   r:!test_expat_entityresolver_enabledz1ExpatReaderTest.test_expat_entityresolver_enableds.5  !8!8!:;  f!56'(:;F'(*E8-9	:r<ct}|j|jtd|j	|jt
}|jt||jd|jd|jd|jd|j|j|jtdzy)NFrrrr<doc></doc>)
rr-
getFeaturerrrrrYr	rrrgrrs   r:!test_expat_entityresolver_defaultz1ExpatReaderTest.test_expat_entityresolver_defaults**+?@%H  !8!8!:;  f!56'(:;F'(*E'-(	)r<ceZdZdZdZy)ExpatReaderTest.AttrGathererc||_yr`_attrs)r9rr$s   r:rz)ExpatReaderTest.AttrGatherer.startElement$	DKr<c||_yr`r)r9rqnamer$s    r:r;z+ExpatReaderTest.AttrGatherer.startElementNS'rr<N)rFrGrHrr;rIr<r:AttrGathererr"s	 	 r<rct}|j}|j||jd|j	|j|jy)Nr)rrrYrrr;rr9r[gathers   r:test_expat_attrs_emptyz&ExpatReaderTest.test_expat_attrs_empty*sL""$  (H

.r<ct}|j}|j||jd|j	|j|jy)Nz<doc attr='val'/>)rrrYrrrErrs   r:test_expat_attrs_wattrz&ExpatReaderTest.test_expat_attrs_wattr4sM""$  ('(

.r<ctd}|j}|j||jd|j	|j|jy)NrBr)rrrYrrr@rrs   r:test_expat_nsattrs_emptyz(ExpatReaderTest.test_expat_nsattrs_empty>sOq!""$  (H!!&--0r<ctd}|j}|j||jdtz|j|j}|j|jd|j|jtdfg|j|jgk(xs|jdgk(|jt|d|jtdf||j|jtdfd|j|jtdfdd|jt|j!tdfdfg|jt|j#dg|j|j%tdfd|j|tdfdy)NrBz"<doc xmlns:ns='%s' ns:attr='val'/>r#r>rCr%)rrrYrr?rrr-r.r/rr0r1rDr5r3r6r7r()r9r[rr$s    r:test_expat_nsattrs_wattrz(ExpatReaderTest.test_expat_nsattrs_wattrHsq!""$  (86AB

*A.)VV,<+=>*b0:*yk9	<UQ'

vv&.FF#34e<FF#3R8%@ekkm,0@%/H.IJelln-w7(895A/0%8r<ct}t}t|}|j||j	t
|j
|jtyr`)	rrr	rYrerr-rgrr9r[rirs    r:test_expat_inpsource_filenamez-ExpatReaderTest.test_expat_inpsource_filenameasKf%  (\"*L9r<ct}t}t|}|j||j	tt|j|jtyr`)
rrr	rYrerrr-rgrr
s    r:test_expat_inpsource_sysidz*ExpatReaderTest.test_expat_inpsource_sysidksPf%  ([./*L9r<cttj}tjt||jtj|t}t}t|}|j||jt||j|jtyr`)rrrrrrrarrr	rYrerr-rgrrs     r:#test_expat_inpsource_sysid_nonasciiz3ExpatReaderTest.test_expat_inpsource_sysid_nonasciius}((e,	((%0f%  (['(*L9r<cNt}t}t|}|j|t	}ttd5}|j||j|ddd|j|jty#1swY.xYwr)rrr	rYrrYrrrer-rgrr9r[rirrr[s      r: test_expat_inpsource_byte_streamz0ExpatReaderTest.test_expat_inpsource_byte_streamsf%  (
,
%	!  #LL 	!	
*L9		!	!s#BB$cRt}t}t|}|j|t	}ttdd5}|j||j|ddd|j|jty#1swY.xYwr)rrr	rYrrYrrrer-rgrrs      r:%test_expat_inpsource_character_streamz5ExpatReaderTest.test_expat_inpsource_character_streamsf%  (
,|
<	!%%a(LL 	!	
*L9		!	!s
#BB&ct}t|}t}|j||j	d|j	d|j|j
|jtdzy)N<doc></doc>r)	rr	rrYrrr-rgrr9rirr[s    r:test_expat_incrementalz&ExpatReaderTest.test_expat_incrementalsef%  (GH*EN,BCr<ct}t|}t}|j||j	d|j	dt}t|}|j||j|j	d|j	d|j	d|j
|j|jtdzy)Nrtextrs<doc>text</doc>)
rr	rrYrresetrr-rgrrs    r:test_expat_incremental_resetz,ExpatReaderTest.test_expat_incremental_resetsf%  (GFf%  (GFH*E4F,FGr<ct}t|}t}|j||j	d|j	d|j|j
|jd|j
|jd|j
|jdy)NrrrB)
rr	rrYrrr-getSystemIdgetPublicId
getLineNumberrs    r:test_expat_locator_noinfoz)ExpatReaderTest.test_expat_locator_noinfosf%  (GH++-t4++-t4--/3r<ct}t|}t}|j||j	t
|j
|jt
|j
|jdyr`)	rr	rrYrerr-r"r#rs    r:test_expat_locator_withinfoz+ExpatReaderTest.test_expat_locator_withinfosff%  (\"++-|<++-t4r<ctj}tjt||jtj|t}t|}t}|j||j||j|j||j|jdyr`)rrrrrrrarr	rrYrer-r"r#)r9rrirr[s     r:$test_expat_locator_withinfo_nonasciiz4ExpatReaderTest.test_expat_locator_withinfo_nonasciis((e,	((%0f%  (U++-u5++-t4r<N)!rFrGrHrrrequires_nonascii_filenamesrrrrrrrrrrrrrrrr	rrrrrrrr r%r'r)rIr<r:rros	:	:!:!:
:
:
E
E		Q 
"
0: )$ ~ //192::!:!:::
DH.45!5!5r<rc2eZdZdZdZdZGddZy)ErrorReportingTestcht}|jtt}|j	tdd}|j
|	|j||jy#t$r*}|j|j|Yd}~yd}~wwxYw)Ns<foo bar foobar>za file name)rrYrrrrrrefailrr-r")r9r[rrrs     r:test_expat_inpsource_locationz0ErrorReportingTest.test_expat_inpsource_locations  !12W%89:4 	4LL IIK	4Q]]_d33	4s!A>>	B1 B,,B1ct}|jt|jt|j
t
d|j|jd|j|jdy)Nz<foo>rB)
rrYrr&rrerr-getColumnNumberr$)r9r[s  r:test_expat_incompletez(ErrorReportingTest.test_expat_incompletesh  !12+V\\8G;LM//115--/3r<c
4ttdd|jddttdd|jddttdd|jddttdd|jddy)NmessagerB)strrDummyLocatorrbs r:test_sax_parse_exception_strz/ErrorReportingTest.test_sax_parse_exception_strs	i"//15
7	8	i"//a8
:	;	i"//48
:	;	i"//d;
=	>r<c*eZdZdZdZdZdZdZy)ErrorReportingTest.DummyLocatorc ||_||_yr`)_lineno_colno)r9linenocolnos   r:rz(ErrorReportingTest.DummyLocator.__init__s!DLDKr<cy)NpubidrIrbs r:r#z+ErrorReportingTest.DummyLocator.getPublicIdr<cy)NsysidrIrbs r:r"z+ErrorReportingTest.DummyLocator.getSystemId rBr<c|jSr`)r<rbs r:r$z-ErrorReportingTest.DummyLocator.getLineNumber#s<<r<c|jSr`)r=rbs r:r2z/ErrorReportingTest.DummyLocator.getColumnNumber&s;;r<N)rFrGrHrr#r"r$r2rIr<r:r7r:s	 			 	r<r7N)rFrGrHr/r3r8r7rIr<r:r,r,s44>$r<r,c$eZdZdZdZdZdZy)
XmlReaderTestc8|jtiyr`)r;rrbs r:test_attrs_emptyzXmlReaderTest.test_attrs_empty2sr 23r<c<|jtddiy)Nr#rC)rErrbs r:test_attrs_wattrzXmlReaderTest.test_attrs_wattr5s/? @Ar<c:|jtiiyr`)r@rrbs r:test_nsattrs_emptyz XmlReaderTest.test_nsattrs_empty8s!!"22r":;r<cttdfditdfdi}|j|jd|j|j	tdfg|j|jdg|jt
|d|jtdf||jt|jtdfg|j|jtdfd|j|jtdfdd|jt|jtdfdfg|jt|jdg|j|jtdfd|j|jdd|j|jdtdf|j|tdfd|j|j!tdfdy)Nr#rCr>rBr%)rr?r-r.r/r0r1rDr3r4r5r6r7r(r)r*r+r8s  r:test_nsattrs_wattrz XmlReaderTest.test_nsattrs_wattr;s 66"2U!;#)6"2Y!?A	
*A.)VV,<+=>*YK8UQ'

vv&.ejjl+vv.>-?@FF#34e<FF#3R8%@ekkm,0@%/H.IJelln-w7(895A..y95A--i866:JK/0%8--vv.>?Kr<N)rFrGrHrJrLrNrPrIr<r:rHrH/s4B<Lr<rHceZdZdZdZy)LexicalHandlerTestc"d|_d|_d|_d|_d|_d|_t
|_|jjdj|j|j|jjdj|j|jjdj|j
d	|jjd
j|j|jjd|jjd|jjd
|jjd|jjd|jjdj|jd	|jjdj|jd|jjdj|jd|jjd|jjdj|j|jjd|jjd|jjd|jjd|jjdj|jd|jd	|jd|jjdj|j
d|jjdj|j|jjd	d|_d|_d|_
d|_d|_d|_d|_g|_y)NrnzUTF-8wish)nbsprtarget)zComment in a DTDzReally! You think so?z#<?xml version="{}" encoding="{}"?>
z<!DOCTYPE {} [
z<!-- {} -->
rz,<!ELEMENT {} (to,from,heading,body,footer)>
z<!ELEMENT to (#PCDATA)>
z<!ELEMENT from (#PCDATA)>
z<!ELEMENT heading (#PCDATA)>
z<!ELEMENT body (#PCDATA)>
z<!ELEMENT footer (#PCDATA)>
z<!ENTITY {} "&#xA0;">
z&<!ENTITY {} "Written by: Alexander.">
rBz+<!ENTITY {} "Hope it gets to: Aristotle.">
rz<{}>z<to>Aristotle</to>
z<from>Alexander</from>
z <heading>Supplication</heading>
z <body>Teach me patience!</body>
z<footer>&{};&{};&{};</footer>
z</{}>
F)r[specified_versionspecified_encodingspecified_doctypespecified_entity_namesspecified_commentr	test_datarZformatseekversionrO
standalonedoctypepublicIDsystemID
end_of_dtdcommentsrbs r:rzLexicalHandlerTest.setUpQs$!&")!'&B#";!C#VD$:$:$($;$;=	>	
/#VD$:$:;	=_#VD$:$:1$=>	@L#VD$:$:;	=89:;=>:;<=6#VD$?$?$BC	EF#VD$?$?$BC	EK#VD$?$?$BC	EV$V]]4+A+ABC3478@A@A>#VD$?$?$B$($?$?$B$($?$?$BD	E	
_33D4J4J14MNOY--d.D.DEFA



r<cGddt}t|_|jjt	|jjd||t
}|j|j|jj||j|j|j|j|j|j|j|j!|j"|jt%|j&t%|j(|jd|j(dd|j&dy)Nc0eZdZfdZdZdZdZxZS)<LexicalHandlerTest.test_handlers.<locals>.TestLexicalHandlerc2t||i|||_yr`superrtest_harnessr9rmrkwargs	__class__s    r:rzELexicalHandlerTest.test_handlers.<locals>.TestLexicalHandler.__init__ $1&1$0!r<cj||j_||j_||j_yr`)rmrbrcrd)r9rbrcrds    r:startDTDzELexicalHandlerTest.test_handlers.<locals>.TestLexicalHandler.startDTDs,,3!!)-5!!*-5!!*r<c&d|j_yr)rmrerbs r:endDTDzCLexicalHandlerTest.test_handlers.<locals>.TestLexicalHandler.endDTDs/3!!,r<cN|jjj|yr`)rmrfr)r9rs  r:commentzDLexicalHandlerTest.test_handlers.<locals>.TestLexicalHandler.comments!!**11$7r<)rFrGrHrrsrurw
__classcell__rps@r:TestLexicalHandlerris
1
6

4
8r<rz-http://xml.org/sax/properties/lexical-handlerr+r)rrr[rYrsetPropertyrrr]rer-rbrZrrcrdrrer1rfr\)r9rzrs   r:
test_handlersz LexicalHandlerTest.test_handlerss	8	8 $o%%n&67;t$	&!!$..1&!t'='=>$--($--((T]]+T334	61T33A67q94==;KLr<NrFrGrHrr}rIr<r:rRrRPs4lMr<rRceZdZdZdZy)CDATAHandlerTestcd|_g|_|jjd|jjdd|_t	|_|j
j
d|j
j
d|j
j
|jddd|j
j
d|j
j
d|j
j
d	|jd
dd|j
j
d|j
j
d
|j
jdg|_d|_	y)N)zParseable character dataF)z <> &% - assorted other XML junk.Trz<root_doc>
z<some_pcdata>

z</some_pcdata>
z
<some_cdata>
z	<![CDATA[rBz]]>
z</some_cdata>
z</root_doc>
F)
r[specified_charsr
char_indexrr]rZr_chardatain_cdatarbs r:rzCDATAHandlerTest.setUps3!##$GH##$NO!^,./ 4 4Q 7 :;2>?/0-.y)=)=a)@)C(DEJK./_-A

r<cGddt}Gddt}t|_|jj	|||jjd||t
}|j|j|jj||j|j|j|jdy)Nc*eZdZfdZdZdZxZS):CDATAHandlerTest.test_handlers.<locals>.TestLexicalHandlerc2t||i|||_yr`rkrns    r:rzCCDATAHandlerTest.test_handlers.<locals>.TestLexicalHandler.__init__rqr<c&d|j_yrrmrrbs r:
startCDATAzECDATAHandlerTest.test_handlers.<locals>.TestLexicalHandler.startCDATAs-1!!*r<c&d|j_y)NFrrbs r:endCDATAzCCDATAHandlerTest.test_handlers.<locals>.TestLexicalHandler.endCDATAs-2!!*r<)rFrGrHrrrrxrys@r:rzrs
1
2
3r<rzc$eZdZfdZdZxZS)7CDATAHandlerTest.test_handlers.<locals>.TestCharHandlerc2t||i|||_yr`rkrns    r:rz@CDATAHandlerTest.test_handlers.<locals>.TestCharHandler.__init__rqr<c|dk7ro|j}|j|j}|j|d||j|d|j|xjdz
c_yy)NrrrB)rmrrr-r)r9rhts    r:rzBCDATAHandlerTest.test_handlers.<locals>.TestCharHandler.charactersscd?))A))!,,7AMM!A$0MM!A$

3LLA%L#r<)rFrGrHrrrxrys@r:TestCharHandlerrs

1
&r<rr{rW)rrrr[rYr|rrr]rerjrr-r)r9rzrrs    r:r}zCDATAHandlerTest.test_handlerss		3		3	&n	&$o%%od&;<;t$	&!!$..1&!'!,r<Nr~rIr<r:rrs*#-r<r__main__r`).)VrfrrrrrunittestrSkipTestxml.sax.saxutilsr	r
rrr
rxml.sax.expatreaderrxml.sax.handlerrrrxml.sax.xmlreaderrrriorrros.pathrrsysurllib.errorrurllib.requestrtest.supportrrtest.support.os_helperrrrTEST_XMLFILE_OUTrSUnicodeEncodeErrorsupports_nonascii_filenamespathsupports_unicode_filenamesrgetfilesystemencodingUnicodeError	TypeError
skipUnlessr*r?TestCaser!rPrUr\r^rrrrrsrxr|rrrrrYr[rrrr,rHrRrrFmainrIr<r:<module>rsKK8MAA---KK 


!"!3
=9N=AA G$#	ww)),  ''(A(A(A(CD
2h11#.0
12?(##2?jG
M
-zM!!zMx-2X&&-2j188$$18hN9X..N9f_Y_YB#z8#4#4#Gj("3"3G
"
"	FZ):):	FF:x/@/@F,	9L))L,

D!Q668Ly5ky5D6**6|LKLBVM**VMr9-x((9-xzHMMOw.8
(

6
7784A
(

?
@@A
)$,',#,Bs5J"J3*KKJ03K	KKK'