
    0hhT1                     b   S SK r S SKrS SKrS SKJr  S SKJr  S SKJ	r	  S SK
Jr  \" SSS9rS	r " S
 S\R                  5      r " S S\R                  5      r " S S\5      r " S S\5      r " S S\	R(                  5      r " S S\R                  5      r\S:X  a  \R0                  " 5         gg)    N)AttributesImpl)feature_external_gespulldom)findfileztest.xmlxmltestdata)subdira  <?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xdc="http://www.xml.com/books">
<!-- A comment -->
<title>Introduction to XSL</title>
<hr/>
<p><xdc:author xdc:attrib="prefixed attribute" attrib="other attrib">A. Namespace</xdc:author></p>
</html>c                   t    \ rS rSrS rS rS r\R                  S 5       r	\R                  S 5       r
S rSrg	)
PullDOMTestCase   c                 *   [         R                  " [        5      nU R                  UR                  R
                  5        [        U5        [        [        S5       n[        [         R                  " U5      5        S S S 5        g ! , (       d  f       g = f)Nrb)r   parsetstfile
addCleanupstreamcloselistopen)selfhandlerfins      :/opt/python-3.13.8/usr/lib/python3.13/test/test_pulldom.py
test_parsePullDOMTestCase.test_parse   sZ     --(,,-W '4 Cs#$ !  s    B
Bc                 V	   [         R                  " [        5      n[        U5      u  p#U R	                  [        US5      5        U R                  [         R                  U5        [        U5      u  p#U R                  [         R                  U5        U R                  SUR                  5        U R                  S[        UR                  5      5        U R                  UR                  R                  S5      R                  S5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  SUR                  5        Un[        U5      u  p#U R                  [         R                  U5        U R                  SUR                  5        [        U5      u  p#U R                  [         R                   U5        U R                  SUR                  5        U R	                  XCL 5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  [         R                  U5        U R                  SUR                  5        [        U5      u  p#U R                  [         R                   U5        U R                  SUR                  5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  [         R                  U5        U R                  S	UR                  5        [        U5      u  p#U R                  [         R                  U5        U R                  S
UR                  5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  [         R                   U5        U R                  S
UR                  5        [        U5      u  p#U R                  [         R                   U5        [        U5      u  p#U R                  [         R                  U5        [        U5      u  p#U R                  [         R                   U5        g )NcreateElementhtml   z	xmlns:xdczhttp://www.xml.com/bookstitlezIntroduction to XSLhrpz
xdc:author)r   parseStringSMALL_SAMPLEnext
assertTruehasattrassertEqualSTART_DOCUMENTSTART_ELEMENTtagNamelen
attributesgetNamedItemvalue
CHARACTERSdataEND_ELEMENT)r   itemsevtnode
title_nodes        r   test_parse_semantics$PullDOMTestCase.test_parse_semantics+   so    ##L1K	o67//5K	..4.C0155kBHH(	*K	++S1K	 	++S1K	$,,/
K	++S1.		:K	,,c2$,,/
*+K	++S1K	..4t||,K	,,c2t||,K	++S1K	..4dll+K	..4t||4K	++S1K	,,c2t||4K	,,c2K	++S1K	,,c2    c                    [         R                  " [        5      nU Hc  u  p#U[         R                  :X  d  M  UR                  S:X  d  M-  UR                  U5        U R                  S[        UR                  5      5          O   U R                  S5        U H  u  p$U[         R                  :X  d  M    O   U R                  SWR                  S5        UR                  U5        U R                  [        U5      S   [         R                  5        [        U5      u  p$U R                  UR                  S5        UR                  U5        [        U5        [        U5      u  p$U R                  UR                  S5        U R                  [        5         [        U5        S S S 5        UR                  5         U R                  UR                   5        U R                  UR"                  5        g ! , (       d  f       NU= f)	Nr       z,No "title" element detected in SMALL_SAMPLE!r!   z=expandNode did not leave DOMEventStream in the correct state.r   r"   r   )r   r#   r$   r*   r+   
expandNoder(   r,   
childNodesfailr%   r0   assertRaisesStopIterationclearassertIsNoneparserr   )r   r3   r4   itemr5   s        r   test_expandItemPullDOMTestCase.test_expandItemi   sz   ##L1ICg+++0G  &  C$89	  IIFGICg+++  	t||K	M 	eQ););<K	s+UK	v.}-K .%,,'%,,'	 .-s   G..
G<c                     [         R                  " [        5      nU H  u  p#U[         R                  :X  d  M    g    U R	                  S5        g )NzNo comment was encountered)r   r#   r$   COMMENTr>   )r   r3   r4   _s       r   test_commentPullDOMTestCase.test_comment   s>     ##L1FCgoo%  II23r9   c                 <   [         R                  " [        5      nU H-  u  p#U[         R                  :X  d  M  UR                  S:X  d  M-    O    [        U5      u  p#U R                  [         R                  U5        g ! [         a    U R                  S5         g f = f)Nr   z8Ran out of events, but should have received END_DOCUMENT)
r   r#   r$   r2   r+   r%   r(   END_DOCUMENTr@   r>   )r   r3   r4   r5   s       r   test_end_document!PullDOMTestCase.test_end_document   s     ##L1ICg)))dllf.D 	LUICW1137 	LIIJL	Ls   -A= =BBc                     [         R                  " [        5      nUR                  nUR	                  [
        5      nU R                  US5        g )NF)r   r#   r$   rC   
getFeaturer   r(   )r   rC   	saxparsergess       r   test_external_ges_default)PullDOMTestCase.test_external_ges_default   s<    $$\2MM	""#78e$r9    N)__name__
__module____qualname____firstlineno__r   r7   rE   unittestexpectedFailurerJ   rN   rT   __static_attributes__rV   r9   r   r   r      sN    % 93|(@ 4 4 L L%r9   r   c                   N    \ rS rSrS r\R                  S 5       rS rSS jr	Sr
g)	ThoroughTestCase   c                 \    U R                  [        R                  " S [        5       S95        g )N)rC   )_test_thoroughr   r   SAXExerciserr   s    r   test_thorough_parse$ThoroughTestCase.test_thorough_parse   s    GMM$|~FGr9   c                 P    [        S [        5       S5      nU R                  U5        g )N   )SAX2DOMTestHelperrc   rb   r   pds     r   test_sax2dom_fail"ThoroughTestCase.test_sax2dom_fail   s"     t\^R8Br9   c                 R    [        S [        5       S5      nU R                  US5        g )Nrh   F)ri   SAX2DOMExerciserrb   rj   s     r   test_thorough_sax2dom&ThoroughTestCase.test_thorough_sax2dom   s$    t%5%7<B&r9   c                    [        U5      u  p4U R                  [        R                  U5        U R	                  [        US5      5        U(       a  [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        U R                  SUR                  5        [        U5      u  p4U R                  [        R                  U5        g )Nr   	a commenttargetr1   r   r"   text)r%   r(   r   r)   r&   r'   rH   r1   PROCESSING_INSTRUCTIONrt   r*   r+   r0   r2   rM   )r   rk   before_rootr4   r5   s        r   rb   ThoroughTestCase._test_thorough   s]    H	//5o67RICW__c2[$))4RICW;;SAXt{{3VTYY/H	..4.H	#.dii0H	77=4;;/+H	..4dll+H	++S1+H	,,c2dll+H	,,c2.H	--s3r9   rV   N)T)rW   rX   rY   rZ   re   r[   r\   rl   rp   rb   r]   rV   r9   r   r_   r_      s,    H    
'
,4r9   r_   c                   .    \ rS rSrS rS rS r\r\rSr	g)rc      c                     Xl         g N_handler)r   r   s     r   setContentHandlerSAXExerciser.setContentHandler   s    r9   c                    U R                   nUR                  5         UR                  S5        UR                  SS5        UR	                  S[        0 5      5        UR                  S5        UR                  SS5        UR	                  S[        SS05      5        UR                  S5        UR                  S5        UR                  S5        UR                  5         g )	Nrs   rt   r1   r   r"   class	paraclassru   )	r~   startDocumentcommentprocessingInstructionstartElementr   
characters
endElementendDocumentr   rI   hs      r   r   SAXExerciser.parse   s    MM	 	
		+	&1	v~b12			+	&1	sNG[+ABC	V	S	V	r9   c                     g r|   rV   )r   argskwargss      r   stubSAXExerciser.stub  s    r9   r}   N)
rW   rX   rY   rZ   r   r   r   setProperty
setFeaturer]   rV   r9   r   rc   rc      s     ( KJr9   rc   c                       \ rS rSrS rSrg)ro   i  c                 x   U R                   nUR                  5         UR                  S[        0 5      5        UR	                  S5        UR                  SS5        UR                  S[        SS05      5        UR                  S5        UR                  S5        UR                  S5        UR                  5         g )	Nr   rs   rt   r1   r"   r   r   ru   )	r~   r   r   r   r   r   r   r   r   r   s      r   r   SAX2DOMExerciser.parse  s    MM		v~b12			+	&1	sNG[+ABC	V	S	V	r9   rV   N)rW   rX   rY   rZ   r   r]   rV   r9   r   ro   ro     s    
r9   ro   c                       \ rS rSrS rSrg)ri   i  c                     [         R                  " 5       U l         U R                  R                  [        R
                  R                  R                  S5        U R                  R                  U R                   5        g )Nr;   )	r   SAX2DOMrC   r   xmlsaxr   feature_namespacesr   rd   s    r   resetSAX2DOMTestHelper.reset!  sH    (swwAA1E%%dll3r9   r   N)rW   rX   rY   rZ   r   r]   rV   r9   r   ri   ri     s    4r9   ri   c                   *    \ rS rSrSS jrS rS rSrg)SAX2DOMTestCasei(  c                 &    U R                  X5        g r|   )r&   )r   testtestnames      r   confirmSAX2DOMTestCase.confirm*  s    'r9   c                    [         R                  " [        5       n[        U[        R
                  R                  5       [        [        5      5      nU H-  u  p4U[        R                  :X  d  M  UR                  S:X  d  M-    O   U R                  [        WR                  5      S5        S S S 5        g ! , (       d  f       g = f)Nr   r   )ioStringIOr$   ri   r   r   make_parserr,   r   r*   r+   assertGreaterr=   )r   r   sdr4   r5   s        r   
test_basicSAX2DOMTestCase.test_basic-  s    [[&#"3(;(;(=#&|#46B	'///DLLF4J  
 s4??3Q7 '&&s   AB3/B3)B33
Cc                    [         R                  " 5       nUR                  5         UR                  S0 5        UR	                  S5        UR                  S0 5        UR	                  S5        UR                  S5        UR	                  S5        UR                  S5        UR                  5         UR                  nUR                  nUR                  u  pEnUR                  S   nU R                  UR                  5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  5        U R                  UR                  5        U R                  UR                  5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  U5        U R                  UR                  U5        UR                  5         g )Ndocru   subelmr   )r   r   r   r   r   r   r   documentdocumentElementr=   rB   previousSiblingassertIsnextSibling
parentNodeunlink)r   sax2domr   roottext1elm1text2text3s           r   testSAX2DOMSAX2DOMTestCase.testSAX2DOM9  s   //#UB'6"Xr*6"8$6"5!""#e"%//0e''.d**E2d&&.e++T2%++,%//0%++,doos+e&&-doot,e&&-e&&-

r9   rV   N)Test)rW   rX   rY   rZ   r   r   r   r]   rV   r9   r   r   r   (  s    (
8 r9   r   __main__)r   r[   xml.saxr   xml.sax.xmlreaderr   xml.sax.handlerr   xml.domr   test.supportr   r   r$   TestCaser   r_   objectrc   ro   DOMEventStreamri   r   rW   mainrV   r9   r   <module>r      s    	   , 0  ! :m
4N%h'' N%b>4x(( >4B6 D| "4.. 41h'' 1h zMMO r9   