o
    ¼>h`  ã                   @   sl   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d„Z	e	ƒ  G d	d
„ d
eeƒZ
eƒ  e
 ¡ ¡ dS )é    )ÚTYPE_CHECKINGÚList)ÚSynchronousTestCaseé   )ÚReactorBuilderÚreturnNc                   C   s   dS )z0
    Do-nothing callable. Stub for testing.
    N© r   r   r   ú„/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/twisted/internet/test/test_cfreactor.pyÚnoop   s    r
   c                   @   s>   e Zd ZdZdgZddd„Zddd„Zdd	d
„Zddd„ZdS )ÚCoreFoundationSpecificTestszN
    Tests for platform interactions of the CoreFoundation-based reactor.
    z$twisted.internet.cfreactor.CFReactorr   Nc                 C   s>   |   ¡ }| 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Úrr   r   r	   Útest_whiteboxStopSimulating   s
   
z7CoreFoundationSpecificTests.test_whiteboxStopSimulatingc                    sf   |   ¡ }| dt¡}|   ¡ ‰ d‡ ‡fdd„}d‡ fd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                      s   ˆ   dˆ¡ d S )Nr   )r   r   ©Úr2Úr2stopr   r	   ÚstopBlocking3   s   zGCoreFoundationSpecificTests.test_callLaterLeakage.<locals>.stopBlockingc                      s   ˆ   ¡  d S ©N)Ústopr   )r   r   r	   r   6   s   zACoreFoundationSpecificTests.test_callLaterLeakage.<locals>.r2stop©r   N)r   r   r
   r   ÚassertEqualÚgetDelayedCalls)r   r   Údelayedr   r   r   r	   Útest_callLaterLeakage&   s   	
z1CoreFoundationSpecificTests.test_callLaterLeakagec                 C   sb   |   ¡ }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   r   r   r	   Útest_whiteboxIterate=   s   z0CoreFoundationSpecificTests.test_whiteboxIteratec                    sV   |   ¡ ‰g ‰d	‡‡fdd„‰ d	‡ ‡fd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                      s   ˆ   ¡  ˆ d¡ d S )NÚyes)r   r!   r   )r   Ústoppedr   r	   ÚdoStopU   s   z9CoreFoundationSpecificTests.test_noTimers.<locals>.doStopc                      s   ˆ  ˆ ¡ d S r   )ÚcallFromThreadr   )r'   r   r   r	   ÚsleepThenStopY   s   z@CoreFoundationSpecificTests.test_noTimers.<locals>.sleepThenStopr   r%   r   )r   r   ÚcallInThreadÚrunr   )r   r)   r   )r'   r   r&   r	   Útest_noTimersN   s   z)CoreFoundationSpecificTests.test_noTimersr   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	_reactorsr   r    r$   r,   r   r   r   r	   r      s    



r   r   )Útypingr   r   Útwisted.trial.unittestr   Úreactormixinsr   ÚfakeBaseÚobjectr
   r   ÚglobalsÚupdateÚmakeTestCaseClassesr   r   r   r	   Ú<module>   s    
P