
    <e@k                     h   d dl mZ d dlZd dlZd dlZd dlZd dlZd dlZd dlm	Z	 d dl
mZ d dlmZmZmZ  G d dej                  ZdZ G d	 d
ej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  Zedk    r ej                     dS dS )     )BytesION)expat)errors)sortdictis_emscriptenis_wasic                   2    e Zd Zd Zd Zd Zd Zd Zd ZdS )SetAttributeTestc                 :    t          j        d          | _        d S N!namespace_separator)r   ParserCreateparserselfs    (/usr/lib/python3.11/test/test_pyexpat.pysetUpzSetAttributeTest.setUp   s    (SAAA    c                     |                      | j        j        d           dD ];}|| j        _        |                      | j        j        t          |                     <d S NF)r         r   )assertIsr   buffer_textboolr   xs     r   test_buffer_textz!SetAttributeTest.test_buffer_text   s`    dk-u555 	< 	<A&'DK#MM$+1477;;;;	< 	<r   c                     |                      | j        j        d           dD ];}|| j        _        |                      | j        j        t          |                     <d S r   )r   r   namespace_prefixesr   r   s     r   test_namespace_prefixesz(SetAttributeTest.test_namespace_prefixes   d    dk4e<<< 	C 	CA-.DK*MM$+8$q''BBBB	C 	Cr   c                     |                      | j        j        d           dD ];}|| j        _        |                      | j        j        t          |                     <d S r   )r   r   ordered_attributesr   r   s     r   test_ordered_attributesz(SetAttributeTest.test_ordered_attributes"   r$   r   c                     |                      | j        j        d           dD ];}|| j        _        |                      | j        j        t          |                     <d S r   )r   r   specified_attributesr   r   s     r   test_specified_attributesz*SetAttributeTest.test_specified_attributes(   sd    dk6>>> 	E 	EA/0DK,MM$+:DGGDDDD	E 	Er   c                 8   |                      t                    5  d| j        _        d d d            n# 1 swxY w Y   |                      t                    5  | j        j         d d d            n# 1 swxY w Y   |                      t          t
          | j        t          d          d           |                      t          | j        j        t          d          d           |                      t          t          | j        t          d                     d S )Nr      r   )	assertRaisesAttributeErrorr   returns_unicode	TypeErrorsetattrrange__setattr__getattrr   s    r   test_invalid_attributesz(SetAttributeTest.test_invalid_attributes.   s\   ~.. 	, 	,*+DK'	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	, 	,~.. 	( 	(K''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	)Wdk5::qIII)T[%<eCjj!LLL)Wdk5::FFFFFs   488A22A69A6N)	__name__
__module____qualname__r   r    r#   r'   r*   r5    r   r   r
   r
      s        B B B< < <C C CC C CE E E	G 	G 	G 	G 	Gr   r
   s  <?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                   T    e Zd Z G d d          Zg dZd Zd Zd Zd Zd Z	d	 Z
d
S )	ParseTestc                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )ParseTest.Outputterc                     g | _         d S N)outr   s    r   __init__zParseTest.Outputter.__init__W   s    DHHHr   c                     | j                             dt          |          z   dz   t          |          z              d S )NzStart element:  )r@   appendreprr   r   nameattrss      r   StartElementHandlerz'ParseTest.Outputter.StartElementHandlerZ   sE    HOO-T

:S@$UOO, - - - - -r   c                 Z    | j                             dt          |          z              d S )NzEnd element: r@   rD   rE   r   rG   s     r   EndElementHandlerz%ParseTest.Outputter.EndElementHandler^   s'    HOOOd4jj899999r   c                     |                                 }|r,| j                            dt          |          z              d S d S )NzCharacter data: )stripr@   rD   rE   r   datas     r   CharacterDataHandlerz(ParseTest.Outputter.CharacterDataHandlera   sJ    ::<<D A 2T$ZZ ?@@@@@A Ar   c                     | j                             dt          |          z   dz   t          |          z              d S )NzPI: rC   rK   )r   targetrQ   s      r   ProcessingInstructionHandlerz0ParseTest.Outputter.ProcessingInstructionHandlerf   s7    HOOFT&\\1C7$t**DEEEEEr   c                     | j                             dt          |          z   dz   t          |          z              d S )Nz	NS decl: rC   rK   )r   prefixuris      r   StartNamespaceDeclHandlerz-ParseTest.Outputter.StartNamespaceDeclHandleri   s7    HOOK$v,,6<tCyyHIIIIIr   c                 Z    | j                             dt          |          z              d S )NzEnd of NS decl: rK   )r   rW   s     r   EndNamespaceDeclHandlerz+ParseTest.Outputter.EndNamespaceDeclHandlerl   s(    HOO.f=>>>>>r   c                 :    | j                             d           d S )NStart of CDATA sectionr@   rD   r   s    r   StartCdataSectionHandlerz,ParseTest.Outputter.StartCdataSectionHandlero   s    HOO455555r   c                 :    | j                             d           d S )NEnd of CDATA sectionr^   r   s    r   EndCdataSectionHandlerz*ParseTest.Outputter.EndCdataSectionHandlerr   s    HOO233333r   c                 Z    | j                             dt          |          z              d S )Nz	Comment: rK   r   texts     r   CommentHandlerz"ParseTest.Outputter.CommentHandleru   s'    HOOK$t**455555r   c                 N    |\  }}}}| j                             d|           d S )NzNotation declared: r^   )r   argsrG   basesysidpubids         r   NotationDeclHandlerz'ParseTest.Outputter.NotationDeclHandlerx   s1    '+$D$uHOOOdd<=====r   c                 P    |\  }}}}}| j                             d|           d S )NzUnparsed entity decl: r^   )r   rh   
entityNameri   systemIdpublicIdnotationNames          r   UnparsedEntityDeclHandlerz-ParseTest.Outputter.UnparsedEntityDeclHandler|   s3    AE>Jh,HOOO?@@@@@r   c                 :    | j                             d           dS )NNot standaloner   r^   r   s    r   NotStandaloneHandlerz(ParseTest.Outputter.NotStandaloneHandler   s    HOO,---1r   c                 ^    |\  }}}}| j                             d|dd                     dS )NzExternal entity ref: r   r^   )r   rh   contextri   sysIdpubIds         r   ExternalEntityRefHandlerz,ParseTest.Outputter.ExternalEntityRefHandler   s8    *.'GT5%HOOOQRRBCCC1r   c                 >    | j                             d|f           dS )NStart doctyper   r^   r   rh   s     r   StartDoctypeDeclHandlerz+ParseTest.Outputter.StartDoctypeDeclHandler   s     HOO_d34441r   c                 :    | j                             d           dS )NEnd doctyper   r^   r   s    r   EndDoctypeDeclHandlerz)ParseTest.Outputter.EndDoctypeDeclHandler   s    HOOM***1r   c                 >    | j                             d|f           dS )NEntity declarationr   r^   r}   s     r   EntityDeclHandlerz%ParseTest.Outputter.EntityDeclHandler   s!    HOO1489991r   c                 >    | j                             d|f           dS )NXML declarationr   r^   r}   s     r   XmlDeclHandlerz"ParseTest.Outputter.XmlDeclHandler   s!    HOO.56661r   c                 >    | j                             d|f           dS )NElement declarationr   r^   r}   s     r   ElementDeclHandlerz&ParseTest.Outputter.ElementDeclHandler   s!    HOO2D9:::1r   c                 >    | j                             d|f           dS )NAttribute list declarationr   r^   r}   s     r   AttlistDeclHandlerz&ParseTest.Outputter.AttlistDeclHandler   s!    HOO94@AAA1r   c                 >    | j                             d|f           dS )NSkipped entityr   r^   r}   s     r   SkippedEntityHandlerz(ParseTest.Outputter.SkippedEntityHandler   s!    HOO-t45551r   c                     d S r?   r9   r   userDatas     r   DefaultHandlerz"ParseTest.Outputter.DefaultHandler       Dr   c                     d S r?   r9   r   s     r   DefaultHandlerExpandz(ParseTest.Outputter.DefaultHandlerExpand   r   r   N)r6   r7   r8   rA   rI   rM   rR   rU   rY   r[   r_   rb   rf   rl   rr   ru   rz   r~   r   r   r   r   r   r   r   r   r9   r   r   	Outputterr=   V   sy       	 	 		- 	- 	-	: 	: 	:	A 	A 	A
	F 	F 	F	J 	J 	J	? 	? 	?	6 	6 	6	4 	4 	4	6 	6 	6	> 	> 	>	A 	A 	A	 	 		 	 	
	 	 		 	 		 	 		 	 		 	 		 	 		 	 		 	 		 	 	 	 	r   r   )rI   rM   rR   rU   rr   rl   rY   r[   rf   r_   rb   r   r   ru   rz   r~   r   r   r   r   r   r   c           	      X    | j         D ]!}t          ||t          ||                     "dS )z{
        Set each of the callbacks defined on handler and named in
        self.handler_names on the given parser.
        N)handler_namesr1   r4   )r   r   handlerrG   s       r   _hookup_callbackszParseTest._hookup_callbacks   s?    
 & 	: 	:DFD''4"8"89999	: 	:r   c                 f    g d}t          ||          D ]\  }}|                     ||           d S )N))r   )z1.0
iso-8859-1r   z,PI: 'xml-stylesheet' 'href="stylesheet.css"'zComment: ' comment data 'rt   )r|   )
quotationszquotations.dtdNr   )r   )root)r   r   Nr9   )r   )r   attr1CDATANr   )r   )r   attr2r   Nr   z<Notation declared: ('notation', None, 'notation.jpeg', None))r   )acircr      âNNNN)r   )external_entityr   NNzentity.fileNNzPUnparsed entity decl: ('unparsed_entity', None, 'entity.file', None, 'notation')rt   r   u?   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'zEnd of NS decl: 'myns'zStart element: 'sub2' {}r]   z+Character data: 'contents of CDATA section'ra   zEnd element: 'sub2'z0External entity ref: (None, 'entity.file', None))r   )skipped_entityr   u   Character data: 'µ'zEnd element: 'root')zipassertEqual)r   
operationsexpected_operations	operationexpected_operations        r   _verify_parse_outputzParseTest._verify_parse_output   s[    !
 !
 !
D .1=P-Q-Q 	< 	<)I)Y(:;;;;	< 	<r   c                 6   |                                  }t          j        d          }|                     ||           |                    t
          d           |j        }|                     |           |                     t          t          |d           d S )Nr   r   Tu   )r   r   r   r   ParserQ   r@   r   r-   r.   r4   r   r@   r   r   s       r   test_parse_byteszParseTest.test_parse_bytes   s    nn#<<<vs+++T4   W
!!*---.'68DDDDDr   c                    |                                  }t          j        d          }|                     ||           |                    t
                              d          d           |j        }|                     |           d S )Nr   r   r   T)	r   r   r   r   r   rQ   decoder@   r   r   s       r   test_parse_strzParseTest.test_parse_str   s{    nn#<<<vs+++T[[..555W
!!*-----r   c                    |                                  }t          j        d          }|                     ||           t	          t
                    }|                    |           |j        }|                     |           d S r   )	r   r   r   r   r   rQ   	ParseFiler@   r   )r   r@   r   filer   s        r   test_parse_filezParseTest.test_parse_file   sz    nn#<<<vs+++t}}W
!!*-----r   c                    t          j                    }t          t                    }|                    |           |                     t           j                  5 }|                    |           d d d            n# 1 swxY w Y   |                     t          j        |j	        j
                  t           j        j                   d S r?   )r   r   r   rQ   r   r-   errorr   ErrorString	exceptioncoder   XML_ERROR_FINISHED)r   r   r   cms       r   test_parse_againzParseTest.test_parse_again  s    #%%t}} u{++ 	#rT"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#*2<+<==,9	; 	; 	; 	; 	;s   A>>BBN)r6   r7   r8   r   r   r   r   r   r   r   r   r9   r   r   r;   r;   U   s        S S S S S S S Sj

 

 

M: : :$< $< $<L
E 
E 
E. . .
. 
. 
.
; 
; 
; 
; 
;r   r;   c                        e Zd Zd Zd Zd ZdS )NamespaceSeparatorTestc                     t          j                     t          j        d            t          j        d           d S )Nr   rC   r   r   r   s    r   
test_legalz!NamespaceSeparatorTest.test_legal  sA     	t4444s333333r   c                    	 t          j        d           |                                  n:# t          $ r-}|                     t          |          d           Y d }~nd }~ww xY w	 t          j        d           |                                  d S # t          $ r.}|                     t          |          d           Y d }~d S d }~ww xY w)N*   r   zJParserCreate() argument 'namespace_separator' must be str or None, not intztoo longzCnamespace_separator must be at most one character, omitted, or None)r   r   failr0   r   str
ValueError)r   es     r   test_illegalz#NamespaceSeparatorTest.test_illegal  s*   	^26666IIKKKK 	^ 	^ 	^SVV\^ ^ ^ ^ ^ ^ ^ ^	^	W:>>>>IIKKKKK 	W 	W 	WSVVUW W W W W W W W W	Ws,   ), 
A##AA#')B 
C
#CC
c                 0    t          j        d           d S )N r   r   r   s    r   test_zero_lengthz'NamespaceSeparatorTest.test_zero_length*  s     	r222222r   N)r6   r7   r8   r   r   r   r9   r   r   r   r     sD        4 4 4W W W	3 	3 	3 	3 	3r   r   c                       e Zd Zd Zd ZdS )InterningTestc                    t          j                    }g fd}||_        ||_        |                    dd           d         }|                     t                    d           D ]}|                     ||u            d S )Nc                 2                         |            d S r?   rD   )rG   rh   Ls     r   	collectorz%InterningTest.test.<locals>.collector;  s    HHTNNNNNr   s   <e> <e/> <e></e> </e>Tr      )r   r   rI   rM   r   r   len
assertTrue)r   pr   tagentryr   s        @r   testzInterningTest.test7  s      	 	 	 	 	 )'	($///dQ### 	* 	*EOOC5L))))	* 	*r   c                      G d d          }t          j        d          }d|_         ||          }|j        |_        |                    t
          d           |                     |j        d           d S )Nc                       e Zd Zd Zd ZdS )7InterningTest.test_issue9402.<locals>.ExternalOutputterc                 "    || _         d | _        d S r?   )r   parser_resultr   r   s     r   rA   z@InterningTest.test_issue9402.<locals>.ExternalOutputter.__init__I  s    $%)"""r   c                 p    | j                             d          }|                    dd          | _        dS )Nr   r   Tr   )r   ExternalEntityParserCreater   r   )r   rw   ri   rx   ry   external_parsers         r   rz   zPInterningTest.test_issue9402.<locals>.ExternalOutputter.ExternalEntityRefHandlerM  s4    "&+"H"H"L"L%4%:%:3%E%E"qr   N)r6   r7   r8   rA   rz   r9   r   r   ExternalOutputterr   H  s2        * * *    r   r   r   r   r   T)r   r   r   rz   r   rQ   r   r   )r   r   r   r@   s       r   test_issue9402zInterningTest.test_issue9402F  s    	 	 	 	 	 	 	 	 #<<<''*-*F'T4   *A.....r   N)r6   r7   r8   r   r   r9   r   r   r   r   6  s2        * * */ / / / /r   r   c                   r    e Zd Zd Zd Zd Zd Zd Zd Zg fdZ	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd ZdS )BufferTextTestc                 ~    g | _         t          j                    | _        d| j        _        | j        | j        _        d S Nr   )stuffr   r   r   r   rR   r   s    r   r   zBufferTextTest.setUp[  s6    
(**"#+/+D(((r   c                 ~    |                      | j        ||d| j        dt          t          |                     d S )Nz
stuff    = z
expected = )r   r   mapr   )r   expectedlabels      r   checkzBufferTextTest.checka  sM    X55$***c#x&8&8&8:	; 	; 	; 	; 	;r   c                 :    | j                             |           d S r?   r   rD   rd   s     r   rR   z#BufferTextTest.CharacterDataHandlerf  s    
$r   c                     | j                             d|z             |                    d          }|dk    rd| j        _        d S |dk    rd| j        _        d S d S )Nz<%s>zbuffer-textyesr   nor   )r   rD   getr   r   )r   rG   rH   bts       r   rI   z"BufferTextTest.StartElementHandleri  sf    
&4-(((YY}%%;;&'DK###4ZZ&'DK### Zr   c                 @    | j                             d|z             d S )Nz</%s>r   rL   s     r   rM   z BufferTextTest.EndElementHandlerq  s"    
'D.)))))r   c                 @    | j                             d|z             d S )Nz	<!--%s-->r   rP   s     r   rf   zBufferTextTest.CommentHandlert  s#    
+,-----r   c           	      X    |D ]&}t          | j        |t          | |                     'd S r?   )r1   r   r4   )r   handlersrG   s      r   setHandlerszBufferTextTest.setHandlersw  s<     	< 	<DDKwtT':':;;;;	< 	<r   c                 `    t          j                    }|                     |j                   d S r?   )r   r   assertFalser   r   s     r   test_default_to_disabledz'BufferTextTest.test_default_to_disabled{  s-    #%%+,,,,,r   c                     |                      | j        j                   | j                            dd           |                     | j        dgd           d S )N   <a>1<b/>2<c/>3</a>T123$buffered text not properly collapsed)r   r   r   r   r   r   r   s    r   test_buffering_enabledz%BufferTextTest.test_buffering_enabled  sd    /000/666eW?	A 	A 	A 	A 	Ar   c                     |                      dg           | j                            dd           |                     | j        g dd           d S )NrI   s9   <a>1<b buffer-text='no'/>2
3<c buffer-text='yes'/>4
5</a>T)<a>1<b>2
3<c>z4
5z*buffering control not reacting as expectedr   r   r   r   r   r   s    r   test1zBufferTextTest.test1  sm     	/0111XZ^___KKKE	G 	G 	G 	G 	Gr   c                 v    | j                             dd           |                     | j        dgd           d S )Ns&   <a>1<b/>&lt;2&gt;<c/>&#32;
&#x20;3</a>Tz1<2> 
 3r  )r   r   r   r   r   s    r   test2zBufferTextTest.test2  sM    DdKKKk]?	A 	A 	A 	A 	Ar   c                     |                      dg           | j                            dd           |                     | j        g dd           d S )NrI   r  T)r	  r
  r  r  r  r   buffered text not properly splitr  r   s    r   test3zBufferTextTest.test3  se    /0111/666%I%I%I;	= 	= 	= 	= 	=r   c                     |                      ddg           d | j        _        | j                            dd           |                     | j        g d           d S )NrI   rM   r  T)r	  r  </b>r  </c></a>)r   r   rR   r   r   r   r   s    r   test4zBufferTextTest.test4  st    /1DEFFF+/(/666FFF	H 	H 	H 	H 	Hr   c                     |                      ddg           | j                            dd           |                     | j        g d           d S )NrI   rM   s   <a>1<b></b>2<c/>3</a>T)	r	  r
  r  r  r  r  r  r  r  r  r   s    r   test5zBufferTextTest.test5  sj    /1DEFFF2D999HHH	J 	J 	J 	J 	Jr   c                     |                      g d           | j                            dd           |                     | j        g dd           d S )Nrf   rM   rI   s   <a>1<b/>2<c></c>345</a> T)	r	  r
  r  r  r  r  r  345r  r  r  r   s    r   test6zBufferTextTest.test6  st     + + + 	, 	, 	,5t<<<JJJ.	0 	0 	0 	0 	0r   c                     |                      g d           | j                            dd           |                     | j        g dd           d S )Nr  s,   <a>1<b/>2<c></c>3<!--abc-->4<!--def-->5</a> T)r	  r
  r  r  r  r  r  r  z
<!--abc-->4z
<!--def-->5r  r  r  r   s    r   test7zBufferTextTest.test7  s}     + + + 	, 	, 	,I4PPPH H H;	= 	= 	= 	= 	=r   N)r6   r7   r8   r   r   rR   rI   rM   rf   r   r  r  r  r  r  r  r  r!  r%  r9   r   r   r   r   Z  s        E E E; ; ;
     ( ( (* * *. . . $& < < < <- - -A A AG G GA A A
= = =H H HJ J J0 0 0= = = = =r   r   c                        e Zd Zd Zd Zd ZdS )HandlerExceptionTestc                      t          |          r?   )RuntimeErrorrF   s      r   rI   z(HandlerExceptionTest.StartElementHandler  s    4   r   c                     |                      t          j                            |d                   |           |                      |d         |           d S )Nr   r   )r   ospathbasename)r   r   filenamefuncnames       r   check_traceback_entryz*HandlerExceptionTest.check_traceback_entry  sL    ))%(33X>>>q8,,,,,r   c           	      \   t          j                    }| j        |_        	 |                    dd           |                                  d S # t
          $ rS}|                     |j        d         ddd|j        d         z  z              t          j	        |j
                  }|                     t          |          d           |                     |d         dd	           |                     |d
         dd           |                     |d         dd           t          j                    r]t          j        dk    rt!          j                    dk    sBt$          s5t&          s:|                     d|d
         d                    Y d }~d S Y d }~d S Y d }~d S Y d }~d S Y d }~d S d }~ww xY w)Ns   <a><b><c/></b></a>Tr   az*Expected RuntimeError for element 'a', butz	 found %r   ztest_pyexpat.pytest_exceptionr   z	pyexpat.cStartElementr   rI   win32ARMzcall_with_frame("StartElement")r   r   rI   r   r   r)  r   rh   	traceback
extract_tb__traceback__r   r0  	sysconfigis_python_buildsysplatformmachiner   r   assertIn)r   r   r   entriess       r   r4  z#HandlerExceptionTest.test_exception  s   #%%%)%="	OLL.555IIKKKKK 	O 	O 	OQVAYI(16!9456 6 6  *1?;;GS\\1---&&wqz'8:JL L L&&wqz'2ND D D&&wqz'8:OQ Q Q)++ O00X5E5G5G55P5P% 6Q 6Q >
1NNNNNNNNNO O O O O O5P5P5P5P5P5P5P5P5P5P5P5P5P5P5P5P5P5P	Os   *A F+D0F&&F+N)r6   r7   r8   rI   r0  r4  r9   r   r   r'  r'    sF        ! ! !- - -O O O O Or   r'  c                   &    e Zd Zd Zd Zd Zd ZdS )PositionTestc                 0    |                      d           d S )Ns	check_posrF   s      r   rI   z PositionTest.StartElementHandler      sr   c                 0    |                      d           d S )Nr   rF  rL   s     r   rM   zPositionTest.EndElementHandler  rH  r   c                 .   || j         j        | j         j        | j         j        f}|                     | j        t          | j                  k     d           | j        | j                 }|                     ||d|d|           | xj        dz  c_        d S )Nztoo many parser eventszExpected position z, got position r   )	r   CurrentByteIndexCurrentLineNumberCurrentColumnNumberr   uptor   expected_listr   )r   eventposr   s       r   rG  zPositionTest.check_pos  s    {+{,{.0 		C(:$;$;;0	2 	2 	2%di0hh:=##xxH	J 	J 	J		Q				r   c                     t          j                    | _        | j        | j        _        | j        | j        _        d| _        g d| _        d}| j                            |d           d S )Nr   ))rE  r   r   r   )rE     r   r   )rE     r3  r   )r   r,   r3  r   )r         r   )r      rS  r   s   <a>
 <b>
  <c/>
 </b>
</a>T)r   r   r   rI   rM   rN  rO  r   )r   xmls     r   r   zPositionTest.test  so    (***.*B'(,(>%	Q Q Q 0#t$$$$$r   N)r6   r7   r8   rI   rM   rG  r   r9   r   r   rC  rC    sP            
 
 
	% 	% 	% 	% 	%r   rC  c                       e Zd Zd ZdS )sf1296433Testc                     ddz  } G d dt                     fd}t          j                    }||_        |                     t           |j        |                    d                     d S )Nz1<?xml version='1.0' encoding='iso8859'?><s>%s</s>  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaac                       e Zd ZdS )Asf1296433Test.test_parse_only_xml_data.<locals>.SpecificExceptionN)r6   r7   r8   r9   r   r   SpecificExceptionr^    s        Dr   r_  c                     r?   r9   )re   r_  s    r   r   z7sf1296433Test.test_parse_only_xml_data.<locals>.handler  s	    ##r   iso8859)	Exceptionr   r   rR   r-   r   encode)r   rX  r   r   r_  s       @r   test_parse_only_xml_dataz&sf1296433Test.test_parse_only_xml_data  s     BZP	 	 	 	 		 	 	 		$ 	$ 	$ 	$ 	$ #%%&-#)V\3::i3H3HIIIIIr   N)r6   r7   r8   rd  r9   r   r   rZ  rZ    s(        J J J J Jr   rZ  c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )ChardataBufferTestz.
    test setting of chardata buffer size
    c                 X    |                      |                     d          d           d S )Ni  r   r   small_buffer_testr   s    r   test_1025_bytesz"ChardataBufferTest.test_1025_bytes  ,    //55q99999r   c                 X    |                      |                     d          d           d S )Ni  r   rh  r   s    r   test_1000_bytesz"ChardataBufferTest.test_1000_bytes  rk  r   c                 ,   t          j                    }d|_        |                     t                    5  d|_        d d d            n# 1 swxY w Y   |                     t                    5  d|_        d d d            n# 1 swxY w Y   |                     t          t          f          5  t          j        dz   |_        d d d            n# 1 swxY w Y   |                     t                    5  d|_        d d d            d S # 1 swxY w Y   d S )Nr   r   g      @)
r   r   r   r-   r   buffer_sizeOverflowErrorr=  maxsizer0   r   s     r   test_wrong_sizez"ChardataBufferTest.test_wrong_size  s   #%%z** 	$ 	$!#F	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$z** 	# 	#!"F	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#
M:;; 	1 	1!$qF	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1 	1y)) 	' 	'!&F	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	' 	'sG   A		AA.BB	B.CCC4D		DDc                    d}d}t          j                    }| j        |_        d|_        d|_        d| _        |                    |           |                     | j        d           |j        |_        |                     | j        d           |                    |           |                     | j        d           d S )Ns+  <?xml version='1.0' encoding='iso8859'?><s>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas  aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</s>i   r   r   r   )	r   r   counting_handlerrR   rp  r   nr   r   r   xml1xml2r   s       r   test_unchanged_sizez&ChardataBufferTest.test_unchanged_size'  s    J!#%%&*&;#  T### $/### 	T#####r   c                     d}d}d}t          j                    }| j        |_        d|_        d|_        |                     |j        d           d| _        |                    |d           |                     |j        d           |                     | j        d           d|_        | 	                    |j                   |                     |j        d           t          d          D ]}|                    |d           |                     | j        d	           d|_        |                     |j                   |                     |j        d           |                    |d
           |                     | j        d           d S )Ns+  <?xml version='1.0' encoding='iso8859'?><a>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaas   bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbs  cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc</a>r      r   F
   rT  T   )r   r   ru  rR   r   rp  r   rv  r   r  r2   r   )r   rx  ry  xml3r   is         r   test_disabling_bufferz(ChardataBufferTest.test_disabling_buffer>  s   J$#%%&*&;#!+T222 T5!!!+T222### +,,,+T222r 	& 	&ALLu%%%%$$$*++++T222T4   $$$$$r   c                 &    | xj         dz  c_         d S r   )rv  rd   s     r   ru  z#ChardataBufferTest.counting_handler\  s    !r   c                     dd|z  z   dz   }t          j                    }| j        |_        d|_        d|_        d| _        |                    |           | j        S )Ns+   <?xml version='1.0' encoding='iso8859'?><s>   as   </s>r|  r   r   )r   r   ru  rR   rp  r   rv  r   )r   
buffer_lenrX  r   s       r   ri  z$ChardataBufferTest.small_buffer_test_  s`    <tj?PPSZZ#%%&*&;#!Svr   c                    d}d}t          j                    }| j        |_        d|_        d|_        |                     |j        d           d| _        |                    |d           |xj        dz  c_        |                     |j        d           |                    |d	           |                     | j        d           d S )
Ns.  <?xml version='1.0' encoding='iso8859'?><a><s>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  aaa</s><s>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</s></a>r   r|  r   Fr      T	r   r   ru  rR   r   rp  r   rv  r   rw  s       r   test_change_size_1z%ChardataBufferTest.test_change_size_1j  s    N8#%%&*&;#!+T222T5!!!a+T222T4   #####r   c                    d}d}t          j                    }| j        |_        d|_        d|_        |                     |j        d           d| _        |                    |d           |j        dz  |_        |                     |j        d           |                    |d	           |                     | j        d
           d S )Ns.  <?xml version='1.0' encoding='iso8859'?><a>a<s>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaar  r   r  r   Fr   r|  TrV  r  rw  s       r   test_change_size_2z%ChardataBufferTest.test_change_size_2z  s    O8#%%&*&;#!+T222T5!!!#/14+T222T4   #####r   N)r6   r7   r8   __doc__rj  rm  rs  rz  r  ru  ri  r  r  r9   r   r   rf  rf    s         : : :: : :
' 
' 
'$ $ $.% % %<  	 	 	$ $ $ $ $ $ $ $r   rf  c                       e Zd Zd Zd ZdS )MalformedInputTestc                    d}t          j                    }	 |                    |d           |                                  d S # t           j        $ r.}|                     t          |          d           Y d }~d S d }~ww xY w)Ns    
Tz unclosed token: line 2, column 0)r   r   r   r   
ExpatErrorr   r   r   rX  r   r   s       r   r  zMalformedInputTest.test1  s    #%%	ILLd###IIKKKKK 	I 	I 	ISVV%GHHHHHHHHH	Is   *A B #A;;B c                     d}t          j                    }d}|                     t           j        |          5  |                    |d           d d d            d S # 1 swxY w Y   d S )Ns   <?xml version='1.0'?>
z3XML declaration not well-formed: line 1, column \d+T)r   r   assertRaisesRegexr  r   )r   rX  r   err_patterns       r   r  zMalformedInputTest.test2  s    2#%%L##E$4kBB 	$ 	$LLd###	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$ 	$s   AA #A N)r6   r7   r8   r  r  r9   r   r   r  r    s5        I I I$ $ $ $ $r   r  c                       e Zd Zd Zd ZdS )ErrorMessageTestc                     |                      t          j        t          j        t          j        t          j                                     d S r?   )r   r   XML_ERROR_SYNTAXmessagescodesr   s    r   
test_codeszErrorMessageTest.test_codes  sB    0f6M)NO	Q 	Q 	Q 	Q 	Qr   c                 *   d}t          j                    }	 |                    |d           |                                  d S # t           j        $ r@}|                     |j        t          j        t          j	                            Y d }~d S d }~ww xY w)N   <T)
r   r   r   r   r  r   r   r   r  XML_ERROR_UNCLOSED_TOKENr  s       r   test_expaterrorz ErrorMessageTest.test_expaterror  s    #%%	LLLd###IIKKKKK 	L 	L 	LQV#\&*IJL L L L L L L L L	Ls   *A B5BBN)r6   r7   r8   r  r  r9   r   r   r  r    s:        Q Q Q
L L L L Lr   r  c                       e Zd ZdZd Zd ZdS )ForeignDTDTestszE
    Tests for the UseForeignDTD method of expat parser objects.
    c                 
   g fd}t          j                    }|                    d           |                    t           j                   ||_        |                    d           |                     dg           g dd<   t          j                    }|                                 |                    t           j                   ||_        |                    d           |                     dg           dS )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.
        c                 6                         ||f           dS r   r   rw   ri   	system_id	public_idhandler_call_argss       r   resolve_entityz<ForeignDTDTests.test_use_foreign_dtd.<locals>.resolve_entity  !    $$i%;<<<1r   Ts   <?xml version='1.0'?><element/>)NNNr   r   UseForeignDTDSetParamEntityParsingXML_PARAM_ENTITY_PARSING_ALWAYSrz   r   r   r   r  r   r  s      @r   test_use_foreign_dtdz$ForeignDTDTests.test_use_foreign_dtd  s    	 	 	 	 	 #%%T"""$$U%JKKK*8'7888*\N;;;  "!!!#%%$$U%JKKK*8'7888*\N;;;;;r   c                 
   g fd}t          j                    }|                    d           |                    t           j                   ||_        |                    d           |                     dg           dS )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.
        c                 6                         ||f           dS r   r   r  s       r   r  zCForeignDTDTests.test_ignore_use_foreign_dtd.<locals>.resolve_entity  r  r   Ts@   <?xml version='1.0'?><!DOCTYPE foo PUBLIC 'bar' 'baz'><element/>)barbazNr  r  s      @r   test_ignore_use_foreign_dtdz+ForeignDTDTests.test_ignore_use_foreign_dtd  s     	 	 	 	 	 #%%T"""$$U%JKKK*8'O	Q 	Q 	Q*^,<=====r   N)r6   r7   r8   r  r  r  r9   r   r   r  r    s<         < < <8> > > > >r   r  __main__) ior   r+  r>  r=  r;  unittestr8  xml.parsersr   xml.parsers.expatr   test.supportr   r   r   TestCaser
   rQ   r;   r   r   r   r'  rC  rZ  rf  r  r  r  r6   mainr9   r   r   <module>r     s          				  



                $ $ $ $ $ $ 9 9 9 9 9 9 9 9 9 9%G %G %G %G %Gx( %G %G %GP6|; |; |; |; |;! |; |; |;| 3  3  3  3  3X.  3  3  3F!/ !/ !/ !/ !/H% !/ !/ !/H\= \= \= \= \=X& \= \= \=@ O  O  O  O  O8,  O  O  OH% % % % %8$ % % %>J J J J JH% J J J&x$ x$ x$ x$ x$* x$ x$ x$t$ $ $ $ $* $ $ $$L L L L Lx( L L L"1> 1> 1> 1> 1>h' 1> 1> 1>h zHMOOOOO r   