Your IP : 216.73.216.213


Current Path : /proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/
Upload File :
Current File : //proc/242857/root/opt/alt/python34/lib64/python3.4/test/__pycache__/test_pyexpat.cpython-34.pyo

�
f f�l�@s�ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZm
Z
Gdd�dej�ZdZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�Zdd �Zed!kr�e�ndS)"�)�BytesION)�expat)�errors)�sortdict�run_unittestc@sdeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd
�Zdd
�ZdS)�SetAttributeTestcCstjdd�|_dS)N�namespace_separator�!)r�ParserCreate�parser)�self�r
�6/opt/alt/python34/lib64/python3.4/test/test_pyexpat.py�setUpszSetAttributeTest.setUpcCsS|j|jjd�x6dD].}||j_|j|jjt|��qWdS)NFr��)rrrr)�assertIsr�buffer_text�bool)r�xr
r
r�test_buffer_texts
z!SetAttributeTest.test_buffer_textcCsS|j|jjd�x6dD].}||j_|j|jjt|��qWdS)NFrrr)rrrr)rrZnamespace_prefixesr)rrr
r
r�test_namespace_prefixess
z(SetAttributeTest.test_namespace_prefixescCsS|j|jjd�x6dD].}||j_|j|jjt|��qWdS)NFrrr)rrrr)rrZordered_attributesr)rrr
r
r�test_ordered_attributes!s
z(SetAttributeTest.test_ordered_attributescCsS|j|jjd�x6dD].}||j_|j|jjt|��qWdS)NFrrr)rrrr)rr�specified_attributesr)rrr
r
r�test_specified_attributes's
z*SetAttributeTest.test_specified_attributescCsS|j|jjd�x6dD].}||j_|j|jjt|��qWdS)NFrrr)rrrr)rrrr)rrr
r
rr-s
cCs�|jt��d|j_WdQX|jt��|jjWdQX|jtt|jtd�d�|jt|jjtd�d�|jtt|jtd��dS)Nr�r)	�assertRaises�AttributeErrorrZreturns_unicode�	TypeError�setattr�range�__setattr__�getattr)rr
r
r�test_invalid_attributes3s""z(SetAttributeTest.test_invalid_attributesN)	�__name__�
__module__�__qualname__rrrrrr#r
r
r
rrsrs�<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<?xml-stylesheet href="stylesheet.css"?>
<!-- comment data -->
<!DOCTYPE quotations SYSTEM "quotations.dtd" [
<!ELEMENT root ANY>
<!ATTLIST root attr1 CDATA #REQUIRED attr2 CDATA #IMPLIED>
<!NOTATION notation SYSTEM "notation.jpeg">
<!ENTITY acirc "&#226;">
<!ENTITY external_entity SYSTEM "entity.file">
<!ENTITY unparsed_entity SYSTEM "entity.file" NDATA notation>
%unparsed_entity;
]>

<root attr1="value1" attr2="value2&#8000;">
<myns:subelement xmlns:myns="http://www.python.org/namespace">
     Contents of subelements
</myns:subelement>
<sub2><![CDATA[contents of CDATA section]]></sub2>
&external_entity;
&skipped_entity;
�
</root>
c@s�eZdZGdd�d�Zddddddd	d
ddd
dddddddddddgZdd�Zdd�Zdd�Zdd �Zd!d"�Z	d#d$�Z
d%S)&�	ParseTestc@s$eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0zParseTest.OutputtercCs
g|_dS)N)�out)rr
r
r�__init__\szParseTest.Outputter.__init__cCs,|jjdt|�dt|��dS)NzStart element: � )r(�append�reprr)r�name�attrsr
r
r�StartElementHandler_sz'ParseTest.Outputter.StartElementHandlercCs|jjdt|��dS)Nz
End element: )r(r+r,)rr-r
r
r�EndElementHandlercsz%ParseTest.Outputter.EndElementHandlercCs3|j�}|r/|jjdt|��ndS)NzCharacter data: )�stripr(r+r,)r�datar
r
r�CharacterDataHandlerfsz(ParseTest.Outputter.CharacterDataHandlercCs,|jjdt|�dt|��dS)NzPI: r*)r(r+r,)r�targetr2r
r
r�ProcessingInstructionHandlerksz0ParseTest.Outputter.ProcessingInstructionHandlercCs,|jjdt|�dt|��dS)Nz	NS decl: r*)r(r+r,)r�prefixZurir
r
r�StartNamespaceDeclHandlernsz-ParseTest.Outputter.StartNamespaceDeclHandlercCs|jjdt|��dS)NzEnd of NS decl: )r(r+r,)rr6r
r
r�EndNamespaceDeclHandlerqsz+ParseTest.Outputter.EndNamespaceDeclHandlercCs|jjd�dS)NzStart of CDATA section)r(r+)rr
r
r�StartCdataSectionHandlertsz,ParseTest.Outputter.StartCdataSectionHandlercCs|jjd�dS)NzEnd of CDATA section)r(r+)rr
r
r�EndCdataSectionHandlerwsz*ParseTest.Outputter.EndCdataSectionHandlercCs|jjdt|��dS)Nz	Comment: )r(r+r,)r�textr
r
r�CommentHandlerzsz"ParseTest.Outputter.CommentHandlercGs-|\}}}}|jjd|f�dS)NzNotation declared: %s)r(r+)r�argsr-�baseZsysidZpubidr
r
r�NotationDeclHandler}sz'ParseTest.Outputter.NotationDeclHandlercGs0|\}}}}}|jjd|f�dS)NzUnparsed entity decl: %s)r(r+)rr=Z
entityNamer>ZsystemIdZpublicIdZnotationNamer
r
r�UnparsedEntityDeclHandler�sz-ParseTest.Outputter.UnparsedEntityDeclHandlercCs|jjd�dS)NzNot standaloner)r(r+)rr
r
r�NotStandaloneHandler�sz(ParseTest.Outputter.NotStandaloneHandlercGs7|\}}}}|jjd|dd�f�dS)NzExternal entity ref: %sr)r(r+)rr=�contextr>�sysId�pubIdr
r
r�ExternalEntityRefHandler�s!z,ParseTest.Outputter.ExternalEntityRefHandlercGs|jjd|f�dS)Nz
Start doctyper)r(r+)rr=r
r
r�StartDoctypeDeclHandler�sz+ParseTest.Outputter.StartDoctypeDeclHandlercCs|jjd�dS)NzEnd doctyper)r(r+)rr
r
r�EndDoctypeDeclHandler�sz)ParseTest.Outputter.EndDoctypeDeclHandlercGs|jjd|f�dS)NzEntity declarationr)r(r+)rr=r
r
r�EntityDeclHandler�sz%ParseTest.Outputter.EntityDeclHandlercGs|jjd|f�dS)NzXML declarationr)r(r+)rr=r
r
r�XmlDeclHandler�sz"ParseTest.Outputter.XmlDeclHandlercGs|jjd|f�dS)NzElement declarationr)r(r+)rr=r
r
r�ElementDeclHandler�sz&ParseTest.Outputter.ElementDeclHandlercGs|jjd|f�dS)NzAttribute list declarationr)r(r+)rr=r
r
r�AttlistDeclHandler�sz&ParseTest.Outputter.AttlistDeclHandlercGs|jjd|f�dS)NzSkipped entityr)r(r+)rr=r
r
r�SkippedEntityHandler�sz(ParseTest.Outputter.SkippedEntityHandlercCsdS)Nr
)r�userDatar
r
r�DefaultHandler�sz"ParseTest.Outputter.DefaultHandlercCsdS)Nr
)rrMr
r
r�DefaultHandlerExpand�sz(ParseTest.Outputter.DefaultHandlerExpandN)r$r%r&r)r/r0r3r5r7r8r9r:r<r?r@rArErFrGrHrIrJrKrLrNrOr
r
r
r�	Outputter[s.rPr/r0r3r5r@r?r7r8r<r9r:rNrOrArErFrGrHrIrJrKrLcCs1x*|jD]}t||t||��q
WdS)z{
        Set each of the callbacks defined on handler and named in
        self.handler_names on the given parser.
        N)�
handler_namesrr")rr�handlerr-r
r
r�_hookup_callbacks�szParseTest._hookup_callbackscCs�d,dddd.dd
dddffffd0d2dd4d6ddddddddd d!d"d#d$d%d&d8d)d*g}x-t||�D]\}}|j||�q�WdS)9N�XML declaration�1.0�
iso-8859-1rz,PI: 'xml-stylesheet' 'href="stylesheet.css"'zComment: ' comment data 'zNot standalone�
Start doctype�
quotations�quotations.dtdrzElement declaration�rootr�Attribute list declaration�attr1�CDATA�attr2z<Notation declared: ('notation', None, 'notation.jpeg', None)�Entity declaration�acirc�â�external_entity�entity.filezPUnparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')zEnd doctypeu?Start element: 'root' {'attr1': 'value1', 'attr2': 'value2ὀ'}z1NS decl: 'myns' 'http://www.python.org/namespace'z>Start element: 'http://www.python.org/namespace!subelement' {}z)Character data: 'Contents of subelements'z9End element: 'http://www.python.org/namespace!subelement'zEnd of NS decl: 'myns'zStart element: 'sub2' {}zStart of CDATA sectionz+Character data: 'contents of CDATA section'zEnd of CDATA sectionzEnd element: 'sub2'z0External entity ref: (None, 'entity.file', None)�Skipped entity�skipped_entityuCharacter data: 'µ'zEnd element: 'root'�rUrVr)rTrf�rXrYNr)rWrg��rootr\r]Nr)r[rh�rir^r]Nr)r[rj�r`rraNNNN)r_rk�rbrNNrcNN)r_rl�rer)rdrm)�zip�assertEqual)r�
operationsZexpected_operationsZ	operationZexpected_operationr
r
r�_verify_parse_output�sD	zParseTest._verify_parse_outputcCsn|j�}tjdd�}|j||�|jtd�|j}|j|�|jt	t
|d�dS)Nrr	ru�)rPrr
rS�Parser2r(rqrrr")rr(rrpr
r
r�test_parse_bytes�s	
zParseTest.test_parse_bytescCsa|j�}tjdd�}|j||�|jtjd�d�|j}|j|�dS)Nrr	z
iso-8859-1r)	rPrr
rSrrr2�decoder(rq)rr(rrpr
r
r�test_parse_str�s	zParseTest.test_parse_strcCsa|j�}tjdd�}|j||�tt�}|j|�|j}|j|�dS)Nrr	)	rPrr
rSrr2�	ParseFiler(rq)rr(r�filerpr
r
r�test_parse_files
	zParseTest.test_parse_filec	Csvtj�}tt�}|j|�|jtj��}|j|�WdQX|jtj|j	j
�tjj�dS)N)
rr
rr2rvr�errorroZErrorStringZ	exception�coderZXML_ERROR_FINISHED)rrrw�cmr
r
r�test_parse_agains
zParseTest.test_parse_againN)r$r%r&rPrQrSrqrsrurxr|r
r
r
rr'Zs V			&
r'c@s4eZdZdd�Zdd�Zdd�ZdS)�NamespaceSeparatorTestcCs.tj�tjdd�tjdd�dS)Nrr*)rr
)rr
r
r�
test_legals
z!NamespaceSeparatorTest.test_legalcCs�ytjdd�|j�Wn;tk
r[}z|jt|�d�WYdd}~XnXytjdd�|j�Wn;tk
r�}z|jt|�d�WYdd}~XnXdS)Nr�*z6ParserCreate() argument 2 must be str or None, not intztoo longzCnamespace_separator must be at most one character, omitted, or None)rr
�failrro�str�
ValueError)r�er
r
r�test_illegal sz#NamespaceSeparatorTest.test_illegalcCstjdd�dS)Nr�)rr
)rr
r
r�test_zero_length/s	z'NamespaceSeparatorTest.test_zero_lengthN)r$r%r&r~r�r�r
r
r
rr}sr}c@s(eZdZdd�Zdd�ZdS)�
InterningTestcs�tj�}g��fdd�}||_||_|jdd��d}|jt��d�x!�D]}|j||k�qmWdS)Ncs�j|�dS)N)r+)r-r=)�Lr
r�	collector@sz%InterningTest.test.<locals>.collectors<e> <e/> <e></e> </e>rr�)rr
r/r0rrro�len�
assertTrue)r�pr��tag�entryr
)r�r�test<s		

zInterningTest.testcCsmGdd�d�}tjdd�}d|_||�}|j|_|jtd�|j|jd�dS)Nc@s(eZdZdd�Zdd�ZdS)z7InterningTest.test_issue9402.<locals>.ExternalOutputtercSs||_d|_dS)N)r�
parser_result)rrr
r
rr)Ns	z@InterningTest.test_issue9402.<locals>.ExternalOutputter.__init__cSs+|jjd�}|jdd�|_dS)Nr��r)rZExternalEntityParserCreaterrr�)rrBr>rCrDZexternal_parserr
r
rrERszPInterningTest.test_issue9402.<locals>.ExternalOutputter.ExternalEntityRefHandlerN)r$r%r&r)rEr
r
r
r�ExternalOutputterMsr�rr	r)rr
rrErrr2ror�)rr�rr(r
r
r�test_issue9402Ks
	zInterningTest.test_issue9402N)r$r%r&r�r�r
r
r
rr�;sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zgd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�BufferTextTestcCs7g|_tj�|_d|j_|j|j_dS)Nr)�stuffrr
rrr3)rr
r
rr`s	zBufferTextTest.setUpc	Cs3|j|j|d||jtt|�f�dS)Nz%s
stuff    = %r
expected = %r)ror��mapr�)r�expectedZlabelr
r
r�checkfszBufferTextTest.checkcCs|jj|�dS)N)r�r+)rr;r
r
rr3ksz#BufferTextTest.CharacterDataHandlercCs]|jjd|�|jd�}|dkr>d|j_n|dkrYd|j_ndS)Nz<%s>zbuffer-text�yesr�nor)r�r+�getrr)rr-r.Zbtr
r
rr/nsz"BufferTextTest.StartElementHandlercCs|jjd|�dS)Nz</%s>)r�r+)rr-r
r
rr0vsz BufferTextTest.EndElementHandlercCs|jjd|�dS)Nz	<!--%s-->)r�r+)rr2r
r
rr<yszBufferTextTest.CommentHandlercCs1x*|D]"}t|j|t||��qWdS)N)rrr")rZhandlersr-r
r
r�setHandlers|s
zBufferTextTest.setHandlerscCs tj�}|j|j�dS)N)rr
�assertFalser)rrr
r
r�test_default_to_disabled�sz'BufferTextTest.test_default_to_disabledcCsC|j|jj�|jjdd�|j|jdgd�dS)Ns<a>1<b/>2<c/>3</a>rZ123z$buffered text not properly collapsed)r�rrrrror�)rr
r
r�test_buffering_enabled�sz%BufferTextTest.test_buffering_enabledc
CsU|jdg�|jjdd�|j|jdddddd	d
dgd�dS)
Nr/s9<a>1<b buffer-text='no'/>2
3<c buffer-text='yes'/>4
5</a>rz<a>�1z<b>�2�
�3z<c>z4
5z*buffering control not reacting as expected)r�rrrror�)rr
r
r�test1�s
zBufferTextTest.test1cCs0|jjdd�|j|jdgd�dS)Ns&<a>1<b/>&lt;2&gt;<c/>&#32;
&#x20;3</a>rz1<2> 
 3z$buffered text not properly collapsed)rrrror�)rr
r
r�test2�szBufferTextTest.test2cCsO|jdg�|jjdd�|j|jdddddd	gd
�dS)Nr/s<a>1<b/>2<c/>3</a>rz<a>r�z<b>r�z<c>r�z buffered text not properly split)r�rrrror�)rr
r
r�test3�s!zBufferTextTest.test3cCs[|jddg�d|j_|jjdd�|j|jddddd	d
g�dS)Nr/r0s<a>1<b/>2<c/>3</a>rz<a>z<b>z</b>z<c>z</c>z</a>)r�rr3rrror�)rr
r
r�test4�s
zBufferTextTest.test4cCsX|jddg�|jjdd�|j|jddddd	d
ddd
g	�dS)Nr/r0s<a>1<b></b>2<c/>3</a>rz<a>r�z<b>z</b>r�z<c>z</c>r�z</a>)r�rrrror�)rr
r
r�test5�szBufferTextTest.test5cCs^|jdddg�|jjdd�|j|jdddd	d
ddd
dg	d�dS)Nr<r0r/s<a>1<b/>2<c></c>345</a> rz<a>r�z<b>z</b>r�z<c>z</c>Z345z</a>z buffered text not properly split)r�rrrror�)rr
r
r�test6�s
zBufferTextTest.test6cCsj|jdddg�|jjdd�|j|jdddd	d
ddd
dddddg
d�dS)Nr<r0r/s,<a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> rz<a>r�z<b>z</b>r�z<c>z</c>r�z
<!--abc-->�4z
<!--def-->�5z</a>z buffered text not properly split)r�rrrror�)rr
r
r�test7�s
zBufferTextTest.test7N)r$r%r&rr�r3r/r0r<r�r�r�r�r�r�r�r�r�r�r
r
r
rr�_s 	r�c@s4eZdZdd�Zdd�Zdd�ZdS)�HandlerExceptionTestcCst|��dS)N)�RuntimeError)rr-r.r
r
rr/�sz(HandlerExceptionTest.StartElementHandlercCs8|jtjj|d�|�|j|d|�dS)Nrr)ro�os�path�basename)rr��filenameZfuncnamer
r
r�check_traceback_entry�s z*HandlerExceptionTest.check_traceback_entrycCstj�}|j|_y|jdd�|j�Wn�tk
r}z�|j|jdddd|jd�tj	|j
�}|jt|�d�|j|ddd	�|j|dd
d�|j|ddd
�t
j�r|jd|dd�nWYdd}~XnXdS)Ns<a><b><c/></b></a>rr�az*Expected RuntimeError for element 'a', butz	 found %r�ztest_pyexpat.py�test_exceptionz	pyexpat.cZStartElementrr/zcall_with_frame("StartElement")rr
r/rrr�r�ror=�	traceback�
extract_tb�
__traceback__r�r��	sysconfig�is_python_buildZassertIn)rrr�Zentriesr
r
rr��s&





z#HandlerExceptionTest.test_exceptionN)r$r%r&r/r�r�r
r
r
rr��sr�c@s@eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�PositionTestcCs|jd�dS)N�s)�	check_pos)rr-r.r
r
rr/�sz PositionTest.StartElementHandlercCs|jd�dS)Nr�)r�)rr-r
r
rr0�szPositionTest.EndElementHandlercCs�||jj|jj|jjf}|j|jt|j�kd�|j|j}|j||d||f�|jd7_dS)Nztoo many parser eventsz%Expected position %s, got position %sr)	rZCurrentByteIndexZCurrentLineNumberZCurrentColumnNumberr��uptor��
expected_listro)rZevent�posr�r
r
rr��s		zPositionTest.check_posc	Csntj�|_|j|j_|j|j_d|_ddddddg|_d}|jj|d�dS)Nrr�r�r�r�r�rr����s<a>
 <b>
  <c/>
 </b>
</a>)r�rrr)r�r�rr)r�r�r�r)r�rr�r�)r�r�r�r)r�r�r�r)rr
rr/r0r�r�rr)r�xmlr
r
rr��s		zPositionTest.testN)r$r%r&r/r0r�r�r
r
r
rr��sr�c@seZdZdd�ZdS)�
sf1296433Testcsnddd}Gdd�dt���fdd�}tj�}||_|jt|j|jd��dS)	Nz1<?xml version='1.0' encoding='iso8859'?><s>%s</s>r�ic@seZdZdS)zAsf1296433Test.test_parse_only_xml_data.<locals>.SpecificExceptionN)r$r%r&r
r
r
r�SpecificExceptionsr�cs
��dS)Nr
)r;)r�r
rrR	sz7sf1296433Test.test_parse_only_xml_data.<locals>.handler�iso8859)�	Exceptionrr
r3rrr�encode)rr�rRrr
)r�r�test_parse_only_xml_data�s	z&sf1296433Test.test_parse_only_xml_dataN)r$r%r&r�r
r
r
rr��sr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�ChardataBufferTestz.
    test setting of chardata buffer size
    cCs|j|jd�d�dS)Nir)ro�small_buffer_test)rr
r
r�test_1025_bytessz"ChardataBufferTest.test_1025_bytescCs|j|jd�d�dS)Ni�r)ror�)rr
r
r�test_1000_bytessz"ChardataBufferTest.test_1000_bytescCs�tj�}d|_|jt��d|_WdQX|jt��d|_WdQX|jttf��tjd|_WdQX|jt	��d|_WdQXdS)Nrrg�@���)
rr
rrr��buffer_size�
OverflowError�sys�maxsizer)rrr
r
r�test_wrong_sizes	z"ChardataBufferTest.test_wrong_sizecCs�ddd}ddd}tj�}|j|_d|_d|_d|_|j|�|j|jd�|j|_|j|jd�|j|�|j|jd�dS)Ns+<?xml version='1.0' encoding='iso8859'?><s>�ais</s>rrr)	rr
�counting_handlerr3r�r�nrrro)r�xml1�xml2rr
r
r�test_unchanged_size(s			

z&ChardataBufferTest.test_unchanged_sizecCs[ddd}dd}ddd}tj�}|j|_d|_d|_|j|jd�d	|_|j|d	�|j|jd�|j|jd�d	|_|j	|j�|j|jd�x$t
d
�D]}|j|d	�q�W|j|jd�d|_|j|j�|j|jd�|j|d�|j|jd�dS)
Ns+<?xml version='1.0' encoding='iso8859'?><a>r�i�bi�cs</a>rr�
r��)rr
r�r3rr�ror�rrr�r r�)rr�r�Zxml3r�ir
r
r�test_disabling_buffer?s.
					z(ChardataBufferTest.test_disabling_buffercCs|jd7_dS)Nr)r�)rr;r
r
rr�]sz#ChardataBufferTest.counting_handlercCsYdd|d}tj�}|j|_d|_d|_d|_|j|�|jS)Ns+<?xml version='1.0' encoding='iso8859'?><s>r�s</s>irr)rr
r�r3r�rr�rr)rZ
buffer_lenr�rr
r
rr�`s			
z$ChardataBufferTest.small_buffer_testcCs�ddd}dddd}tj�}|j|_d|_d|_|j|jd�d|_|j|d�|jd	9_|j|jd
�|j|d�|j|jd	�dS)Ns.<?xml version='1.0' encoding='iso8859'?><a><s>r�is
aaa</s><s>is</s></a>rrri)	rr
r�r3rr�ror�rr)rr�r�rr
r
r�test_change_size_1ks			z%ChardataBufferTest.test_change_size_1cCs�ddd}dddd}tj�}|j|_d|_d|_|j|jd�d	|_|j|d	�|jd
|_|j|jd�|j|d�|j|jd�dS)
Ns/<?xml version='1.0' encoding='iso8859'?><a>a<s>r�i�s
aaa</s><s>is</s></a>rirrir�)	rr
r�r3rr�ror�rr)rr�r�rr
r
r�test_change_size_2{s			z%ChardataBufferTest.test_change_size_2N)
r$r%r&�__doc__r�r�r�r�r�r�r�r�r�r
r
r
rr�sr�c@s(eZdZdd�Zdd�ZdS)�MalformedInputTestcCsud}tj�}y|j|d�|j�Wn>tjk
rp}z|jt|�d�WYdd}~XnXdS)Ns
Tz unclosed token: line 2, column 0)rr
rrr��
ExpatErrorror�)rr�rr�r
r
rr��szMalformedInputTest.test1c
CsHd}tj�}d}|jtj|��|j|d�WdQXdS)Ns<?xml version…='1.0'?>
z3XML declaration not well-formed: line 1, column \d+T)rr
ZassertRaisesRegexr�rr)rr�rZerr_patternr
r
rr��s
zMalformedInputTest.test2N)r$r%r&r�r�r
r
r
rr��s	r�c@s(eZdZdd�Zdd�ZdS)�ErrorMessageTestcCs(|jtjtjtjtj�dS)N)rorZXML_ERROR_SYNTAXZmessages�codes)rr
r
r�
test_codes�szErrorMessageTest.test_codescCs|d}tj�}y|j|d�|j�WnEtjk
rw}z"|j|jtjtj	�WYdd}~XnXdS)N�<T)
rr
rrr�r�rorzrr�ZXML_ERROR_UNCLOSED_TOKEN)rr�rr�r
r
r�test_expaterror�sz ErrorMessageTest.test_expaterrorN)r$r%r&r�r�r
r
r
rr��sr�c@s.eZdZdZdd�Zdd�ZdS)�ForeignDTDTestszE
    Tests for the UseForeignDTD method of expat parser objects.
    cs�g��fdd�}tj�}|jd�|jtj�||_|jd�|j�dg�g�dd�<tj�}|j�|jtj�||_|jd�|j�dg�dS)z�
        If UseForeignDTD is passed True and a document without an external
        entity reference is parsed, ExternalEntityRefHandler is first called
        with None for the public and system ids.
        cs�j||f�dS)Nr)r+)rBr>�	system_id�	public_id)�handler_call_argsr
r�resolve_entity�sz<ForeignDTDTests.test_use_foreign_dtd.<locals>.resolve_entityTs<?xml version='1.0'?><element/>N)NN)NN)rr
�
UseForeignDTD�SetParamEntityParsing�XML_PARAM_ENTITY_PARSING_ALWAYSrErrro)rr�rr
)r�r�test_use_foreign_dtd�s
	

	
z$ForeignDTDTests.test_use_foreign_dtdcsng��fdd�}tj�}|jd�|jtj�||_|jd�|j�dg�dS)	z�
        If UseForeignDTD is passed True and a document with an external
        entity reference is parsed, ExternalEntityRefHandler is called with
        the public and system ids from the document.
        cs�j||f�dS)Nr)r+)rBr>r�r�)r�r
rr��szCForeignDTDTests.test_ignore_use_foreign_dtd.<locals>.resolve_entityTs@<?xml version='1.0'?><!DOCTYPE foo PUBLIC 'bar' 'baz'><element/>�bar�bazN)r�r�)rr
r�r�r�rErrro)rr�rr
)r�r�test_ignore_use_foreign_dtd�s
	z+ForeignDTDTests.test_ignore_use_foreign_dtdN)r$r%r&r�r�r�r
r
r
rr��sr�c
Cs/tttttttttt	t
tt�dS)N)
rrr'r}r�r�r�r�r�r�r�r�r�r
r
r
r�	test_main�sr��__main__)�iorr�r�r�Zunittestr�Zxml.parsersrZxml.parsers.expatrZtest.supportrrZTestCaserr2r'r}r�r�r�r�r�r�r�r�r�r�r$r
r
r
r�<module>s0E�#$` z4