
    Yf`                         d dl mZmZ d dlmZ ddlmZ ereZneZd
dZ	 e	              G d d	ee          Z
 e                                e
                                           dS )    )TYPE_CHECKINGList)SynchronousTestCase   )ReactorBuilderreturnNc                      dS )z0
    Do-nothing callable. Stub for testing.
    N r
       V/var/www/html/env/lib/python3.11/site-packages/twisted/internet/test/test_cfreactor.pynoopr      s      r   c                   8    e Zd ZdZdgZd	dZd	dZd	dZd	dZdS )
CoreFoundationSpecificTestszN
    Tests for platform interactions of the CoreFoundation-based reactor.
    z$twisted.internet.cfreactor.CFReactorr   Nc                     |                                  }|                    d|j                   |                    dt                     |                     |           |                     |j        d           dS )zO
        CFReactor's simulation timer is None after CFReactor crashes.
        r   d   N)buildReactor	callLatercrashr   
runReactorassertIs_currentSimulator)selfrs     r   test_whiteboxStopSimulatingz7CoreFoundationSpecificTests.test_whiteboxStopSimulating   sn     	Aqw	Ca)400000r   c                 R   |                                  }|                    dt                    }|                                  dfd}dfd                    d|           |                                |                     |                                |g           dS )a\  
        callLater should not leak global state into CoreFoundation which will
        be invoked by a different reactor running the main loop.

        @note: this test may actually be usable for other reactors as well, so
            we may wish to promote it to ensure this invariant across other
            foreign-main-loop reactors.
        r   r   Nc                  4                          d           d S )Nr   )r   )r2r2stops   r   stopBlockingzGCoreFoundationSpecificTests.test_callLaterLeakage.<locals>.stopBlocking3   s    LLF#####r   c                  0                                       d S N)stop)r   s   r   r   zACoreFoundationSpecificTests.test_callLaterLeakage.<locals>.r2stop6   s    GGIIIIIr   r   N)r   r   r   r   assertEqualgetDelayedCalls)r   r   delayedr   r   r   s       @@r   test_callLaterLeakagez1CoreFoundationSpecificTests.test_callLaterLeakage&   s     ++a&&  	$ 	$ 	$ 	$ 	$ 	$ 	$	 	 	 	 	 	 	Q%%%**,,wi88888r   c                 ~   |                                  }g }|                    d|j        d           |                    dt                    }|                                 |                     |j        d           |                     |                                |g           |                     |dg           dS )an  
        C{.iterate()} should remove the CFTimer that will run Twisted's
        callLaters from the loop, even if one is still pending.  We test this
        state indirectly with a white-box assertion by verifying the
        C{_currentSimulator} is set to C{None}, since CoreFoundation does not
        allow us to enumerate all active timers or sources.
        r   r   r   N)	r   r   appendr   iterater   r   r$   r%   )r   r   xr&   s       r   test_whiteboxIteratez0CoreFoundationSpecificTests.test_whiteboxIterate=   s     	Aqx###++c4((			a)4000**,,wi888QC     r   c                     |                                  g dfddfd}                    dj        |                                            |                     dg           dS )zS
        The loop can wake up just fine even if there are no timers in it.
        r   Nc                  Z                                                           d           d S )Nyes)r"   r)   )r   stoppeds   r   doStopz9CoreFoundationSpecificTests.test_noTimers.<locals>.doStopU   s(    FFHHHNN5!!!!!r   c                  2                                     d S r!   )callFromThread)r1   r   s   r   sleepThenStopz@CoreFoundationSpecificTests.test_noTimers.<locals>.sleepThenStopY   s    V$$$$$r   r   r/   r#   )r   r   callInThreadrunr$   )r   r4   r1   r   r0   s     @@@r   test_noTimersz)CoreFoundationSpecificTests.test_noTimersN   s     	" 	" 	" 	" 	" 	" 	"	% 	% 	% 	% 	% 	% 	% 	
Aq~}555
 	
5'*****r   r#   )	__name__
__module____qualname____doc__	_reactorsr   r'   r,   r7   r
   r   r   r   r      sx          88I1 1 1 19 9 9 9.! ! ! !"+ + + + + +r   r   r#   )typingr   r   twisted.trial.unittestr   reactormixinsr   fakeBaseobjectr   r   globalsupdatemakeTestCaseClassesr
   r   r   <module>rE      s    & & & & & & & & 6 6 6 6 6 6 ) ) ) ) ) ) "HHH    M+ M+ M+ M+ M+.( M+ M+ M+` 		  ,@@BB C C C C Cr   