Ë
    ojF  ã                   ó  — d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  G d„ de«      Z G d	„ d
e«      Z e«       j                  ej!                  «       «        e«       j                  ej!                  «       «       y)z/
Tests for implementations of L{IReactorTime}.
é    )ÚIReactorThreadsÚIReactorTime)ÚReactorBuilder)Úmsg)Úplatform)ÚSkipTestc                   ó"   — e Zd ZdZefZd„ Zd„ Zy)ÚTimeTestsBuilderzA
    Builder for defining tests relating to L{IReactorTime}.
    c                 ó|   — | j                  «       }|j                  d|j                  «       |j                  «        y)z?
        The reactor can be stopped by a delayed call.
        r   N)ÚbuildReactorÚ	callLaterÚstopÚrun)ÚselfÚreactors     úA/usr/lib/python3/dist-packages/twisted/internet/test/test_time.pyÚtest_delayedCallStopsReactorz-TimeTestsBuilder.test_delayedCallStopsReactor   s/   € ð ×#Ñ#Ó%ˆØ×Ñ˜!˜WŸ\™\Ô*Ø�‰�ó    c                 óh  ‡‡‡— | j                  «       Št        j                  ‰«      rd„ Šnt        d«      ‚‰j	                  ddz  dz   d„ «      }ˆfd„Š ‰‰ˆˆˆfd„«       ‰j                  «        | j                  |j                  «       «       | j                  |‰j                  «       «       y	)
z
        Scheduling a delayed call at a point in the extreme future does not
        prevent normal reactor operation.
        c                 ó@   — t        d|¬«       | j                  |«       y )Nz.Thread-based event-source scheduling %(event)r)ÚformatÚevent)r   ÚcallFromThread)r   r   s     r   ÚeventSourcez=TimeTestsBuilder.test_distantDelayedCall.<locals>.eventSource&   s    € ÜØKÐSXõð ×&Ñ& uÕ-r   z=Do not know how to synthesize non-time event to stop the testé   é€   é   c                   ó   — y ©N© r    r   r   ú<lambda>z:TimeTestsBuilder.test_distantDelayedCall.<locals>.<lambda>2   s   � r   c                  ó<   •— t        d«       ‰ j                  «        y )NzStopping the reactor)r   r   )r   s   €r   r   z6TimeTestsBuilder.test_distantDelayedCall.<locals>.stop4   s   ø€ ÜÐ&Ô'Ø�L‰L�Nr   c                  ó   •—  ‰ ‰‰«      S r   r    )r   r   r   s   €€€r   r!   z:TimeTestsBuilder.test_distantDelayedCall.<locals>.<lambda><   s   ø€ ¡[°¸$Ó%?€ r   N)
r   r   Ú
providedByr   r   r   Ú
assertTrueÚactiveÚassertInÚgetDelayedCalls)r   ÚdelayedCallr   r   r   s     @@@r   Útest_distantDelayedCallz(TimeTestsBuilder.test_distantDelayedCall   sŸ   ú€ ð
 ×#Ñ#Ó%ˆÜ×%Ñ% gÔ.ó.ô ØOóð ð
 ×'Ñ'¨¨3©°©
±LÓAˆô	ñ 	�GÕ?Ô@ð 	�‰Œð 	�‰˜×*Ñ*Ó,Ô-Ø�‰�k 7×#:Ñ#:Ó#<Õ=r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚrequiredInterfacesr   r*   r    r   r   r
   r
      s   „ ñð '˜Ðòó*>r   r
   c                   óH   — e Zd ZdZefZ ej                  «       rdndgZd„ Z	y)ÚGlibTimeTestsBuilderza
    Builder for defining tests relating to L{IReactorTime} for reactors based
    off glib.
    z,twisted.internet.gireactor.PortableGIReactorz$twisted.internet.gireactor.GIReactorc                 óÖ   ‡‡‡— ddl m} | j                  «       Šg Šˆˆfd„}ˆˆfd„Š‰j                  |j                  d|«       | j                  ‰d«       | j                  ‰dg«       y)	z¶
        A
        L{reactor.callLater<twisted.internet.interfaces.IReactorTime.callLater>}
        call scheduled from a C{gobject.timeout_add}
        call is run on time.
        r   )ÚGObjectc                  ó*   •— ‰j                  d‰ «       y)Nr   )r   )Úcallbackr   s   €€r   Ú	gschedulez8GlibTimeTestsBuilder.test_timeout_add.<locals>.gschedulef   s   ø€ Ø×Ñ˜a Ô*Ør   c                  óH   •— ‰j                  d«       ‰ j                  «        y )NT)Úappendr   )r   Úresults   €€r   r5   z7GlibTimeTestsBuilder.test_timeout_add.<locals>.callbackj   s   ø€ Ø�M‰M˜$ÔØ�L‰L�Nr   é
   é   TN)Úgi.repositoryr3   r   ÚcallWhenRunningÚtimeout_addÚ
runReactorÚassertEqual)r   r3   r6   r5   r   r9   s      @@@r   Útest_timeout_addz%GlibTimeTestsBuilder.test_timeout_addY   s_   ú€ õ 	*à×#Ñ#Ó%ˆàˆõ	õ	ð 	×Ñ × 3Ñ 3°R¸ÔCØ�‰˜ Ô#Ø×Ñ˜ $ Õ(r   N)
r+   r,   r-   r.   r   r/   r   Ú	isWindowsÚ	_reactorsrA   r    r   r   r1   r1   K   s5   „ ñð
 '˜Ðð ˆ8×ÑÔñ 	7à3ð€Ió)r   r1   N)r.   Útwisted.internet.interfacesr   r   Ú#twisted.internet.test.reactormixinsr   Útwisted.python.logr   Útwisted.python.runtimer   Útwisted.trial.unittestr   r
   r1   ÚglobalsÚupdateÚmakeTestCaseClassesr    r   r   ú<module>rL      sl   ðñ÷ FÝ >Ý "Ý +Ý +ô9>�~ô 9>ôx%)˜>ô %)ñP ƒ	× Ñ Ð!×5Ñ5Ó7Ô 8Ù ƒ	× Ñ Ð%×9Ñ9Ó;Õ <r   