+
    Dfjl$                         R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
  ! R R4      t ! R R	4      t ! R
 R]P                  4      t ! R R]P                  4      tR# )z+
Test cases for twisted.words.xish.utility
)OrderedDict)unittest)utility)Element)EventDispatcherc                   0   a  ] tR t^t o RtR tR tRtV tR# )CallbackTrackerz|
Test helper for tracking callbacks.

Increases a counter on each call to L{call} and stores the object
passed in the call.
c                "    ^ V n         RV n        R# )    Ncalledobjselfs   &B/usr/lib/python3/dist-packages/twisted/words/test/test_xishutil.py__init__CallbackTracker.__init__   s        c                B    V P                   ^,           V n         Wn        R# )   Nr   )r   r   s   &&r   callCallbackTracker.call   s    kkAor   r   N)	__name__
__module____qualname____firstlineno____doc__r   r   __static_attributes____classdictcell____classdict__s   @r   r   r      s      r   r   c                   <   a  ] tR t^"t o RtR tR tR tR tRt	V t
R# )OrderedCallbackTrackerz5
Test helper for tracking callbacks and their order.
c                    . V n         R # NcallListr   s   &r   r   OrderedCallbackTracker.__init__'   s	    r   c                P    V P                   P                  V P                  4       R # r$   )r&   appendcall1r   objects   &&r   r*   OrderedCallbackTracker.call1*       TZZ(r   c                P    V P                   P                  V P                  4       R # r$   )r&   r)   call2r+   s   &&r   r0   OrderedCallbackTracker.call2-   r.   r   c                P    V P                   P                  V P                  4       R # r$   )r&   r)   call3r+   s   &&r   r3   OrderedCallbackTracker.call30   r.   r   r%   N)r   r   r   r   r   r   r*   r0   r3   r   r   r   s   @r   r"   r"   "   s#     ))) )r   r"   c                   l   a  ] tR t^4t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tRtV tR# )EventDispatcherTestsz
Tests for L{EventDispatcher}.
c                   \        4       p\        4       p\        4       p\        4       pVP                  R VP                  4       VP                  RVP                  4       VP                  RVP                  4       VP                  RVP                  4       \	        R4      pVP                  R4       \	        R4      pVP                  R4       VP                  V4       V P                  VP                  ^4       V P                  VP                  V4       V P                  VP                  ^ 4       VP                  V4       V P                  VP                  ^4       V P                  VP                  ^4       V P                  VP                  V4       V P                  VP                  ^ 4       VP                  VR4       V P                  VP                  ^4       V P                  VP                  V4       VP                  RVP                  4       VP                  V4       V P                  VP                  ^4       R# )	/message/body/message	/presence//event/testeventbodypresenceNnsmessager?   r=   )r   r   addObserverr   r   
addElementdispatchassertEqualr   r   removeObserver)r   dcb1cb2cb3msgpress   &      r   	testStuffEventDispatcherTests.testStuff9   s   	osxx0	j#((+	k388,	)3884'(v)*
#	

3Q'#&Q'	

4Q'Q'$'Q'	

1)*Q'!$	chh/	

4Q'r   c                   \        4       p\        4       p\        4       pVP                  RVP                  4       VP                  RVP                  4       VP	                  VR4       V P                  VP                  ^4       V P                  VP                  V4       V P                  VP                  ^4       V P                  VP                  V4       R# )zv
Test adding two observers for the same query.

When the event is dispatched both of the observers need to be called.
r;   N)r   r   rB   r   rD   rE   r   r   )r   rG   rH   rI   s   &   r   test_addObserverTwice*EventDispatcherTests.test_addObserverTwice]   s     	)3884	)3884	

1)*Q'!$Q'!$r   c                  aa \        4       o\        R4      p\        4       oVV3R lpSP                  RV4       SP	                  V4       V P                  SP                  ^ 4       SP	                  V4       V P                  SP                  ^4       SP	                  V4       V P                  SP                  ^4       R# )z7
Test for registration of an observer during dispatch.
c                 @   < SP                  R SP                  4       R# r9   N)rB   r   )_cbrG   s   &r   	onMessageBEventDispatcherTests.test_addObserverInDispatch.<locals>.onMessagex   s    MM*bgg.r   r9   Nr>   r   r   r   addOnetimeObserverrD   rE   r   r   rK   rW   rV   rG   s   &  @@r   test_addObserverInDispatch/EventDispatcherTests.test_addObserverInDispatchp   s     '(	/ 	
Z3	

3A&	

3A&	

3A&r   c                  aa \        4       o\        R4      p\        4       oVV3R lpSP                  RV4       SP	                  V4       V P                  SP                  ^ 4       SP	                  V4       V P                  SP                  ^4       SP	                  V4       V P                  SP                  ^4       R# )z>
Test for registration of a onetime observer during dispatch.
c                 @   < SP                  R SP                  4       R# rT   )rZ   r   )rK   rV   rG   s   &r   rW   IEventDispatcherTests.test_addOnetimeObserverInDispatch.<locals>.onMessage   s      RWW5r   r9   Nr>   rY   r[   s   &  @@r   !test_addOnetimeObserverInDispatch6EventDispatcherTests.test_addOnetimeObserverInDispatch   s     '(	6 	
Z3	

3A&	

3A&	

3A&r   c                0   \        4       p\        R4      p\        4       pVP                  RVP                  4       VP                  V4       V P                  VP                  ^4       VP                  V4       V P                  VP                  ^4       R# )r?   r9   Nr>   )r   r   r   rZ   r   rD   rE   r   )r   rG   rK   rV   s   &   r   testOnetimeDispatch(EventDispatcherTests.testOnetimeDispatch   so    '(	Z1	

3A&	

3A&r   c                   \        4       p\        R4      p\        R4      p\        4       pVP                  RVP                  4       VP                  V4      pV P                  RV4       VP                  V4      pV P                  RV4       R# )r?   r:   FTNr>   rA   )r   r   r   rB   r   rD   rE   )r   rG   rK   rL   rV   results   &     r   testDispatcherResult)EventDispatcherTests.testDispatcherResult   su    '()*	k277+C'D!v&r   c                    \        4       p\        4       pVP                  R VP                  4       VP                  RVP                  R4       VP                  R VP
                  ^4       \        R4      pVP                  R4       VP                  V4       T P                  VP                  VP
                  VP                  VP                  .R\        VP                   Uu. uF  qDP                  NK  	  up4      ,          4       R# u upi )r8   r9   r<   zCalls out of order: %sNr>   )r   r"   rB   r0   r3   r*   r   rC   rD   rE   r&   reprr   )r   rG   rV   rK   cs   &    r   testOrderedXPathDispatch-EventDispatcherTests.testOrderedXPathDispatch   s    #%	orxx0	j"((B/	orxx3'(v	

3KKXXrxx*$t,MAZZ,M'NN	
 -Ns   $Dc                b   \        4       p\        4       pVP                  RVP                  4       VP	                  RR4       V P                  ^VP                  4       VP                  RVP                  4       V P                  ^ \        VP                  P                  ^ 4      4      4       R# )z?
Test observer clean-up after removeObserver for named events.
//event/testN)r   r   rB   r   rD   rE   r   rF   len_eventObserverspopr   rG   rV   s   &  r   test_cleanUpRemoveEventObserver4EventDispatcherTests.test_cleanUpRemoveEventObserver   s    
 	nbgg.	

4(BII&	1C 1 1 5 5a 89:r   c                v   \        4       p\        4       p\        R4      pVP                  RVP                  4       VP                  V4       V P                  ^VP                  4       VP                  RVP                  4       V P                  ^ \        VP                  P                  ^ 4      4      4       R# )z?
Test observer clean-up after removeObserver for XPath events.
Nr9   Nr@   )r   r   r   rB   r   rD   rE   r   rF   rr   _xpathObserversrt   r   rG   rV   rK   s   &   r   test_cleanUpRemoveXPathObserver4EventDispatcherTests.test_cleanUpRemoveXPathObserver   s    
 '(	j"''*	

3BII&	RWW-C 1 1 5 5a 89:r   c                *   \        4       p\        4       pVP                  RVP                  4       VP	                  RR4       V P                  ^VP                  4       V P                  ^ \        VP                  P                  ^ 4      4      4       R# )z4
Test observer clean-up after onetime named events.
rq   N)
r   r   rZ   r   rD   rE   r   rr   rs   rt   ru   s   &  r    test_cleanUpOnetimeEventObserver5EventDispatcherTests.test_cleanUpOnetimeEventObserver   sp    
 	^RWW5	

4(BII&C 1 1 5 5a 89:r   c                >   \        4       p\        4       p\        R4      pVP                  RVP                  4       VP                  V4       V P                  ^VP                  4       V P                  ^ \        VP                  P                  ^ 4      4      4       R# )z4
Test observer clean-up after onetime XPath events.
Nr9   ry   )r   r   r   rZ   r   rD   rE   r   rr   rz   rt   r{   s   &   r    test_cleanUpOnetimeXPathObserver5EventDispatcherTests.test_cleanUpOnetimeXPathObserver   sx    
 '(	Z1	

3BII&C 1 1 5 5a 89:r   c                D  a  ! R R\         P                  4      p ! R R\        4      oV3R lp\        4       p\	        4       p\         P                  p V\         n        VP                  RV4       VP                  RVP                  4        VP                  RR4       V P                  ^\        V P                  S4      4      4       V P                  ^VP                  4       V\         n        R#   S d    T P                  R4        Lmi ; i  T\         n        i ; i)	z
Test that exceptions in observers do not bubble up to dispatch.

The exceptions raised in observers should be logged and other
observers should be called as if nothing happened.
c                   &   a  ] tR tRt o R tRtV tR# )OEventDispatcherTests.test_observerRaisingException.<locals>.OrderedCallbackListi
  c                $    \        4       V n        R # r$   )r   	callbacksr   s   &r   r   XEventDispatcherTests.test_observerRaisingException.<locals>.OrderedCallbackList.__init__  s    !,r   )r   N)r   r   r   r   r   r   r   r   s   @r   OrderedCallbackListr   
  s     / /r   r   c                       ] tR tRtRtR# )EEventDispatcherTests.test_observerRaisingException.<locals>.TestErrori   N)r   r   r   r   r   r   r   r   	TestErrorr     s    r   r   c                    < S! 4       hr$   r   )rU   r   s   &r   
raiseErrorFEventDispatcherTests.test_observerRaisingException.<locals>.raiseError  s    +r   rq   Nz2TestError raised. Should have been logged instead.)r   CallbackList	Exceptionr   r   rB   r   rD   failrE   rr   flushLoggedErrorsr   )r   r   r   rG   rV   originalCallbackListr   s   &     @r   test_observerRaisingException2EventDispatcherTests.test_observerRaisingException  s    	/'"6"6 	/		 		 &33	8#6G MM.*5MM."''2P

40 QD$:$:9$E FGQ		*#7G   P		NOP $8G s1   9D C4 !AD 4DD DD Dr   N)r   r   r   r   r   rM   rP   r\   ra   rd   rh   rn   rv   r|   r   r   r   r   r   r   s   @r   r6   r6   4   sL     "(H%&',',	''
,;;;;$8 $8r   r6   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )XmlPipeTestsi)  z2
Tests for L{twisted.words.xish.utility.XmlPipe}.
c                :    \         P                  ! 4       V n        R # r$   )r   XmlPipepiper   s   &r   setUpXmlPipeTests.setUp.  s    OO%	r   c                   a V3R lp. oV P                   P                  P                  RV4       \        R4      pV P                   P                  P                  V4       V P                  V.S4       R# )z?
Send an element from the source and observe it from the sink.
c                 *   < SP                  V 4       R # r$   r)   r   r   s   &r   rV   ,XmlPipeTests.test_sendFromSource.<locals>.cb6      MM#r   /test[@xmlns="testns"]Ntestnstest)r   sinkrB   r   sourcesendrE   r   rV   elementr   s   &  @r   test_sendFromSource XmlPipeTests.test_sendFromSource1  s]    
	 		""#;R@,-		g&'F+r   c                   a V3R lp. oV P                   P                  P                  RV4       \        R4      pV P                   P                  P                  V4       V P                  V.S4       R# )z?
Send an element from the sink and observe it from the source.
c                 *   < SP                  V 4       R # r$   r   r   s   &r   rV   *XmlPipeTests.test_sendFromSink.<locals>.cbD  r   r   r   Nr   )r   r   rB   r   r   r   rE   r   s   &  @r   test_sendFromSinkXmlPipeTests.test_sendFromSink?  s]    
	 		$$%=rB,-		G$'F+r   )r   N)
r   r   r   r   r   r   r   r   r   r   r   s   @r   r   r   )  s     &,, ,r   r   N)r   collectionsr   twisted.trialr   twisted.words.xishr   twisted.words.xish.domishr   twisted.words.xish.utilityr   r   r"   TestCaser6   r   r   r   r   <module>r      sV   
 $ " & - 6 ") )$r88,, r8j",8$$ ",r   