+
    Dfj*                         R t ^ RIHtHtHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ^RIHtHt ^RIHt ^RIHt  ! R	 R
]P*                  4      tR# )z-
Test cases for L{twisted.logger._observer}.
)DictListTuplecast)implementer)BrokenMethodImplementation)verifyObject)unittest)ILogObserverLogEvent)Logger)LogPublisherc                      a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltV 3R lR ltV 3R lR ltRtV tR# )LogPublisherTestsz
Tests for L{LogPublisher}.
c                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "C/usr/lib/python3/dist-packages/twisted/logger/test/test_observer.py__annotate__LogPublisherTests.__annotate__   s           c                    \        4       p \        \        V4       R#   \         d   pT P	                  T4        Rp?R# Rp?ii ; i)z(
L{LogPublisher} is an L{ILogObserver}.
N)r   r   r
   r   fail)self	publisheres   &  r   test_interface LogPublisherTests.test_interface   s7     !N		y1) 	IIaLL	s    AA  Ac                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   #   s     > > >r   c                    \        \        R 4      p\        \        R 4      p\        W4      pV P                  W0\	        VP
                  4      4       R# )z2
L{LogPublisher.observers} returns the observers.
c                     R # Nr   r   s   &r   <lambda>2LogPublisherTests.test_observers.<locals>.<lambda>'       $r   c                     R # r%   r   r&   s   &r   r'   r(   (   r)   r   N)r   r
   r   assertEqualset
_observers)r   o1o2r   s   &   r   test_observers LogPublisherTests.test_observers#   sC     ,/,/ (	"3y';';#<=r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   -   s     
B 
B$ 
Br   c                    \        \        R 4      p\        \        R 4      p\        \        R 4      p\        W4      pVP                  V4       V P	                  WV0\        VP                  4      4       R# )z/
L{LogPublisher.addObserver} adds an observer.
c                     R # r%   r   r&   s   &r   r'   4LogPublisherTests.test_addObserver.<locals>.<lambda>1   r)   r   c                     R # r%   r   r&   s   &r   r'   r5   2   r)   r   c                     R # r%   r   r&   s   &r   r'   r5   3   r)   r   N)r   r
   r   addObserverr+   r,   r-   r   r.   r/   o3r   s   &    r   test_addObserver"LogPublisherTests.test_addObserver-   s_     ,/,/,/ (	b!""s9+?+?'@Ar   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   9   s     F FT Fr   c                l    \        4       pV P                  \        VP                  \	        4       4       R# )zM
L{LogPublisher.addObserver} refuses to add an observer that's
not callable.
N)r   assertRaises	TypeErrorr8   object)r   r   s   & r   test_addObserverNotCallable-LogPublisherTests.test_addObserverNotCallable9   s%    
 !N	)Y%:%:FHEr   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   A   s     
> 
>T 
>r   c                    \        \        R 4      p\        \        R 4      p\        \        R 4      p\        WV4      pVP                  V4       V P	                  W0\        VP                  4      4       R# )z5
L{LogPublisher.removeObserver} removes an observer.
c                     R # r%   r   r&   s   &r   r'   7LogPublisherTests.test_removeObserver.<locals>.<lambda>E   r)   r   c                     R # r%   r   r&   s   &r   r'   rG   F   r)   r   c                     R # r%   r   r&   s   &r   r'   rG   G   r)   r   Nr   r
   r   removeObserverr+   r,   r-   r9   s   &    r   test_removeObserver%LogPublisherTests.test_removeObserverA   s_     ,/,/,/ ,	  $"3y';';#<=r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   M   s     > >$ >r   c                    \        \        R 4      p\        \        R 4      p\        \        R 4      p\        W4      pVP                  V4       V P	                  W0\        VP                  4      4       R# )zL
L{LogPublisher.removeObserver} removes an observer that is not
registered.
c                     R # r%   r   r&   s   &r   r'   DLogPublisherTests.test_removeObserverNotRegistered.<locals>.<lambda>R   r)   r   c                     R # r%   r   r&   s   &r   r'   rQ   S   r)   r   c                     R # r%   r   r&   s   &r   r'   rQ   T   r)   r   NrJ   r9   s   &    r    test_removeObserverNotRegistered2LogPublisherTests.test_removeObserverNotRegisteredM   s]    
 ,/,/,/ (	  $"3y';';#<=r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   Z   s     & &T &r   c                V   \        ^^R7      p. p. p. p\        \        VP                  4      p\        \        VP                  4      p\        \        VP                  4      p\	        WVV4      pV! V4       V P                  W4       V P                  W4       V P                  W4       R# )z&
L{LogPublisher} calls its observers.
foobarN)dictr   r
   appendr   assertIn)	r   eventevents1events2events3r.   r/   r:   r   s	   &        r   test_fanOutLogPublisherTests.test_fanOutZ   s     ""$"$"$,/,/,/ ,	%e%e%e%r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r   n   s     ) )T )r   c                  aa \        ^^R7      p\        R4      o. o\        \        4      R VV3R ll4       p. p\	        V\        \        VP                  4      4      pV! V4       V P                  VS4       V Uu. uF  pRV9   g   K  VR,          NK  	  ppV P                  \        V4      ^4       V P                  V^ ,          P                  S4       V P                  \        S4      ^4       R# u upi )ze
Observer raises an exception during fan out: a failure is logged, but
not re-raised.  Life goes on.
rX   ARGH! EVIL DEATH!c                (    V ^8  d   QhR\         RR/# r   r^   r   Nr   )r   s   "r   r   ;LogPublisherTests.test_observerRaises.<locals>.__annotate__y   s     	  	 H 	  	 r   c                 L   < S'       * pSP                  V 4       V'       d   ShR # r%   )r\   )r^   shouldRaiseevents	exceptions   & r   observer7LogPublisherTests.test_observerRaises.<locals>.observerx   s#    $*KMM%  r   log_failureN)r[   RuntimeErrorr   r
   r   r   r\   r]   r+   lenassertIsvalue)	r   r^   ro   	collectorr   r   errorsrm   rn   s	   &      @@r   test_observerRaises%LogPublisherTests.test_observerRaisesn   s    
 " !45	!#	\	"	  	  
#	  %'	 4i>N>N+OP	% 	eV$ -6LIq!9K"!M""ILVa(fQiooy1Va(	 Ms   =	C5C5c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s      T r   c                   a \        ^^R7      p\        R4      o\        \        4      R R l4       p ! V3R lR\        4      p\        V4      pV! 4       Vn        V! V4       R# )z
Observer raises an exception during fan out and the publisher's Logger
pukes when the failure is reported.  The exception does not propagate
back to the caller.
rX   rf   c                (    V ^8  d   QhR\         RR/# rh   ri   )r   s   "r   r   KLogPublisherTests.test_observerRaisesAndLoggerHatesMe.<locals>.__annotate__   s     	, 	,H 	, 	,r   c                     \        R 4      h)z	Sad panda)rr   )r^   s   &r   ro   GLogPublisherTests.test_observerRaisesAndLoggerHatesMe.<locals>.observer   s    {++r   c                   :   <a  ] tR t^t o V 3R lV3R lltRtV tR# )ILogPublisherTests.test_observerRaisesAndLoggerHatesMe.<locals>.GurkLoggerc                *   < V ^8  d   QhRS[ RS[ RR/# )r   argskwargsr   N)rA   )r   r   s   "r   r   VLogPublisherTests.test_observerRaisesAndLoggerHatesMe.<locals>.GurkLogger.__annotate__   s"        V  v  $  r   c                   < Shr%   r   )r   r   r   rn   s   &*,r   failureQLogPublisherTests.test_observerRaisesAndLoggerHatesMe.<locals>.GurkLogger.failure   s    r   r   N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell__)r   rn   s   @r   
GurkLoggerr      s          r   r   N)r[   rr   r   r
   r   r   log)r   r^   ro   r   r   rn   s   &    @r   #test_observerRaisesAndLoggerHatesMe5LogPublisherTests.test_observerRaisesAndLoggerHatesMe   s\     " !45		\	"	, 
#	,	  	  !*	"	%r   c                   < V ^8  d   QhRR/# r   r   )r   r   s   "r   r   r      s     H HD Hr   c                *  a \        ^^. R7      p/ o\        \        4      R V3R ll4       p\        \        4      R V3R ll4       p\        W#4      pV! V4       V P	                  S^,          WB334       V P	                  S^,          WB3WC334       R# )z1
Tracing keeps track of forwarding to observers.
)rY   rZ   	log_tracec                (    V ^8  d   QhR\         RR/# r   r   r   Nri   )r   s   "r   r   2LogPublisherTests.test_trace.<locals>.__annotate__        	 	( 	t 	r   c           
         < SP                  ^\        \        \        \        \        3,          ,          \        V R,          4      4      4       R# )   r   N
setdefaultr   r   r   r
   tupler   tracess   &r   r.   (LogPublisherTests.test_trace.<locals>.o1   5    4eFL$89:E!K.<QRr   c                (    V ^8  d   QhR\         RR/# r   ri   )r   s   "r   r   r      r   r   c           
         < SP                  ^\        \        \        \        \        3,          ,          \        V R,          4      4      4       R# )r   r   Nr   r   s   &r   r/   (LogPublisherTests.test_trace.<locals>.o2   r   r   N)r[   r   r
   r   r+   )r   r^   r.   r/   r   r   s   &    @r   
test_traceLogPublisherTests.test_trace   s     R0@B
 
\	"	 
#	
 
\	"	 
#	
 !(	%i_$67i_yo$FGr   r   N)r   r   r   r   __doc__r    r0   r;   rB   rL   rT   rb   rx   r   r   r   r   )r   s   @r   r   r      su      > >
B 
BF F
> 
>> >& &() )@ .H Hr   r   N)r   typingr   r   r   r   zope.interfacer   zope.interface.exceptionsr   zope.interface.verifyr   twisted.trialr	   _interfacesr
   r   _loggerr   	_observerr   TestCaser   r   r   r   <module>r      s=    + * & @ . " 0  $lH)) lHr   