403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_pyexpat.cpython-36.pyc
3

�w2_j�@sJddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlm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
�Zedk�rFej�dS) �)�BytesION)�expat)�errors)�sortdictc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SetAttributeTestcCstjdd�|_dS)N�!)�namespace_separator)r�ParserCreate�parser)�self�r�6/opt/alt/python36/lib64/python3.6/test/test_pyexpat.py�setUpszSetAttributeTest.setUpcCs>|j|jjd�x(dD] }||j_|j|jjt|��qWdS)NFr��)rrrr)�assertIsr
�buffer_text�bool)r�xrrr
�test_buffer_texts
z!SetAttributeTest.test_buffer_textcCs>|j|jjd�x(dD] }||j_|j|jjt|��qWdS)NFrrr)rrrr)rr
Znamespace_prefixesr)rrrrr
�test_namespace_prefixess
z(SetAttributeTest.test_namespace_prefixescCs>|j|jjd�x(dD] }||j_|j|jjt|��qWdS)NFrrr)rrrr)rr
Zordered_attributesr)rrrrr
�test_ordered_attributes!s
z(SetAttributeTest.test_ordered_attributescCs>|j|jjd�x(dD] }||j_|j|jjt|��qWdS)NFrrr)rrrr)rr
Zspecified_attributesr)rrrrr
�test_specified_attributes's
z*SetAttributeTest.test_specified_attributescCs�|jt��d|j_WdQRX|jt��|jjWdQRX|jtt|jtd�d�|jt|jjtd�d�|jtt|jtd��dS)Nr�r)	�assertRaises�AttributeErrorr
Zreturns_unicode�	TypeError�setattr�range�__setattr__�getattr)rrrr
�test_invalid_attributes-sz(SetAttributeTest.test_invalid_attributesN)	�__name__�
__module__�__qualname__rrrrrr!rrrr
rs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@szeZdZGdd�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)rrrr
�__init__VszParseTest.Outputter.__init__cCs$|jjdt|�dt|��dS)NzStart element: � )r&�append�reprr)r�name�attrsrrr
�StartElementHandlerYsz'ParseTest.Outputter.StartElementHandlercCs|jjdt|��dS)Nz
End element: )r&r)r*)rr+rrr
�EndElementHandler]sz%ParseTest.Outputter.EndElementHandlercCs$|j�}|r |jjdt|��dS)NzCharacter data: )�stripr&r)r*)r�datarrr
�CharacterDataHandler`sz(ParseTest.Outputter.CharacterDataHandlercCs$|jjdt|�dt|��dS)NzPI: r()r&r)r*)r�targetr0rrr
�ProcessingInstructionHandleresz0ParseTest.Outputter.ProcessingInstructionHandlercCs$|jjdt|�dt|��dS)Nz	NS decl: r()r&r)r*)r�prefixZurirrr
�StartNamespaceDeclHandlerhsz-ParseTest.Outputter.StartNamespaceDeclHandlercCs|jjdt|��dS)NzEnd of NS decl: )r&r)r*)rr4rrr
�EndNamespaceDeclHandlerksz+ParseTest.Outputter.EndNamespaceDeclHandlercCs|jjd�dS)NzStart of CDATA section)r&r))rrrr
�StartCdataSectionHandlernsz,ParseTest.Outputter.StartCdataSectionHandlercCs|jjd�dS)NzEnd of CDATA section)r&r))rrrr
�EndCdataSectionHandlerqsz*ParseTest.Outputter.EndCdataSectionHandlercCs|jjdt|��dS)Nz	Comment: )r&r)r*)r�textrrr
�CommentHandlertsz"ParseTest.Outputter.CommentHandlercGs"|\}}}}|jjd|f�dS)NzNotation declared: %s)r&r))r�argsr+�baseZsysidZpubidrrr
�NotationDeclHandlerwsz'ParseTest.Outputter.NotationDeclHandlercGs$|\}}}}}|jjd|f�dS)NzUnparsed entity decl: %s)r&r))rr;Z
entityNamer<ZsystemIdZpublicIdZnotationNamerrr
�UnparsedEntityDeclHandler{sz-ParseTest.Outputter.UnparsedEntityDeclHandlercCs|jjd�dS)NzNot standaloner)r&r))rrrr
�NotStandaloneHandlersz(ParseTest.Outputter.NotStandaloneHandlercGs*|\}}}}|jjd|dd�f�dS)NzExternal entity ref: %sr)r&r))rr;�contextr<�sysId�pubIdrrr
�ExternalEntityRefHandler�sz,ParseTest.Outputter.ExternalEntityRefHandlercGs|jjd|f�dS)Nz
Start doctyper)r&r))rr;rrr
�StartDoctypeDeclHandler�sz+ParseTest.Outputter.StartDoctypeDeclHandlercCs|jjd�dS)NzEnd doctyper)r&r))rrrr
�EndDoctypeDeclHandler�sz)ParseTest.Outputter.EndDoctypeDeclHandlercGs|jjd|f�dS)NzEntity declarationr)r&r))rr;rrr
�EntityDeclHandler�sz%ParseTest.Outputter.EntityDeclHandlercGs|jjd|f�dS)NzXML declarationr)r&r))rr;rrr
�XmlDeclHandler�sz"ParseTest.Outputter.XmlDeclHandlercGs|jjd|f�dS)NzElement declarationr)r&r))rr;rrr
�ElementDeclHandler�sz&ParseTest.Outputter.ElementDeclHandlercGs|jjd|f�dS)NzAttribute list declarationr)r&r))rr;rrr
�AttlistDeclHandler�sz&ParseTest.Outputter.AttlistDeclHandlercGs|jjd|f�dS)NzSkipped entityr)r&r))rr;rrr
�SkippedEntityHandler�sz(ParseTest.Outputter.SkippedEntityHandlercCsdS)Nr)r�userDatarrr
�DefaultHandler�sz"ParseTest.Outputter.DefaultHandlercCsdS)Nr)rrKrrr
�DefaultHandlerExpand�sz(ParseTest.Outputter.DefaultHandlerExpandN)r"r#r$r'r-r.r1r3r5r6r7r8r:r=r>r?rCrDrErFrGrHrIrJrLrMrrrr
�	OutputterUs.rNr-r.r1r3r>r=r5r6r:r7r8rLrMr?rCrDrErFrGrHrIrJcCs&x |jD]}t||t||��qWdS)z{
        Set each of the callbacks defined on handler and named in
        self.handler_names on the given parser.
        N)�
handler_namesrr )rr
�handlerr+rrr
�_hookup_callbacks�szParseTest._hookup_callbackscCsvd,dddd.dd
dddffffd0d2dd4d6ddddddddd d!d"d#d$d%d&d8d)d*g}x"t||�D]\}}|j||�qZWdS)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'�rSrTr)rRrd�rVrWNr)rUre�rXrZr[Nr)rYrf�rXr\r[Nr)rYrg�r^rr_NNNN)r]rh�r`rNNraNN)r]ri�rcr)rbrj)�zip�assertEqual)r�
operationsZexpected_operationsZ	operationZexpected_operationrrr
�_verify_parse_output�sDzParseTest._verify_parse_outputcCsP|j�}tjdd�}|j||�|jtd�|j}|j|�|jt	t
|d�dS)Nr)rru�)rNrr	rQ�Parser0r&rnrrr )rr&r
rmrrr
�test_parse_bytes�s
zParseTest.test_parse_bytescCsF|j�}tjdd�}|j||�|jtjd�d�|j}|j|�dS)Nr)rz
iso-8859-1r)	rNrr	rQror0�decoder&rn)rr&r
rmrrr
�test_parse_str�szParseTest.test_parse_strcCsF|j�}tjdd�}|j||�tt�}|j|�|j}|j|�dS)Nr)r)	rNrr	rQrr0�	ParseFiler&rn)rr&r
�filermrrr
�test_parse_file�s
zParseTest.test_parse_filec
CsZtj�}tt�}|j|�|jtj��}|j|�WdQRX|jtj|j	j
�tjj�dS)N)
rr	rr0rsr�errorrlZErrorStringZ	exception�coderZXML_ERROR_FINISHED)rr
rt�cmrrr
�test_parse_agains
zParseTest.test_parse_againN)r"r#r$rNrOrQrnrprrruryrrrr
r%Ts V
&
r%c@s$eZdZdd�Zdd�Zdd�ZdS)�NamespaceSeparatorTestcCs$tj�tjdd�tjdd�dS)N)rr()rr	)rrrr
�
test_legalsz!NamespaceSeparatorTest.test_legalcCs�ytjdd�|j�Wn2tk
rJ}z|jt|�d�WYdd}~XnXytjdd�|j�Wn2tk
r�}z|jt|�d�WYdd}~XnXdS)N�*)rz6ParserCreate() argument 2 must be str or None, not intztoo longzCnamespace_separator must be at most one character, omitted, or None)rr	�failrrl�str�
ValueError)r�errr
�test_illegals

z#NamespaceSeparatorTest.test_illegalcCstjdd�dS)N�)r)rr	)rrrr
�test_zero_length)s	z'NamespaceSeparatorTest.test_zero_lengthN)r"r#r$r{r�r�rrrr
rzsrzc@seZdZdd�Zdd�ZdS)�
InterningTestcshtj�}g��fdd�}||_||_|jdd��d}|jt��d�x�D]}|j||k�qNWdS)Ncs�j|�dS)N)r))r+r;)�Lrr
�	collector:sz%InterningTest.test.<locals>.collectors<e> <e/> <e></e> </e>rr�)rr	r-r.rorl�len�
assertTrue)r�pr��tag�entryr)r�r
�test6s
zInterningTest.testcCsNGdd�d�}tjdd�}d|_||�}|j|_|jtd�|j|jd�dS)Nc@seZdZdd�Zdd�ZdS)z7InterningTest.test_issue9402.<locals>.ExternalOutputtercSs||_d|_dS)N)r
�
parser_result)rr
rrr
r'Hsz@InterningTest.test_issue9402.<locals>.ExternalOutputter.__init__cSs|jjd�}|jdd�|_dS)Nr��r)r
ZExternalEntityParserCreateror�)rr@r<rArBZexternal_parserrrr
rCLszPInterningTest.test_issue9402.<locals>.ExternalOutputter.ExternalEntityRefHandlerN)r"r#r$r'rCrrrr
�ExternalOutputterGsr�r)rr)rr	rrCror0rlr�)rr�r
r&rrr
�test_issue9402Es
zInterningTest.test_issue9402N)r"r#r$r�r�rrrr
r�5sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zgfd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�BufferTextTestcCs&g|_tj�|_d|j_|j|j_dS)Nr)�stuffrr	r
rr1)rrrr
rZs
zBufferTextTest.setUpc	Cs&|j|j|d||jtt|�f�dS)Nz%s
stuff    = %r
expected = %r)rlr��mapr~)r�expectedZlabelrrr
�check`s
zBufferTextTest.checkcCs|jj|�dS)N)r�r))rr9rrr
r1esz#BufferTextTest.CharacterDataHandlercCs@|jjd|�|jd�}|dkr,d|j_n|dkr<d|j_dS)Nz<%s>zbuffer-text�yesr�nor)r�r)�getr
r)rr+r,Zbtrrr
r-hs

z"BufferTextTest.StartElementHandlercCs|jjd|�dS)Nz</%s>)r�r))rr+rrr
r.psz BufferTextTest.EndElementHandlercCs|jjd|�dS)Nz	<!--%s-->)r�r))rr0rrr
r:sszBufferTextTest.CommentHandlercCs&x |D]}t|j|t||��qWdS)N)rr
r )rZhandlersr+rrr
�setHandlersvs
zBufferTextTest.setHandlerscCstj�}|j|j�dS)N)rr	�assertFalser)rr
rrr
�test_default_to_disabledzsz'BufferTextTest.test_default_to_disabledcCs2|j|jj�|jjdd�|j|jdgd�dS)Ns<a>1<b/>2<c/>3</a>rZ123z$buffered text not properly collapsed)r�r
rrorlr�)rrrr
�test_buffering_enabled~sz%BufferTextTest.test_buffering_enabledc
Cs>|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�r
rorlr�)rrrr
�test1�s
zBufferTextTest.test1cCs$|jjdd�|j|jdgd�dS)Ns&<a>1<b/>&lt;2&gt;<c/>&#32;
&#x20;3</a>rz1<2> 
 3z$buffered text not properly collapsed)r
rorlr�)rrrr
�test2�szBufferTextTest.test2cCs:|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�r
rorlr�)rrrr
�test3�szBufferTextTest.test3cCsB|jddg�d|j_|jjdd�|j|jddddd	d
g�dS)Nr-r.s<a>1<b/>2<c/>3</a>rz<a>z<b>z</b>z<c>z</c>z</a>)r�r
r1rorlr�)rrrr
�test4�s
zBufferTextTest.test4cCs@|jddg�|jjdd�|j|jddddd	d
ddd
g	�dS)Nr-r.s<a>1<b></b>2<c/>3</a>rz<a>r�z<b>z</b>r�z<c>z</c>r�z</a>)r�r
rorlr�)rrrr
�test5�szBufferTextTest.test5cCsD|jdddg�|jjdd�|j|jdddd	d
ddd
dg	d�dS)Nr:r.r-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�r
rorlr�)rrrr
�test6�szBufferTextTest.test6cCsL|jdddg�|jjdd�|j|jdddd	d
ddd
dddddg
d�dS)Nr:r.r-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�r
rorlr�)rrrr
�test7�szBufferTextTest.test7N)r"r#r$rr�r1r-r.r:r�r�r�r�r�r�r�r�r�r�rrrr
r�Ys 	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�HandlerExceptionTestcCst|��dS)N)�RuntimeError)rr+r,rrr
r-�sz(HandlerExceptionTest.StartElementHandlercCs,|jtjj|d�|�|j|d|�dS)Nrr)rl�os�path�basename)rr��filename�funcnamerrr
�check_traceback_entry�sz*HandlerExceptionTest.check_traceback_entrycCs�tj�}|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�WYdd}~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-ror}r�rlr;�	traceback�
extract_tb�
__traceback__r�r��	sysconfig�is_python_buildZassertIn)rr
r�Zentriesrrr
r��s&


z#HandlerExceptionTest.test_exceptionN)r"r#r$r-r�r�rrrr
r��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�PositionTestcCs|jd�dS)N�s)�	check_pos)rr+r,rrr
r-�sz PositionTest.StartElementHandlercCs|jd�dS)Nr�)r�)rr+rrr
r.�szPositionTest.EndElementHandlercCsd||jj|jj|jjf}|j|jt|j�kd�|j|j}|j||d||f�|jd7_dS)Nztoo many parser eventsz%Expected position %s, got position %sr)	r
ZCurrentByteIndexZCurrentLineNumberZCurrentColumnNumberr��uptor��
expected_listrl)rZevent�posr�rrr
r��s
zPositionTest.check_posc	CsLtj�|_|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	r
r-r.r�r�ro)r�xmlrrr
r��s


zPositionTest.testN)r"r#r$r-r.r�r�rrrr
r��sr�c@seZdZdd�ZdS)�
sf1296433TestcsPddd}Gdd�dt���fdd�}tj�}||_|jt|j|jd��dS)	Nz1<?xml version='1.0' encoding='iso8859'?><s>%s</s>r�ic@seZdZdS)zAsf1296433Test.test_parse_only_xml_data.<locals>.SpecificExceptionN)r"r#r$rrrr
�SpecificExceptionsr�cs��dS)Nr)r9)r�rr
rPsz7sf1296433Test.test_parse_only_xml_data.<locals>.handler�iso8859)�	Exceptionrr	r1rro�encode)rr�rPr
r)r�r
�test_parse_only_xml_data�sz&sf1296433Test.test_parse_only_xml_dataN)r"r#r$r�rrrr
r��sr�c@sXeZdZdZdd�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)rl�small_buffer_test)rrrr
�test_1025_bytessz"ChardataBufferTest.test_1025_bytescCs|j|jd�d�dS)Ni�r)rlr�)rrrr
�test_1000_bytessz"ChardataBufferTest.test_1000_bytescCs�tj�}d|_|jt��d|_WdQRX|jt��d|_WdQRX|jttf��tjd|_WdQRX|jt	��d|_WdQRXdS)Nrrg�@���)
rr	rrr�buffer_size�
OverflowError�sys�maxsizer)rr
r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_handlerr1r�r�nrorl)r�xml1�xml2r
rrr
�test_unchanged_size"s

z&ChardataBufferTest.test_unchanged_sizecCsddd}dd}ddd}tj�}|j|_d|_d|_|j|jd�d	|_|j|d	�|j|jd�|j|jd�d	|_|j	|j�|j|jd�xt
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�r1rr�rlr�ror�rr�)rr�r�Zxml3r
�irrr
�test_disabling_buffer9s.z(ChardataBufferTest.test_disabling_buffercCs|jd7_dS)Nr)r�)rr9rrr
r�Wsz#ChardataBufferTest.counting_handlercCsBdd|d}tj�}|j|_d|_d|_d|_|j|�|jS)Ns+<?xml version='1.0' encoding='iso8859'?><s>r�s</s>irr)rr	r�r1r�rr�ro)rZ
buffer_lenr�r
rrr
r�Zs
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�r1rr�rlr�ro)rr�r�r
rrr
�test_change_size_1es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�r1rr�rlr�ro)rr�r�r
rrr
�test_change_size_2usz%ChardataBufferTest.test_change_size_2N)
r"r#r$�__doc__r�r�r�r�r�r�r�r�r�rrrr
r�sr�c@seZdZdd�Zdd�ZdS)�MalformedInputTestcCs^d}tj�}y|j|d�|j�Wn4tjk
rX}z|jt|�d�WYdd}~XnXdS)Ns
Tz unclosed token: line 2, column 0)rr	ror}�
ExpatErrorrlr~)rr�r
r�rrr
r��szMalformedInputTest.test1c
Cs:d}tj�}d}|jtj|��|j|d�WdQRXdS)Ns<?xml version…='1.0'?>
z3XML declaration not well-formed: line 1, column \d+T)rr	ZassertRaisesRegexr�ro)rr�r
Zerr_patternrrr
r��s
zMalformedInputTest.test2N)r"r#r$r�r�rrrr
r��s	r�c@seZdZdd�Zdd�ZdS)�ErrorMessageTestcCs |jtjtjtjtj�dS)N)rlrZXML_ERROR_SYNTAXZmessages�codes)rrrr
�
test_codes�szErrorMessageTest.test_codescCsdd}tj�}y|j|d�|j�Wn:tjk
r^}z|j|jtjtj	�WYdd}~XnXdS)N�<T)
rr	ror}r�rlrwrr�ZXML_ERROR_UNCLOSED_TOKEN)rr�r
r�rrr
�test_expaterror�sz ErrorMessageTest.test_expaterrorN)r"r#r$r�r�rrrr
r��sr�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))r@r<�	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_ALWAYSrCrorl)rr�r
r)r�r
�test_use_foreign_dtd�s


z$ForeignDTDTests.test_use_foreign_dtdcsPg��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))r@r<r�r�)r�rr
r��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�rCrorl)rr�r
r)r�r
�test_ignore_use_foreign_dtd�s
z+ForeignDTDTests.test_ignore_use_foreign_dtdN)r"r#r$r�r�r�rrrr
r��sr��__main__)�iorr�r�r�Zunittestr�Zxml.parsersrZxml.parsers.expatrZtest.supportrZTestCaserr0r%rzr�r�r�r�r�r�r�r�r�r"�mainrrrr
�<module>s0??#$` z4


Youez - 2016 - github.com/yon3zu
LinuXploit