§
    ÈtºfM£  ã                   ó  — d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z	m
Z
mZ ddlmZ ddlmZmZ dd	lmZmZmZmZmZ dd
lmZmZ ddlmZ ddlmZ ddlmZm Z  ddl!m"Z" ddl#m$Z$m%Z% d„ Z& ee¦  «         G d„ d¦  «        ¦   «         Z' eee'¦  «          ee¦  «         G d„ d¦  «        ¦   «         Z( eee'¦  «          G d„ de%¦  «        Z) G d„ de%¦  «        Z* G d„ d¦  «        Z+d!d„Z,e fd„Z-dZ. G d„ d e$¦  «        Z/dS )"zœ
Tests for (new code in) L{twisted.application.internet}.

@var AT_LEAST_ONE_ATTEMPT: At least enough seconds for L{ClientService} to make
    one attempt.
é    N)Úimplementer)ÚverifyClass)Úinternet)ÚClientServiceÚStreamServerEndpointServiceÚTimerService)Útask)ÚCancelledErrorÚDeferred)ÚIFileDescriptorReceiverÚIHalfCloseableProtocolÚIListeningPortÚIStreamClientEndpointÚIStreamServerEndpoint)ÚFactoryÚProtocol)ÚClock)ÚStringTransport)ÚformatEventÚglobalLogPublisher)ÚFailure)ÚSynchronousTestCaseÚTestCasec                  ó   — dS )zM
    A fake target function for testing TimerService which does nothing.
    N© r   ó    úe/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/application/test/test_internet.pyÚfakeTargetFunctionr   )   s	   € ð 	€Dr   c                   óN   — e Zd ZdZdZdZdZ e¦   «         ZdZ	d„ Z
d„ Zd„ Zd„ ZdS )Ú
FakeServeraq  
    In-memory implementation of L{IStreamServerEndpoint}.

    @ivar result: The L{Deferred} resulting from the call to C{listen}, after
        C{listen} has been called.

    @ivar factory: The factory passed to C{listen}.

    @ivar cancelException: The exception to errback C{self.result} when it is
        cancelled.

    @ivar port: The L{IListeningPort} which C{listen}'s L{Deferred} will fire
        with.

    @ivar listenAttempts: The number of times C{listen} has been invoked.

    @ivar failImmediately: If set, the exception to fail the L{Deferred}
        returned from C{listen} before it is returned.
    Nr   c                 ó,   — t          ¦   «         | _        d S ©N)ÚFakePortÚport©Úselfs    r   Ú__init__zFakeServer.__init__L   s   € Ý‘J”JˆŒ	ˆ	ˆ	r   c                 ó¼   ‡ — ‰ xj         dz  c_         |‰ _        t          ˆ fd„¬¦  «        ‰ _        ‰ j        �‰ j                             ‰ j        ¦  «         ‰ j        S )zê
        Return a Deferred and store it for future use.  (Implementation of
        L{IStreamServerEndpoint}).

        @param factory: the factory to listen with

        @return: a L{Deferred} stored in L{FakeServer.result}
        é   c                 ó8   •— |                       ‰j        ¦  «        S r"   )ÚerrbackÚcancelException)Údr&   s    €r   ú<lambda>z#FakeServer.listen.<locals>.<lambda>Z   s   ø€ °1·9²9¸TÔ=QÑ3RÔ3R€ r   )Ú	canceller)ÚlistenAttemptsÚfactoryr   ÚresultÚfailImmediatelyr+   )r&   r1   s   ` r   ÚlistenzFakeServer.listenO   sf   ø€ ð 	ÐÔ˜qÑ ÐÔØˆŒÝÐ)RÐ)RÐ)RÐ)RÐSÑSÔSˆŒØÔÐ+ØŒK×Ò Ô 4Ñ5Ô5Ð5ØŒ{Ðr   c                 óD   — | j                              | j        ¦  «         dS )z°
        Test code should invoke this method after causing C{listen} to be
        invoked in order to fire the L{Deferred} previously returned from
        C{listen}.
        N)r2   Úcallbackr$   r%   s    r   ÚstartedListeningzFakeServer.startedListening_   s"   € ð 	Œ×Ò˜TœYÑ'Ô'Ð'Ð'Ð'r   c                 óD   — | j         j                             d¦  «         dS )a  
        Test code should invoke this method after causing C{stopListening} to
        be invoked on the port fired from the L{Deferred} returned from
        C{listen} in order to cause the L{Deferred} returned from
        C{stopListening} to fire.
        N)r$   Údeferredr6   r%   s    r   ÚstoppedListeningzFakeServer.stoppedListeningg   s#   € ð 	Œ	Ô×#Ò# DÑ)Ô)Ð)Ð)Ð)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r2   r1   r3   r
   r,   r0   r'   r4   r7   r:   r   r   r   r    r    0   s}   € € € € € ðð ð( €FØ€GØ€OØ$�nÑ&Ô&€OØ€Nðð ð ðð ð ð (ð (ð (ð*ð *ð *ð *ð *r   r    c                   ó(   — e Zd ZdZdZd„ Zd„ Zd„ ZdS )r#   zs
    Fake L{IListeningPort} implementation.

    @ivar deferred: The L{Deferred} returned by C{stopListening}.
    Nc                 ó6   — t          ¦   «         | _        | j        S )z`
        Stop listening.

        @return: a L{Deferred} stored in L{FakePort.deferred}
        )r   r9   r%   s    r   ÚstopListeningzFakePort.stopListening~   s   € õ !™
œ
ˆŒØŒ}Ðr   c                 ó   — d S r"   r   r%   s    r   ÚgetHostzFakePort.getHost‡   ó   € àˆr   c                 ó   — d S r"   r   r%   s    r   ÚstartListeningzFakePort.startListening‹   rD   r   )r;   r<   r=   r>   r9   rA   rC   rF   r   r   r   r#   r#   t   sR   € € € € € ðð ð €Hðð ð ðð ð ðð ð ð ð r   r#   c                   ó\   — e Zd ZdZd„ Zd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚEndpointServiceTestsz4
    Tests for L{twisted.application.internet}.
    c                 ó�   — t          ¦   «         | _        t          ¦   «         | _        t	          | j        | j        ¦  «        | _        dS )zp
        Construct a stub server, a stub factory, and a
        L{StreamServerEndpointService} to test.
        N)r    Ú
fakeServerr   r1   r   Úsvcr%   s    r   ÚsetUpzEndpointServiceTests.setUp˜   s3   € õ
 %™,œ,ˆŒÝ‘y”yˆŒÝ.¨t¬ÀÄÑMÔMˆŒˆˆr   c                 ó‚   — | j                              ¦   «          |                      | j        | j        j        ¦  «         dS )z‡
        L{StreamServerEndpointService.privilegedStartService} calls its
        endpoint's C{listen} method with its factory.
        N)rK   ÚprivilegedStartServiceÚassertIdenticalr1   rJ   r%   s    r   Útest_privilegedStartServicez0EndpointServiceTests.test_privilegedStartService¡   s;   € ð
 	Œ×'Ò'Ñ)Ô)Ð)Ø×Ò˜Tœ\¨4¬?Ô+BÑCÔCÐCÐCÐCr   Nc                 óœ   — t          ¦   «         | j        _        d| j        _        |                      t           |p| j        j        ¦  «         dS )a@  
        L{StreamServerEndpointService.startService} should raise synchronously
        if the L{Deferred} returned by its wrapped
        L{IStreamServerEndpoint.listen} has already fired with an errback and
        the L{StreamServerEndpointService}'s C{_raiseSynchronously} flag has
        been set.  This feature is necessary to preserve compatibility with old
        behavior of L{twisted.internet.strports.service}, which is to return a
        service which synchronously raises an exception from C{startService}
        (so that, among other things, twistd will not start running).  However,
        since L{IStreamServerEndpoint.listen} may fail asynchronously, it is a
        bad idea to rely on this behavior.

        @param thunk: If specified, a callable to execute in place of
            C{startService}.
        TN)ÚZeroDivisionErrorrJ   r3   rK   Ú_raiseSynchronouslyÚassertRaisesÚstartService)r&   Úthunks     r   Ú(test_synchronousRaiseRaisesSynchronouslyz=EndpointServiceTests.test_synchronousRaiseRaisesSynchronously©   sE   € õ  +<Ñ*=Ô*=ˆŒÔ'Ø'+ˆŒÔ$Ø×ÒÕ+¨UÐ-K°d´hÔ6KÑLÔLÐLÐLÐLr   c                 óD   — |                       | j        j        ¦  «         dS )zÓ
        L{StreamServerEndpointService.privilegedStartService} should behave the
        same as C{startService} with respect to
        L{EndpointServiceTests.test_synchronousRaiseRaisesSynchronously}.
        N)rW   rK   rN   r%   s    r   Útest_synchronousRaisePrivilegedz4EndpointServiceTests.test_synchronousRaisePrivileged½   s#   € ð 	×5Ò5°d´hÔ6UÑVÔVÐVÐVÐVr   c                 ó  — | j                              ¦   «          | j        j                             t          ¦   «         ¦  «         |                      t
          ¦  «        }|                      t          |¦  «        d¦  «         dS )a  
        L{StreamServerEndpointService.startService} and
        L{StreamServerEndpointService.privilegedStartService} should both log
        an exception when the L{Deferred} returned from their wrapped
        L{IStreamServerEndpoint.listen} fails.
        r)   N)	rK   rU   rJ   r2   r+   rR   ÚflushLoggedErrorsÚassertEqualÚlen©r&   Úloggeds     r   Útest_failReportsErrorz*EndpointServiceTests.test_failReportsErrorÅ   sn   € ð 	Œ×ÒÑÔÐØŒÔ×&Ò&Õ'8Ñ':Ô':Ñ;Ô;Ð;Ø×'Ò'Õ(9Ñ:Ô:ˆØ×Ò�˜V™œ aÑ(Ô(Ð(Ð(Ð(r   c                 ó   — d| j         _        | j                              ¦   «          | j        j                             t          ¦   «         ¦  «         |                      t          ¦  «        }|                      t          |¦  «        d¦  «         dS )aB  
        L{StreamServerEndpointService.startService} and
        L{StreamServerEndpointService.privilegedStartService} should both log
        an exception when the L{Deferred} returned from their wrapped
        L{IStreamServerEndpoint.listen} fails asynchronously, even if
        C{_raiseSynchronously} is set.
        Tr)   N)
rK   rS   rU   rJ   r2   r+   rR   r[   r\   r]   r^   s     r   Ú!test_asynchronousFailReportsErrorz6EndpointServiceTests.test_asynchronousFailReportsErrorÑ   sx   € ð (,ˆŒÔ$ØŒ×ÒÑÔÐØŒÔ×&Ò&Õ'8Ñ':Ô':Ñ;Ô;Ð;Ø×'Ò'Õ(9Ñ:Ô:ˆØ×Ò�˜V™œ aÑ(Ô(Ð(Ð(Ð(r   c                 óâ   — t          ¦   «         | j        _        | j                             ¦   «          |                      t           ¦  «        }|                      t          |¦  «        d¦  «         dS )zŸ
        Without the C{_raiseSynchronously} compatibility flag, failing
        immediately has the same behavior as failing later; it logs the error.
        r)   N)rR   rJ   r3   rK   rU   r[   r\   r]   r^   s     r   Ú test_synchronousFailReportsErrorz5EndpointServiceTests.test_synchronousFailReportsErrorß   s^   € õ
 +<Ñ*=Ô*=ˆŒÔ'ØŒ×ÒÑÔÐØ×'Ò'Õ(9Ñ:Ô:ˆØ×Ò�˜V™œ aÑ(Ô(Ð(Ð(Ð(r   c                 óÂ   — | j                              ¦   «          |                      | j        | j        j        ¦  «         |                      | j         j        d¦  «         dS )zÃ
        L{StreamServerEndpointService.startService} sets the C{running} flag,
        and calls its endpoint's C{listen} method with its factory, if it
        has not yet been started.
        TN)rK   rU   rO   r1   rJ   r\   Úrunningr%   s    r   Útest_startServiceUnstartedz/EndpointServiceTests.test_startServiceUnstartedé   sV   € ð 	Œ×ÒÑÔÐØ×Ò˜Tœ\¨4¬?Ô+BÑCÔCÐCØ×Ò˜œÔ)¨4Ñ0Ô0Ð0Ð0Ð0r   c                 óà   — |                       ¦   «          | j                             ¦   «          |                      | j        j        d¦  «         |                      | j        j        d¦  «         dS )zš
        L{StreamServerEndpointService.startService} sets the C{running} flag,
        but nothing else, if the service has already been started.
        r)   TN)rP   rK   rU   r\   rJ   r0   rf   r%   s    r   Útest_startServiceStartedz-EndpointServiceTests.test_startServiceStartedó   sf   € ð
 	×(Ò(Ñ*Ô*Ð*ØŒ×ÒÑÔÐØ×Ò˜œÔ7¸Ñ;Ô;Ð;Ø×Ò˜œÔ)¨4Ñ0Ô0Ð0Ð0Ð0r   c                 ó  — | j                              ¦   «          | j                             ¦   «          | j                              ¦   «          | j                              ¦   «         }g }|                     |j        ¦  «         |                      t          |¦  «        d¦  «         | j         
                    ¦   «          |                      t          |¦  «        d¦  «         |                      | j         j        ¦  «         dS )zã
        L{StreamServerEndpointService.stopService} calls C{stopListening} on
        the L{IListeningPort} returned from its endpoint, returns the
        C{Deferred} from stopService, and sets C{running} to C{False}.
        r   r)   N)rK   rN   rJ   r7   rU   ÚstopServiceÚaddCallbackÚappendr\   r]   r:   ÚassertFalserf   ©r&   r2   Úls      r   Útest_stopServicez%EndpointServiceTests.test_stopServiceý   sÙ   € ð 	Œ×'Ò'Ñ)Ô)Ð)ØŒ×(Ò(Ñ*Ô*Ð*àŒ×ÒÑÔÐØ”×%Ò%Ñ'Ô'ˆØˆØ×Ò˜1œ8Ñ$Ô$Ð$Ø×Ò�˜Q™œ Ñ#Ô#Ð#ØŒ×(Ò(Ñ*Ô*Ð*Ø×Ò�˜Q™œ Ñ#Ô#Ð#Ø×Ò˜œÔ)Ñ*Ô*Ð*Ð*Ð*r   c                 ó,  — | j                              ¦   «          | j                              ¦   «         }g }|                     |j        ¦  «         |                      |dg¦  «         |                      |                      t          ¦  «        g ¦  «         dS )zÚ
        L{StreamServerEndpointService.stopService} cancels the L{Deferred}
        returned by C{listen} if it has not yet fired.  No error will be logged
        about the cancellation of the listen attempt.
        N)rK   rN   rk   ÚaddBothrm   r\   r[   r
   ro   s      r   Ú#test_stopServiceBeforeStartFinishedz8EndpointServiceTests.test_stopServiceBeforeStartFinished  s†   € ð 	Œ×'Ò'Ñ)Ô)Ð)Ø”×%Ò%Ñ'Ô'ˆØˆØ�Š�q”xÑ Ô Ð Ø×Ò˜˜T˜FÑ#Ô#Ð#Ø×Ò˜×/Ò/µÑ?Ô?ÀÑDÔDÐDÐDÐDr   c                 óz  — t          ¦   «         | j        _        | j                             ¦   «          | j                             ¦   «         }g }|                     |j        ¦  «         |                      |dg¦  «         |  	                    t           ¦  «        }|                      t          |¦  «        d¦  «         dS )zá
        L{StreamServerEndpointService.stopService} cancels the L{Deferred}
        returned by C{listen} if it has not fired yet.  An error will be logged
        if the resulting exception is not L{CancelledError}.
        Nr)   )rR   rJ   r,   rK   rN   rk   rl   rm   r\   r[   r]   )r&   r2   rp   ÚstoppingErrorss       r   Ú test_stopServiceCancelStartErrorz5EndpointServiceTests.test_stopServiceCancelStartError  s¦   € õ +<Ñ*=Ô*=ˆŒÔ'ØŒ×'Ò'Ñ)Ô)Ð)Ø”×%Ò%Ñ'Ô'ˆØˆØ×Ò˜1œ8Ñ$Ô$Ð$Ø×Ò˜˜T˜FÑ#Ô#Ð#Ø×/Ò/Õ0AÑBÔBˆØ×Ò�˜^Ñ,Ô,¨aÑ0Ô0Ð0Ð0Ð0r   r"   )r;   r<   r=   r>   rL   rP   rW   rY   r`   rb   rd   rg   ri   rq   rt   rw   r   r   r   rH   rH   “   sç   € € € € € ðð ðNð Nð NðDð Dð DðMð Mð Mð Mð(Wð Wð Wð
)ð 
)ð 
)ð)ð )ð )ð)ð )ð )ð1ð 1ð 1ð1ð 1ð 1ð+ð +ð +ð$Eð Eð Eð1ð 1ð 1ð 1ð 1r   rH   c                   óN   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ ZdS )ÚTimerServiceTestsa)  
    Tests for L{twisted.application.internet.TimerService}.

    @type timer: L{TimerService}
    @ivar timer: service to test

    @type clock: L{task.Clock}
    @ivar clock: source of time

    @type deferred: L{Deferred}
    @ivar deferred: deferred returned by L{TimerServiceTests.call}.
    c                 ó¨   — t          d| j        ¦  «        | _        t          j        ¦   «         x| _        | j        _        t          ¦   «         | _        dS )z1
        Set up a timer service to test.
        é   N)r   ÚcallÚtimerr	   r   Úclockr   r9   r%   s    r   rL   zTimerServiceTests.setUp:  s=   € õ " ! T¤YÑ/Ô/ˆŒ
Ý(,¬
©¬Ð4ˆŒ
�T”ZÔ%Ý ™
œ
ˆŒˆˆr   c                 ó   — | j         S )z‚
        Function called by L{TimerService} being tested.

        @returns: C{self.deferred}
        @rtype: L{Deferred}
        )r9   r%   s    r   r|   zTimerServiceTests.callB  s   € ð Œ}Ðr   c                 ój  — | j                              ¦   «          |                      | j         j        d¦  «         |                      | j         j        t          j        ¦  «         |                      | j	        | j         j        j	        ¦  «         |                      | j         j        j        d¦  «         dS )z�
        When L{TimerService.startService} is called, it marks itself
        as running, creates a L{task.LoopingCall} and starts it.
        zService is startedzLoopingCall is startedN)
r}   rU   Ú
assertTruerf   ÚassertIsInstanceÚ_loopr	   ÚLoopingCallrO   r~   r%   s    r   Útest_startServicez#TimerServiceTests.test_startServiceK  s“   € ð
 	Œ
×ÒÑ!Ô!Ð!Ø�Š˜œ
Ô*Ð,@ÑAÔAÐAØ×Ò˜dœjÔ.µÔ0@ÑAÔAÐAØ×Ò˜TœZ¨¬Ô)9Ô)?Ñ@Ô@Ð@Ø�Š˜œ
Ô(Ô0Ð2JÑKÔKÐKÐKÐKr   c                 ó’   — g }|j         di f| j        _        | j                             ¦   «          |                      dg|¦  «         dS )zi
        When L{TimerService.startService} is called, it calls the function
        immediately.
        r"   N)rm   r}   r|   rU   r\   )r&   r2   s     r   Ú$test_startServiceRunsCallImmediatelyz6TimerServiceTests.test_startServiceRunsCallImmediatelyV  sM   € ð
 ˆØ!œ=¨'°2Ð6ˆŒ
ŒØŒ
×ÒÑ!Ô!Ð!Ø×Ò˜$˜ Ñ(Ô(Ð(Ð(Ð(r   c                 óì   ‡— t          j        ¦   «         Šˆfd„}|                      t          d|¦  «         | j                             ¦   «          |                      ‰| j        j        j        ¦  «         dS )z±
        L{TimerService.startService} uses L{internet._maybeGlobalReactor} to
        choose the reactor to pass to L{task.LoopingCall}
        uses the global reactor.
        c                 ó   •— ‰S r"   r   )ÚmaybeReactorÚ
otherClocks    €r   ÚgetOtherClockzKTimerServiceTests.test_startServiceUsesGlobalReactor.<locals>.getOtherClockh  s	   ø€ ØÐr   Ú_maybeGlobalReactorN)	r	   r   Úpatchr   r}   rU   rO   rƒ   r~   )r&   rŒ   r‹   s     @r   Ú"test_startServiceUsesGlobalReactorz4TimerServiceTests.test_startServiceUsesGlobalReactor`  sz   ø€ õ ”Z‘\”\ˆ
ð	ð 	ð 	ð 	ð 	ð 	�
Š
•8Ð2°MÑBÔBÐBØŒ
×ÒÑ!Ô!Ð!Ø×Ò˜Z¨¬Ô)9Ô)?Ñ@Ô@Ð@Ð@Ð@r   c                 ór  — | j                              ¦   «          | j                              ¦   «         }|                      |¦  «         |                      d| j         j        ¦  «         | j                             t          ¦   «         ¦  «         |  	                    |  
                    |¦  «        d¦  «         dS )z¦
        When L{TimerService.stopService} is called while a call is in progress.
        the L{Deferred} returned doesn't fire until after the call finishes.
        TN)r}   rU   rk   ÚassertNoResultr\   rf   r9   r6   ÚobjectrO   ÚsuccessResultOf©r&   r-   s     r   Útest_stopServiceWaitsz'TimerServiceTests.test_stopServiceWaitso  sž   € ð
 	Œ
×ÒÑ!Ô!Ð!ØŒJ×"Ò"Ñ$Ô$ˆØ×Ò˜AÑÔÐØ×Ò˜˜tœzÔ1Ñ2Ô2Ð2ØŒ×Ò�v™xœxÑ(Ô(Ð(Ø×Ò˜T×1Ò1°!Ñ4Ô4°dÑ;Ô;Ð;Ð;Ð;r   c                 ó  — | j                              ¦   «          | j                             t	          ¦   «         ¦  «         | j                              ¦   «         }|                      |                      |¦  «        d¦  «         dS )z•
        When L{TimerService.stopService} is called while a call isn't in progress.
        the L{Deferred} returned has already been fired.
        N)r}   rU   r9   r6   r’   rk   rO   r“   r”   s     r   Útest_stopServiceImmediatelyz-TimerServiceTests.test_stopServiceImmediately{  so   € ð
 	Œ
×ÒÑ!Ô!Ð!ØŒ×Ò�v™xœxÑ(Ô(Ð(ØŒJ×"Ò"Ñ$Ô$ˆØ×Ò˜T×1Ò1°!Ñ4Ô4°dÑ;Ô;Ð;Ð;Ð;r   c                 óœ  — | j                              ¦   «          | j                             t	          t          ¦   «         ¦  «        ¦  «         |                      t
          ¦  «        }|                      dt          |¦  «        ¦  «         | j          	                    ¦   «         }|  
                    |                      |¦  «        d¦  «         dS )z´
        When function passed to L{TimerService} returns a deferred that errbacks,
        the exception is logged, and L{TimerService.stopService} doesn't raise an error.
        r)   N)r}   rU   r9   r+   r   rR   r[   r\   r]   rk   rO   r“   )r&   Úerrorsr-   s      r   Útest_failedCallLogsErrorz*TimerServiceTests.test_failedCallLogsError…  sª   € ð
 	Œ
×ÒÑ!Ô!Ð!ØŒ×Ò�gÕ&7Ñ&9Ô&9Ñ:Ô:Ñ;Ô;Ð;Ø×'Ò'Õ(9Ñ:Ô:ˆØ×Ò˜�C ™KœKÑ(Ô(Ð(ØŒJ×"Ò"Ñ$Ô$ˆØ×Ò˜T×1Ò1°!Ñ4Ô4°dÑ;Ô;Ð;Ð;Ð;r   c                 ó:  — t          dt          ¦  «        }|                     ¦   «          t          j        |¦  «        }|                     ¦   «          t          j        |¦  «        }t          ¦   «         }t          |d|¦  «        }|  	                    ||¦  «         dS )zq
        When pickling L{internet.TimerService}, it won't pickle
        L{internet.TimerService._loop}.
        r)   rƒ   N©
r   r   rU   ÚpickleÚdumpsrk   Úloadsr’   ÚgetattrrO   ©r&   r}   ÚdumpedTimerÚloadedTimerÚnothingÚvalues         r   Ú$test_pickleTimerServiceNotPickleLoopz6TimerServiceTests.test_pickleTimerServiceNotPickleLoop‘  sŒ   € õ ˜QÕ 2Ñ3Ô3ˆØ×ÒÑÔÐÝ”l 5Ñ)Ô)ˆØ×ÒÑÔÐÝ”l ;Ñ/Ô/ˆÝ‘(”(ˆÝ˜ W¨gÑ6Ô6ˆØ×Ò˜W eÑ,Ô,Ð,Ð,Ð,r   c                 ó:  — t          dt          ¦  «        }|                     ¦   «          t          j        |¦  «        }|                     ¦   «          t          j        |¦  «        }t          ¦   «         }t          |d|¦  «        }|  	                    ||¦  «         dS )zy
        When pickling L{internet.TimerService}, it won't pickle
        L{internet.TimerService._loopFinished}.
        r)   Ú_loopFinishedNrœ   r¡   s         r   Ú,test_pickleTimerServiceNotPickleLoopFinishedz>TimerServiceTests.test_pickleTimerServiceNotPickleLoopFinished¡  sŒ   € õ ˜QÕ 2Ñ3Ô3ˆØ×ÒÑÔÐÝ”l 5Ñ)Ô)ˆØ×ÒÑÔÐÝ”l ;Ñ/Ô/ˆÝ‘(”(ˆÝ˜ _°gÑ>Ô>ˆØ×Ò˜W eÑ,Ô,Ð,Ð,Ð,r   N)r;   r<   r=   r>   rL   r|   r…   r‡   r�   r•   r—   rš   r¦   r©   r   r   r   ry   ry   ,  sº   € € € € € ðð ð#ð #ð #ðð ð ð	Lð 	Lð 	Lð)ð )ð )ðAð Að Að
<ð 
<ð 
<ð<ð <ð <ð
<ð 
<ð 
<ð-ð -ð -ð -ð -ð -ð -ð -r   ry   c                   ó   — e Zd ZdZd„ ZdS )ÚConnectInformationaË  
    Information about C{endpointForTesting}

    @ivar connectQueue: a L{list} of L{Deferred} returned from C{connect}.  If
        these are not already fired, you can fire them with no value and they
        will trigger building a factory.

    @ivar constructedProtocols: a L{list} of protocols constructed.

    @ivar passedFactories: a L{list} of L{IProtocolFactory}; the ones actually
        passed to the underlying endpoint / i.e. the reactor.
    c                 ó0   — g | _         g | _        g | _        d S r"   )ÚconnectQueueÚconstructedProtocolsÚpassedFactoriesr%   s    r   r'   zConnectInformation.__init__À  s    € ØˆÔØ$&ˆÔ!Ø!ˆÔÐÐr   N)r;   r<   r=   r>   r'   r   r   r   r«   r«   ²  s-   € € € € € ðð ð"ð "ð "ð "ð "r   r«   Fc                 óŽ   ‡ ‡— t          t          ¦  «         G ˆ ˆfd„d¦  «        ¦   «         }t          ¦   «         Š‰ |¦   «         fS )aD  
    Make a sample endpoint for testing.

    @param fireImmediately: If true, fire all L{Deferred}s returned from
        C{connect} immedaitely.

    @return: a 2-tuple of C{(information, endpoint)}, where C{information} is a
        L{ConnectInformation} describing the operations in progress on
        C{endpoint}.
    c                   ó   •— e Zd Zˆ ˆfd„ZdS )ú.endpointForTesting.<locals>.ClientTestEndpointc                 óâ   •‡— t          ¦   «         }‰j                             ‰¦  «         |j        ˆˆfd„¦   «         }‰j                             |¦  «         ‰r|                     d ¦  «         |S )Nc                 ó¬   •— ‰                      d ¦  «        }‰j                             |¦  «         t          ¦   «         }|                     |¦  «         |S r"   )ÚbuildProtocolr®   rm   r   ÚmakeConnection)ÚignoredÚprotocolÚ	transportr1   Úinfos      €€r   ÚcreateProtocolzNendpointForTesting.<locals>.ClientTestEndpoint.connect.<locals>.createProtocolØ  sQ   ø€ à"×0Ò0°Ñ6Ô6�ØÔ)×0Ò0°Ñ:Ô:Ð:Ý+Ñ-Ô-�	Ø×'Ò'¨	Ñ2Ô2Ð2Ø�r   )r   r¯   rm   rl   r­   r6   )r&   r1   r2   r»   ÚfireImmediatelyrº   s    `  €€r   Úconnectz6endpointForTesting.<locals>.ClientTestEndpoint.connectÔ  sˆ   øø€ Ý‘Z”ZˆFØÔ ×'Ò'¨Ñ0Ô0Ð0àÔð ð  ð  ð  ð  ñ  Ôð ð Ô×$Ò$ VÑ,Ô,Ð,Øð &Ø—’ Ñ%Ô%Ð%ØˆMr   N)r;   r<   r=   r½   )r¼   rº   s   €€r   ÚClientTestEndpointr²   Ò  s3   ø€ € € € € ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	r   r¾   )r   r   r«   )r¼   r¾   rº   s   ` @r   ÚendpointForTestingr¿   Æ  ss   øø€ õ Õ&Ñ'Ô'ðð ð ð ð ð ð ð ñ ô ñ (Ô'ðõ$ ÑÔ€DØÐ#Ð#Ñ%Ô%Ð%Ð%r   c                 óz   ‡‡— g Š‰                      ‰j        ¦  «         |                      ˆˆfd„¦  «         ˆfd„S )a6  
    Catch the global log stream.

    @param testCase: The test case to add a cleanup to.

    @param logPublisher: the log publisher to add and remove observers for.

    @return: a 0-argument callable that returns a list of textual log messages
        for comparison.
    @rtype: L{list} of L{unicode}
    c                  ó8   •— ‰                       ‰j        ¦  «        S r"   )ÚremoveObserverrm   )ÚlogPublisherÚlogss   €€r   r.   zcatchLogs.<locals>.<lambda>÷  s   ø€  × ;Ò ;¸D¼KÑ HÔ H€ r   c                  ó   •— d„ ‰ D ¦   «         S )Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )r   )Ú.0Úevents     r   ú
<listcomp>z/catchLogs.<locals>.<lambda>.<locals>.<listcomp>ø  s    € Ð9Ð9Ð9¨5•K Ñ&Ô&Ð9Ð9Ð9r   r   )rÄ   s   €r   r.   zcatchLogs.<locals>.<lambda>ø  s   ø€ Ð9Ð9°DÐ9Ñ9Ô9€ r   )ÚaddObserverrm   Ú
addCleanup)ÚtestCaserÃ   rÄ   s    `@r   Ú	catchLogsrÍ   é  sQ   øø€ ð €DØ×Ò˜Tœ[Ñ)Ô)Ð)Ø×ÒÐHÐHÐHÐHÐHÑIÔIÐIØ9Ð9Ð9Ð9Ð9r   g      Y@c                   óÔ   — e Zd ZdZddefd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z d„ Z!d „ Z"d!„ Z#d"S )#ÚClientServiceTestsz%
    Tests for L{ClientService}.
    Tc                 óœ  ‡ ‡‡‡‡— i }|                      t          ¦   «         ¬¦  «         |                      |¦  «         |d         Št          |¬¦  «        \  }}g xŠ|_         G ˆˆfd„dt          ¦  «        } |¦   «         x|_        }	t          ||	fi |¤ŽŠˆˆ ˆfd„}
‰                      |
¦  «         |r‰                     ¦   «          |‰fS )aL  
        Create a L{ClientService} along with a L{ConnectInformation} indicating
        the connections in progress on its endpoint.

        @param fireImmediately: Should all of the endpoint connection attempts
            fire synchronously?
        @type fireImmediately: L{bool}

        @param startService: Should the L{ClientService} be started before
            being returned?
        @type startService: L{bool}

        @param protocolType: a 0-argument callable returning a new L{IProtocol}
            provider to be used for application-level protocol connections.

        @param kw: Arbitrary keyword arguments to be passed on to
            L{ClientService}

        @return: a 2-tuple of L{ConnectInformation} (for information about test
            state) and L{ClientService} (the system under test).  The
            L{ConnectInformation} has 2 additional attributes;
            C{applicationFactory} and C{applicationProtocols}, which refer to
            the unwrapped protocol factory and protocol instances passed in to
            L{ClientService} respectively.
        ©r~   r~   ©r¼   c                   ó&   •‡ — e Zd Z”Zˆ ˆfd„Zˆ xZS )ú>ClientServiceTests.makeReconnector.<locals>.RememberingFactoryc                 ót   •— t          ¦   «                              |¦  «        }‰                     |¦  «         |S r"   )Úsuperrµ   rm   )r&   Úaddrr2   Ú	__class__ÚapplicationProtocolss      €€r   rµ   zLClientServiceTests.makeReconnector.<locals>.RememberingFactory.buildProtocol0  s3   ø€ Ý™œ×.Ò.¨tÑ4Ô4�Ø$×+Ò+¨FÑ3Ô3Ð3Ø�r   )r;   r<   r=   r¸   rµ   Ú__classcell__)rØ   rÙ   ÚprotocolTypes   @€€r   ÚRememberingFactoryrÔ   -  sC   øø€ € € € € Ø#ˆHðð ð ð ð ð ð ð ð ð r   rÜ   c                  óœ   •— d ‰_         ‰j        r‰                     ¦   «          ‰                     ‰                      ¦   «         g ¦  «         d S r"   )Ú	_protocolrf   rk   r\   ÚgetDelayedCalls)r~   r&   Úservices   €€€r   Ústopz0ClientServiceTests.makeReconnector.<locals>.stop9  sQ   ø€ Ø $ˆGÔØŒð &Ø×#Ò#Ñ%Ô%Ð%ð ×Ò˜U×2Ò2Ñ4Ô4°bÑ9Ô9Ð9Ð9Ð9r   )	Úupdater   r¿   rÙ   r   ÚapplicationFactoryr   rË   rU   )r&   r¼   rU   rÛ   ÚkwÚnkwÚcqÚendpointrÜ   r1   rá   rÙ   r~   rà   s   `  `       @@@r   ÚmakeReconnectorz"ClientServiceTests.makeReconnector  s%  øøøøø€ ð8 ˆØ�
Š
�™œˆ
Ñ!Ô!Ð!Ø�
Š
�2‰ŒˆØ�G”ˆÝ)¸/ÐJÑJÔJ‰ˆˆHð :<Ð;Ð˜rÔ6ð	ð 	ð 	ð 	ð 	ð 	ð 	ð 	¥ñ 	ô 	ð 	ð +=Ð*<Ñ*>Ô*>Ð>ˆÔ å ¨'Ð9Ð9°SÐ9Ð9ˆð	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	�Š˜ÑÔÐØð 	#Ø× Ò Ñ"Ô"Ð"Ø�7ˆ{Ðr   c                 óˆ   — |                       d¬¦  «        \  }}|                      t          |j        ¦  «        d¦  «         dS )zL
        When the service is started, a connection attempt is made.
        FrÒ   r)   N)rè   r\   r]   r­   )r&   ræ   rà   s      r   r…   z$ClientServiceTests.test_startServiceF  sD   € ð ×*Ò*¸5Ð*ÑAÔA‰ˆˆGØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ð1Ð1r   c                 óð   — |                       ¦   «         \  }}|j        }|                      |j        d¦  «         |j        d         }|                     ¦   «          |                      |j        d¦  «         dS )a!  
        Although somewhat obscure, L{IProtocolFactory} includes both C{doStart}
        and C{doStop} methods; ensure that when these methods are called on the
        factory that was passed to the reactor, the factory that was passed
        from the application receives them.
        r   r)   N)rè   rã   r\   ÚnumPortsr¯   ÚdoStart)r&   ræ   rà   ÚfirstAppFactoryÚfirstPassedFactorys        r   Útest_startStopFactoryz(ClientServiceTests.test_startStopFactoryM  sy   € ð ×*Ò*Ñ,Ô,‰ˆˆGØÔ/ˆØ×Ò˜Ô1°1Ñ5Ô5Ð5ØÔ/°Ô2ÐØ×"Ò"Ñ$Ô$Ð$Ø×Ò˜Ô1°1Ñ5Ô5Ð5Ð5Ð5r   c                 óf  — |                       ¦   «         \  }}|                     ¦   «         }|                      |¦  «         |j        d         }|                      |j        j        d¦  «         |                     t          t          ¦   «         ¦  «        ¦  «         |  
                    |¦  «         dS )z¸
        When the service is stopped, no further connect attempts are made.  The
        returned L{Deferred} fires when all outstanding connections have been
        stopped.
        r   TN)rè   rk   r‘   r®   r\   r¹   ÚdisconnectingÚconnectionLostr   Ú	Exceptionr“   ©r&   ræ   rà   r-   r¸   s        r   Útest_stopServiceWhileConnectedz1ClientServiceTests.test_stopServiceWhileConnected[  s¡   € ð ×*Ò*Ñ,Ô,‰ˆˆGØ×ÒÑ!Ô!ˆØ×Ò˜AÑÔÐØÔ*¨1Ô-ˆØ×Ò˜Ô+Ô9¸4Ñ@Ô@Ð@Ø×Ò¥­	©¬Ñ 4Ô 4Ñ5Ô5Ð5Ø×Ò˜QÑÔÐÐÐr   c                 ó.  — |                       ¦   «         \  }}|                     ¦   «         }|                      |¦  «         |j        d         }|                      |j        j        d¦  «         |                     ¦   «          |                      |¦  «         |                      t          |j        ¦  «        d¦  «         | 	                    t          t          ¦   «         ¦  «        ¦  «         |                      t          |j        ¦  «        d¦  «         dS )z—
        When L{ClientService} is restarted after having been connected, it
        waits to start connecting until after having disconnected.
        r   Tr)   r{   N)rè   rk   r‘   r®   r\   r¹   rñ   rU   r]   rò   r   ró   rô   s        r   Ú#test_startServiceWaitsForDisconnectz6ClientServiceTests.test_startServiceWaitsForDisconnecti  sõ   € ð
 ×*Ò*Ñ,Ô,‰ˆˆGØ×ÒÑ!Ô!ˆØ×Ò˜AÑÔÐØÔ*¨1Ô-ˆØ×Ò˜Ô+Ô9¸4Ñ@Ô@Ð@Ø×ÒÑÔÐØ×Ò˜AÑÔÐØ×Ò�˜RÔ4Ñ5Ô5°qÑ9Ô9Ð9Ø×Ò¥­	©¬Ñ 4Ô 4Ñ5Ô5Ð5Ø×Ò�˜RÔ4Ñ5Ô5°qÑ9Ô9Ð9Ð9Ð9r   c                 óÂ  — |                       d¬¦  «        \  }}|j        d                              d¦  «         |j        d         }|                     ¦   «         }|                      |¦  «         |                     ¦   «         }|                      |¦  «         |                     ¦   «          |                      |¦  «         |                      |¦  «         |                      |j	        j
        d¦  «         |                     t          t          ¦   «         ¦  «        ¦  «         |                      |¦  «         |j        d                              d¦  «         |                      t          |j        ¦  «        d¦  «         |                      |                      |¦  «        |j        d         ¦  «         |                     ¦   «         }|                      |¦  «         dS )a%  
        When L{ClientService} is stopping - that is,
        L{ClientService.stopService} has been called, but the L{Deferred} it
        returns has not fired yet - calling L{startService} will cause a new
        connection to be made, and new calls to L{whenConnected} to succeed.
        FrÒ   r   NTr)   r{   )rè   r­   r6   r®   rk   r‘   ÚwhenConnectedrU   r\   r¹   rñ   rò   r   ró   r“   r]   rO   rÙ   )r&   ræ   rà   ÚfirstÚstoppedÚnextProtocolÚsecondStoppeds          r   Útest_startServiceWhileStoppingz1ClientServiceTests.test_startServiceWhileStoppingy  sµ  € ð ×*Ò*¸5Ð*ÑAÔA‰ˆˆGØ
Œ˜Ô×#Ò# DÑ)Ô)Ð)ØÔ'¨Ô*ˆØ×%Ò%Ñ'Ô'ˆØ×Ò˜GÑ$Ô$Ð$Ø×,Ò,Ñ.Ô.ˆØ×Ò˜LÑ)Ô)Ð)Ø×ÒÑÔÐØ×Ò˜LÑ)Ô)Ð)Ø×Ò˜GÑ$Ô$Ð$Ø×Ò˜œÔ6¸Ñ=Ô=Ð=Ø×Ò�W¥Y¡[¤[Ñ1Ô1Ñ2Ô2Ð2Ø×Ò˜WÑ%Ô%Ð%Ø
Œ˜Ô×#Ò# DÑ)Ô)Ð)Ø×Ò�˜RÔ4Ñ5Ô5°qÑ9Ô9Ð9Ø×ÒØ× Ò  Ñ.Ô.°Ô0GÈÔ0Jñ	
ô 	
ð 	
ð  ×+Ò+Ñ-Ô-ˆØ×Ò˜MÑ*Ô*Ð*Ð*Ð*r   c                 óØ  — |                       d¬¦  «        \  }}|                     ¦   «         }|                      |¦  «         |                      |                     ¦   «         t
          ¦  «         |                     ¦   «          |j        d                              d¦  «         |  	                    |j
        d         |                      |                     ¦   «         ¦  «        ¦  «         dS )a  
        When L{ClientService} is stopped - that is,
        L{ClientService.stopService} has been called and the L{Deferred} it
        returns has fired - calling L{startService} will cause a new connection
        to be made, and new calls to L{whenConnected} to succeed.
        FrÒ   éÿÿÿÿN)rè   rk   r“   ÚfailureResultOfrù   r
   rU   r­   r6   rO   rÙ   )r&   ræ   rà   rû   s       r   Útest_startServiceWhileStoppedz0ClientServiceTests.test_startServiceWhileStopped•  sÛ   € ð ×*Ò*¸5Ð*ÑAÔA‰ˆˆGØ×%Ò%Ñ'Ô'ˆØ×Ò˜WÑ%Ô%Ð%Ø×Ò˜W×2Ò2Ñ4Ô4µnÑEÔEÐEØ×ÒÑÔÐØ
Œ˜Ô×$Ò$ TÑ*Ô*Ð*Ø×ÒØÔ# BÔ'¨×)=Ò)=¸g×>SÒ>SÑ>UÔ>UÑ)VÔ)Vñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óT  — t          t          t          ¦  «         G d„ dt          ¦  «        ¦   «         }|                      |¬¦  «        \  }}|j        d         }|                      t          j        |¦  «        ¦  «         |                      t          j        |¦  «        ¦  «         dS )aC  
        If the protocol objects returned by the factory given to
        L{ClientService} provide special "marker" interfaces for their
        transport - L{IHalfCloseableProtocol} or L{IFileDescriptorReceiver} -
        those interfaces will be provided by the protocol objects passed on to
        the reactor.
        c                   ó   — e Zd ZdZdS )úEClientServiceTests.test_interfacesForTransport.<locals>.FancyProtocolz9
            Provider of various interfaces.
            N)r;   r<   r=   r>   r   r   r   ÚFancyProtocolr  ¯  s   € € € € € ðð ð ð r   r  )rÛ   r   N)r   r   r   r   rè   r®   r�   Ú
providedBy)r&   r  ræ   rà   ÚreactorFacings        r   Útest_interfacesForTransportz.ClientServiceTests.test_interfacesForTransport¦  s±   € õ 
Õ+Õ-DÑ	EÔ	Eð	ð 	ð 	ð 	ð 	�Hñ 	ô 	ñ 
FÔ	Eð	ð
 ×*Ò*¸Ð*ÑFÔF‰ˆˆGØÔ/°Ô2ˆØ�ŠÕ/Ô:¸=ÑIÔIÑJÔJÐJØ�ŠÕ.Ô9¸-ÑHÔHÑIÔIÐIÐIÐIr   c                 óÜ  — t          ¦   «         }|                      d|¬¦  «        \  }}|j        d                              t	          ¦   «         ¦  «         |                     t          ¦  «         |                      t          |j        ¦  «        d¦  «         | 	                    ¦   «         }|j        d                              t	          ¦   «         ¦  «         |  
                    |¦  «         dS )zU
        When the service is stopped while retrying, the retry is cancelled.
        F©r¼   r~   r   r{   r)   N)r   rè   r­   r+   ró   ÚadvanceÚAT_LEAST_ONE_ATTEMPTr\   r]   rk   r“   ©r&   r~   ræ   rà   r-   s        r   Útest_stopServiceWhileRetryingz0ClientServiceTests.test_stopServiceWhileRetryingº  sÅ   € õ ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ
Œ˜Ô×"Ò"¥9¡;¤;Ñ/Ô/Ð/Ø�ŠÕ*Ñ+Ô+Ð+Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×ÒÑ!Ô!ˆØ
Œ˜Ô×"Ò"¥9¡;¤;Ñ/Ô/Ð/Ø×Ò˜QÑÔÐÐÐr   c                 ó8  — t          ¦   «         }|                      d|¬¦  «        \  }}|                      t          |j        ¦  «        d¦  «         |                      |j        d         ¦  «         |                     ¦   «         }|                      |¦  «         dS )zv
        When the service is stopped while initially connecting, the connection
        attempt is cancelled.
        Fr  r)   r   N)r   rè   r\   r]   r­   r‘   rk   r“   r  s        r   Útest_stopServiceWhileConnectingz2ClientServiceTests.test_stopServiceWhileConnectingÇ  s�   € õ
 ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×Ò˜BœO¨AÔ.Ñ/Ô/Ð/Ø×ÒÑ!Ô!ˆØ×Ò˜QÑÔÐÐÐr   c                 ó4  — t          ¦   «         }|                      |¬¦  «        \  }}|                     ¦   «         }|                      |                     ¦   «         g ¦  «         |                      |                      |¦  «        |j        d         ¦  «         dS )zy
        When a client connects, the service keeps a reference to the new
        protocol and resets the delay.
        rÑ   r   N)r   rè   rù   r\   rß   rO   r“   rÙ   )r&   r~   ræ   rà   ÚawaitingProtocols        r   Útest_clientConnectedz'ClientServiceTests.test_clientConnectedÓ  s™   € õ
 ‘”ˆØ×*Ò*°Ð*Ñ7Ô7‰ˆˆGØ"×0Ò0Ñ2Ô2ÐØ×Ò˜×.Ò.Ñ0Ô0°"Ñ5Ô5Ð5Ø×ÒØ× Ò Ð!1Ñ2Ô2°BÔ4KÈAÔ4Nñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó  — t          ¦   «         }|                      d|¬¦  «        \  }}|                      t          |j        ¦  «        d¦  «         |j        d                              t          t          ¦   «         ¦  «        ¦  «         |                     ¦   «         }|  	                    |¦  «         | 
                    d„ ¦  «         |                     t          ¦  «         |                      t          |j        ¦  «        d¦  «         dS )zŒ
        When a client connection fails, the service removes its reference
        to the protocol and tries again after a timeout.
        Fr  r)   r   c                 ó6   — |                       t          ¦  «        S r"   )Útrapr
   )r·   s    r   r.   z@ClientServiceTests.test_clientConnectionFailed.<locals>.<lambda>í  s   € °·²½nÑ1MÔ1M€ r   r{   N)r   rè   r\   r]   r­   r+   r   ró   rù   r‘   Ú
addErrbackr  r  )r&   r~   ræ   rà   rù   s        r   Útest_clientConnectionFailedz.ClientServiceTests.test_clientConnectionFailedà  sè   € õ
 ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø
Œ˜Ô×"Ò"¥7­9©;¬;Ñ#7Ô#7Ñ8Ô8Ð8Ø×-Ò-Ñ/Ô/ˆØ×Ò˜MÑ*Ô*Ð*ð 	× Ò Ð!MÐ!MÑNÔNÐNØ�ŠÕ*Ñ+Ô+Ð+Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ð1Ð1r   c                 ó„  — t          ¦   «         }|                      |d¬¦  «        \  }}|                      t          |j        ¦  «        d¦  «         |j        d                              d¦  «         |                      t          |j        ¦  «        d¦  «         |                      |                      |                     ¦   «         ¦  «        |j	        d         ¦  «         |j
        d                              t          t          ¦   «         ¦  «        ¦  «         |                     t          ¦  «         |                      t          |j        ¦  «        d¦  «         |j        d                              d¦  «         |                      |                      |                     ¦   «         ¦  «        |j	        d         ¦  «         dS )z~
        When a client connection is lost, the service removes its reference
        to the protocol and calls retry.
        F)r~   r¼   r)   r   Nr{   )r   rè   r\   r]   r­   r6   rO   r“   rù   rÙ   r®   rò   r   ró   r  r  )r&   r~   ræ   rà   s       r   Útest_clientConnectionLostz,ClientServiceTests.test_clientConnectionLostñ  s†  € õ
 ‘”ˆØ×*Ò*°ÈÐ*ÑNÔN‰ˆˆGØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø
Œ˜Ô×#Ò# DÑ)Ô)Ð)Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×ÒØ× Ò  ×!6Ò!6Ñ!8Ô!8Ñ9Ô9¸2Ô;RÐSTÔ;Uñ	
ô 	
ð 	
ð 	Ô Ô"×1Ò1µ'½)¹+¼+Ñ2FÔ2FÑGÔGÐGØ�ŠÕ*Ñ+Ô+Ð+Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø
Œ˜Ô×#Ò# DÑ)Ô)Ð)Ø×ÒØ× Ò  ×!6Ò!6Ñ!8Ô!8Ñ9Ô9¸2Ô;RÐSTÔ;Uñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó|  — t          ¦   «         }|                      |¬¦  «        \  }}|                     ¦   «         }|j        d                              t          t          ¦   «         ¦  «        ¦  «         |                      |                     ¦   «         t          ¦  «         |  
                    |j        ¦  «         dS )z¸
        When a client connection is lost while the service is stopping, the
        protocol stopping deferred is called and the reference to the protocol
        is removed.
        rÑ   r   N)r   rè   rk   r®   rò   r   ÚIndentationErrorr  rù   r
   r�   Úcalledr  s        r   Ú&test_clientConnectionLostWhileStoppingz9ClientServiceTests.test_clientConnectionLostWhileStopping  sŸ   € õ ‘”ˆØ×*Ò*°Ð*Ñ7Ô7‰ˆˆGØ×ÒÑ!Ô!ˆØ
Ô Ô"×1Ò1µ'Õ:JÑ:LÔ:LÑ2MÔ2MÑNÔNÐNØ×Ò˜W×2Ò2Ñ4Ô4µnÑEÔEÐEØ�Š˜œÑ!Ô!Ð!Ð!Ð!r   c                 óà  — |                       dd¬¦  «        \  }}|                      t          |j        ¦  «        d¦  «         |                     ¦   «          |                      t          |j        ¦  «        d¦  «         t          | ¦  «        }|                     ¦   «          |                      t          |j        ¦  «        d¦  «         |                      d |¦   «         d         ¦  «         dS )zÀ
        If L{ClientService} is started when it's already started, it will log a
        complaint and do nothing else (in particular it will not make
        additional connections).
        F)r¼   rU   r   r)   z$Duplicate ClientService.startServiceN)rè   r\   r]   r­   rU   rÍ   ÚassertIn)r&   ræ   rà   Úmessagess       r   Útest_startTwicez"ClientServiceTests.test_startTwice  sÔ   € ð ×*Ò*¸5ÈuÐ*ÑUÔU‰ˆˆGØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø×ÒÑÔÐØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ý˜T‘?”?ˆØ×ÒÑÔÐØ×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1Ø�ŠÐ<¸h¸h¹j¼jÈ¼mÑLÔLÐLÐLÐLr   c                 ó¨  — t          ¦   «         }|                      d|¬¦  «        \  }}|                     ¦   «         }|                     ¦   «         }|                     d¬¦  «        }|                      |¦  «         |                      |¦  «         |                      |¦  «         |j        d                              d¦  «         |                      |¦  «        }|                      |¦  «        }|                      |¦  «        }	|                      ||¦  «         |                      ||	¦  «         |                      ||j        d         ¦  «         dS )z{
        L{ClientService.whenConnected} returns a L{Deferred} that fires when a
        connection is established.
        Fr  r)   ©ÚfailAfterFailuresr   N)	r   rè   rù   r‘   r­   r6   r“   rO   rÙ   )
r&   r~   ræ   rà   ÚaÚbÚcÚresultAÚresultBÚresultCs
             r   Útest_whenConnectedLaterz*ClientServiceTests.test_whenConnectedLater"  sA  € õ
 ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ×!Ò!Ñ#Ô#ˆØ×!Ò!Ñ#Ô#ˆØ×!Ò!°AÐ!Ñ6Ô6ˆØ×Ò˜AÑÔÐØ×Ò˜AÑÔÐØ×Ò˜AÑÔÐØ
Œ˜Ô×#Ò# DÑ)Ô)Ð)Ø×&Ò& qÑ)Ô)ˆØ×&Ò& qÑ)Ô)ˆØ×&Ò& qÑ)Ô)ˆØ×Ò˜W gÑ.Ô.Ð.Ø×Ò˜W gÑ.Ô.Ð.Ø×Ò˜W bÔ&=¸aÔ&@ÑAÔAÐAÐAÐAr   c                 ó†  — t          ¦   «         }|                      d|¬¦  «        \  }}|                     ¦   «         }|                     d¬¦  «        }|                     d¬¦  «        }|                     d¬¦  «        }|                      |¦  «         |                      |¦  «         |                      |¦  «         |                      |¦  «         t	          t          ¦   «         ¦  «        }|j        d                              |¦  «         |                      |¦  «         |                      |  	                    |t
          ¦  «        |¦  «         |                      |¦  «         |                      |¦  «         | 
                    t          ¦  «         |                      t          |j        ¦  «        d¦  «         |                      |¦  «         |                      |¦  «         |                      |¦  «         t	          t          ¦   «         ¦  «        }	|j        d                              |	¦  «         |                      |¦  «         |                      |  	                    |t
          ¦  «        |	¦  «         |                      |¦  «         t          }
| 
                    |
¦  «         |                      t          |j        ¦  «        d¦  «         |                      |¦  «         |                      |¦  «         |j        d                              d¦  «         |                      |¦  «        }|                      |¦  «        }|                      ||¦  «         |                      ||j        d         ¦  «         |                     d¬¦  «        }|                      |¦  «        }|                      ||¦  «         dS )	z‘
        L{ClientService.whenConnected} returns a L{Deferred} that fails, if
        asked, when some number of connections have failed.
        Fr  r)   r%  r{   é   r   N)r   rè   rù   r‘   r   ró   r­   r+   rO   r  r  r  r\   r]   r6   r“   rÙ   )r&   r~   ræ   rà   Úa0Úa1Úa2Úa3Úf1Úf2ÚAT_LEAST_TWO_ATTEMPTSÚresultA0ÚresultA3Úa4ÚresultA4s                  r   Útest_whenConnectedFailsz*ClientServiceTests.test_whenConnectedFails7  s`  € õ
 ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ×"Ò"Ñ$Ô$ˆØ×"Ò"°QÐ"Ñ7Ô7ˆØ×"Ò"°QÐ"Ñ7Ô7ˆØ×"Ò"°QÐ"Ñ7Ô7ˆØ×Ò˜BÑÔÐØ×Ò˜BÑÔÐØ×Ò˜BÑÔÐØ×Ò˜BÑÔÐå•Y‘[”[Ñ!Ô!ˆØ
Œ˜Ô×"Ò" 2Ñ&Ô&Ð&à×Ò˜BÑÔÐØ×Ò˜T×1Ò1°"µiÑ@Ô@À"ÑEÔEÐEØ×Ò˜BÑÔÐØ×Ò˜BÑÔÐà�ŠÕ*Ñ+Ô+Ð+Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1à×Ò˜BÑÔÐØ×Ò˜BÑÔÐØ×Ò˜BÑÔÐå•Y‘[”[Ñ!Ô!ˆØ
Œ˜Ô×"Ò" 2Ñ&Ô&Ð&à×Ò˜BÑÔÐØ×Ò˜T×1Ò1°"µiÑ@Ô@À"ÑEÔEÐEØ×Ò˜BÑÔÐå 4ÐØ�ŠÐ+Ñ,Ô,Ð,Ø×Ò�˜Rœ_Ñ-Ô-¨qÑ1Ô1Ð1à×Ò˜BÑÔÐØ×Ò˜BÑÔÐà
Œ˜Ô×#Ò# DÑ)Ô)Ð)à×'Ò'¨Ñ+Ô+ˆØ×'Ò'¨Ñ+Ô+ˆØ×Ò˜X xÑ0Ô0Ð0Ø×Ò˜X rÔ'>¸qÔ'AÑBÔBÐBð ×"Ò"°QÐ"Ñ7Ô7ˆØ×'Ò'¨Ñ+Ô+ˆØ×Ò˜X xÑ0Ô0Ð0Ð0Ð0r   c                 óN  — t          ¦   «         }|                      d|¬¦  «        \  }}|                     ¦   «         }|                     ¦   «         }|                     d¬¦  «        }|                      |¦  «         |                      |¦  «         |                      |¦  «         |                     ¦   «          |                     t          ¦  «         |                      |t          ¦  «         |                      |t          ¦  «         |                      |t          ¦  «         dS )z†
        L{ClientService.whenConnected} returns a L{Deferred} that fails when
        L{ClientService.stopService} is called.
        Fr  r)   r%  N)	r   rè   rù   r‘   rk   r  r  r  r
   )r&   r~   ræ   rà   r'  r(  r)  s          r   Útest_whenConnectedStopServicez0ClientServiceTests.test_whenConnectedStopServiceq  s
  € õ
 ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ×!Ò!Ñ#Ô#ˆØ×!Ò!Ñ#Ô#ˆØ×!Ò!°AÐ!Ñ6Ô6ˆØ×Ò˜AÑÔÐØ×Ò˜AÑÔÐØ×Ò˜AÑÔÐØ×ÒÑÔÐØ�ŠÕ*Ñ+Ô+Ð+Ø×Ò˜Q¥Ñ/Ô/Ð/Ø×Ò˜Q¥Ñ/Ô/Ð/Ø×Ò˜Q¥Ñ/Ô/Ð/Ð/Ð/r   c                 óR  — t          ¦   «         }|                      d|¬¦  «        \  }}|j        d                              t	          d¦  «        ¦  «         |                     ¦   «         }|                      |                     ¦   «         g ¦  «         |                      |¦  «         dS )zÎ
        When L{ClientService.stopService} is called while waiting between
        connection attempts, the pending reconnection attempt is cancelled and
        the service is stopped immediately.
        Fr  r   úno connectionN)	r   rè   r­   r+   ró   rk   r\   rß   r“   r  s        r   Útest_retryCancelledz&ClientServiceTests.test_retryCancelled„  s™   € õ ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ
Œ˜Ô×"Ò"¥9¨_Ñ#=Ô#=Ñ>Ô>Ð>Ø×ÒÑ!Ô!ˆØ×Ò˜×.Ò.Ñ0Ô0°"Ñ5Ô5Ð5Ø×Ò˜QÑÔÐÐÐr   c                 óÐ   — t          ¦   «         }|                      dd|¬¦  «        \  }}|                     ¦   «         }|                      |                      |¦  «        ¦  «         dS )z¦
        Calling L{ClientService.stopService} before
        L{ClientService.startService} returns a L{Deferred} that has
        already fired with L{None}.
        F)r¼   rU   r~   N©r   rè   rk   ÚassertIsNoner“   )r&   r~   Ú_rà   r-   s        r   Ú"test_stopServiceBeforeStartServicez5ClientServiceTests.test_stopServiceBeforeStartService‘  sm   € õ ‘”ˆØ×)Ò)Ø!°¸Uð *ñ 
ô 
‰
ˆˆ7ð ×ÒÑ!Ô!ˆØ×Ò˜$×.Ò.¨qÑ1Ô1Ñ2Ô2Ð2Ð2Ð2r   c                 óô  — t          ¦   «         }|                      d|¬¦  «        \  }}|                     ¦   «         }|j        d                              t          d¦  «        ¦  «         |                     ¦   «          |                     ¦   «         }|                      |                      |¦  «        j	        t          ¦  «         |                      |                      |¦  «        j	        t          ¦  «         dS )zÊ
        L{ClientService.whenConnected} returns a L{Deferred} that
        errbacks with L{CancelledError} if
        L{ClientService.stopService} is called between connection
        attempts.
        Fr  r   r?  N)r   rè   rù   r­   r+   ró   rk   r‚   r  r¥   r
   )r&   r~   ræ   rà   ÚbeforeErrbackAndStopÚafterErrbackAndStops         r   Ú'test_whenConnectedErrbacksOnStopServicez:ClientServiceTests.test_whenConnectedErrbacksOnStopServicež  sî   € õ ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGØ&×4Ò4Ñ6Ô6Ðð 	Œ˜Ô×"Ò"¥9¨_Ñ#=Ô#=Ñ>Ô>Ð>à×ÒÑÔÐØ%×3Ò3Ñ5Ô5Ðà×ÒØ× Ò Ð!5Ñ6Ô6Ô<½nñ	
ô 	
ð 	
ð 	×ÒØ× Ò Ð!4Ñ5Ô5Ô;½^ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 ó¬  — t          ¦   «         }|                      d|¬¦  «        \  }}|j        d                              d¦  «         |                     ¦   «         }|                     ¦   «         }|j        d                              t          t          ¦   «         ¦  «        ¦  «         |  	                    |¦  «         |  	                    |¦  «         dS )zí
        Calling L{ClientService.stopService} twice after it has
        connected (that is, stopping it while it is disconnecting)
        returns a L{Deferred} each time that fires when the
        disconnection has completed.
        Fr  r   N)
r   rè   r­   r6   rk   r®   rò   r   r  r“   ©r&   r~   ræ   rà   ÚfirstStopDeferredÚsecondStopDeferreds         r   Ú"test_stopServiceWhileDisconnectingz5ClientServiceTests.test_stopServiceWhileDisconnecting·  sÇ   € õ ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGà
Œ˜Ô×#Ò# DÑ)Ô)Ð)ð $×/Ò/Ñ1Ô1Ðà$×0Ò0Ñ2Ô2Ðð 	Ô Ô"×1Ò1µ'Õ:JÑ:LÔ:LÑ2MÔ2MÑNÔNÐNà×ÒÐ.Ñ/Ô/Ð/Ø×ÒÐ/Ñ0Ô0Ð0Ð0Ð0r   c                 óÔ  — t          ¦   «         }|                      d|¬¦  «        \  }}|j        d                              d¦  «         |                     ¦   «         }|                     ¦   «          |                     ¦   «         }|j        d                              t          t          ¦   «         ¦  «        ¦  «         |  
                    |¦  «         |  
                    |¦  «         dS )z²
        Calling L{ClientService.stopService} after calling a
        reconnection attempt returns a L{Deferred} that fires when the
        disconnection has completed.
        Fr  r   N)r   rè   r­   r6   rk   rU   r®   rò   r   r  r“   rK  s         r   Útest_stopServiceWhileRestartingz2ClientServiceTests.test_stopServiceWhileRestartingÎ  sÙ   € õ ‘”ˆØ×*Ò*¸5ÈÐ*ÑNÔN‰ˆˆGà
Œ˜Ô×#Ò# DÑ)Ô)Ð)ð $×/Ò/Ñ1Ô1Ðà×ÒÑÔÐà$×0Ò0Ñ2Ô2Ðð 	Ô Ô"×1Ò1µ'Õ:JÑ:LÔ:LÑ2MÔ2MÑNÔNÐNà×ÒÐ.Ñ/Ô/Ð/Ø×ÒÐ/Ñ0Ô0Ð0Ð0Ð0r   c                 óF  — t          ¦   «         }|                      d|¬¦  «        \  }}|                     ¦   «         }|                     ¦   «         }|                      |                      |¦  «        ¦  «         |                      |                      |¦  «        ¦  «         dS )zŽ
        Calling L{ClientService.stopService} on a stopped service
        returns a L{Deferred} that has already fired with L{None}.
        Fr  NrB  )r&   r~   rD  rà   rL  rM  s         r   Ú test_stopServiceOnStoppedServicez3ClientServiceTests.test_stopServiceOnStoppedServiceæ  s™   € õ
 ‘”ˆØ×)Ò)¸%ÀuÐ)ÑMÔM‰
ˆˆ7Ø#×/Ò/Ñ1Ô1ÐØ$×0Ò0Ñ2Ô2Ðà×Ò˜$×.Ò.Ð/@ÑAÔAÑBÔBÐBØ×Ò˜$×.Ò.Ð/AÑBÔBÑCÔCÐCÐCÐCr   c                 ó„   ‡— dgŠˆfd„}|                       |d¬¦  «        \  }}|                      d‰d         ¦  «         dS )z†
        The C{prepareConnection} callable is called after
        L{ClientService.startService} once the connection is made.
        r   c                 ó(   •— ‰dxx         dz  cc<   d S ©Nr   r)   r   ©Ú_protoÚpreparess    €r   ÚprepareConnectionz[ClientServiceTests.test_prepareConnectionCalledWhenServiceStarts.<locals>.prepareConnectionú  ó   ø€ Ø�QˆKˆKŒK˜1ÑˆKˆK‰KˆKˆKr   T)rY  rU   r)   N)rè   r\   )r&   rY  ræ   rà   rX  s       @r   Ú-test_prepareConnectionCalledWhenServiceStartsz@ClientServiceTests.test_prepareConnectionCalledWhenServiceStartsó  sl   ø€ ð
 �3ˆð	ð 	ð 	ð 	ð 	ð ×*Ò*Ø/¸dð +ñ 
ô 
‰ˆˆGð 	×Ò˜˜H QœKÑ(Ô(Ð(Ð(Ð(r   c                 ó–   ‡— g Šˆfd„}|                       |¬¦  «        \  }}|                      |j        d         ‰d         ¦  «         dS )zf
        The C{prepareConnection} callable is passed the connected protocol
        instance.
        c                 ó2   •— ‰                      | ¦  «         d S r"   ©rm   )ÚprotoÚnewProtocolss    €r   rY  zVClientServiceTests.test_prepareConnectionCalledWithProtocol.<locals>.prepareConnection	  s   ø€ Ø×Ò Ñ&Ô&Ð&Ð&Ð&r   ©rY  r   N)rè   rO   r®   )r&   rY  ræ   rà   r`  s       @r   Ú(test_prepareConnectionCalledWithProtocolz;ClientServiceTests.test_prepareConnectionCalledWithProtocol  sp   ø€ ð
 ˆð	'ð 	'ð 	'ð 	'ð 	'ð ×*Ò*Ø/ð +ñ 
ô 
‰ˆˆGð 	×Ò˜RÔ4°QÔ7¸Àa¼ÑIÔIÐIÐIÐIr   c                 ó¨  ‡— dgŠˆfd„}t          ¦   «         }|                      |d|¬¦  «        \  }}|j        d                              t	          d¦  «        ¦  «         |                      d‰d         ¦  «         |                     t          ¦  «         |j        d                              d¦  «         |                      d‰d         ¦  «         dS )zf
        The C{prepareConnection} callback is invoked only once a connection is
        made.
        r   c                 ó(   •— ‰dxx         dz  cc<   d S rU  r   rV  s    €r   rY  z]ClientServiceTests.test_prepareConnectionCalledAfterConnectionMade.<locals>.prepareConnection  rZ  r   F)rY  r¼   r~   zconnection attempt failedr)   N)	r   rè   r­   r+   ró   r\   r  r  r6   ©r&   rY  r~   ræ   rà   rX  s        @r   Ú/test_prepareConnectionCalledAfterConnectionMadezBClientServiceTests.test_prepareConnectionCalledAfterConnectionMade  sã   ø€ ð
 �3ˆð	ð 	ð 	ð 	ð 	õ ‘”ˆØ×*Ò*Ø/ÀÈeð +ñ 
ô 
‰ˆˆGð 	Œ˜Ô×"Ò"¥9Ð-HÑ#IÔ#IÑJÔJÐJØ×Ò˜˜H QœKÑ(Ô(Ð(à�ŠÕ*Ñ+Ô+Ð+Ø
Œ˜Ô×#Ò# DÑ)Ô)Ð)à×Ò˜˜H QœKÑ(Ô(Ð(Ð(Ð(r   c                 ó~  ‡— dgŠˆfd„}t          ¦   «         }|                      ||¬¦  «        \  }}|                      d‰d         ¦  «         |j        d                              t          t          ¦   «         ¦  «        ¦  «         |                     t          ¦  «         |                      d‰d         ¦  «         dS )z�
        The C{prepareConnection} callback is invoked each time a connection is
        made, including on reconnection.
        r   c                 ó(   •— ‰dxx         dz  cc<   d S rU  r   rV  s    €r   rY  zUClientServiceTests.test_prepareConnectionCalledOnReconnect.<locals>.prepareConnection/  rZ  r   ©rY  r~   r)   r{   N)	r   rè   r\   r®   rò   r   r  r  r  re  s        @r   Ú'test_prepareConnectionCalledOnReconnectz:ClientServiceTests.test_prepareConnectionCalledOnReconnect(  sÏ   ø€ ð
 �3ˆð	ð 	ð 	ð 	ð 	õ ‘”ˆØ×*Ò*Ø/°uð +ñ 
ô 
‰ˆˆGð 	×Ò˜˜H QœKÑ(Ô(Ð(ð 	Ô Ô"×1Ò1µ'Õ:JÑ:LÔ:LÑ2MÔ2MÑNÔNÐNØ�ŠÕ*Ñ+Ô+Ð+à×Ò˜˜H QœKÑ(Ô(Ð(Ð(Ð(r   c                 óÚ   ‡— t          ¦   «         Šˆfd„}|                      |¬¦  «        \  }}|                      |                     ¦   «         ¦  «        }|                      ‰|¦  «         dS )a?  
        The C{prepareConnection} return value is ignored when it does not
        indicate a failure. Even though the callback participates in the
        internal new-connection L{Deferred} chain for error propagation
        purposes, any successful result does not affect the ultimate return
        value.
        c                 ó   •— ‰S r"   r   )r_  Úsentinels    €r   rY  zVClientServiceTests.test_prepareConnectionReturnValueIgnored.<locals>.prepareConnectionJ  s   ø€ ØˆOr   ra  N)r’   rè   r“   rù   ÚassertNotIdentical)r&   rY  ræ   rà   r2   rm  s        @r   Ú(test_prepareConnectionReturnValueIgnoredz;ClientServiceTests.test_prepareConnectionReturnValueIgnored?  s   ø€ õ ‘8”8ˆð	ð 	ð 	ð 	ð 	ð ×*Ò*Ð=NÐ*ÑOÔO‰ˆˆGà×%Ò% g×&;Ò&;Ñ&=Ô&=Ñ>Ô>ˆØ×Ò ¨&Ñ1Ô1Ð1Ð1Ð1r   c                 óL  ‡‡— g Št          ¦   «         Šˆˆfd„}|                      |¬¦  «        \  }}|                     ¦   «         }|                      |¦  «         ‰                     d¦  «         |                      |j        d         |                      |¦  «        ¦  «         dS )z�
        The C{prepareConnection} callable returns a deferred and calls to
        L{ClientService.whenConnected} wait until it fires.
        c                 ó2   •— ‰                      | ¦  «         ‰S r"   r^  )r_  ÚnewProtocolDeferredr`  s    €€r   rY  zVClientServiceTests.test_prepareConnectionReturningADeferred.<locals>.prepareConnectionZ  s   ø€ Ø×Ò Ñ&Ô&Ð&Ø&Ð&r   ra  Nr   )r   rè   rù   r‘   r6   rO   rÙ   r“   )r&   rY  ræ   rà   ÚwhenConnectedDeferredrr  r`  s        @@r   Ú(test_prepareConnectionReturningADeferredz;ClientServiceTests.test_prepareConnectionReturningADeferredR  sÉ   øø€ ð
 ˆÝ&™jœjÐð	'ð 	'ð 	'ð 	'ð 	'ð 	'ð ×*Ò*Ð=NÐ*ÑOÔO‰ˆˆGà '× 5Ò 5Ñ 7Ô 7ÐØ×ÒÐ1Ñ2Ô2Ð2à×$Ò$ TÑ*Ô*Ð*à×ÒØÔ# AÔ&¨×(<Ò(<Ð=RÑ(SÔ(Sñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óª  — t          ¦   «         }d„ }|                      ||¬¦  «        \  }}|                     d¬¦  «        }|                      |¦  «         |                     t
          ¦  «         |                      |¦  «         |                     t
          ¦  «         |                      t          |                      |¦  «        j	        ¦  «         dS )zs
        The connection attempt counts as a failure when the
        C{prepareConnection} callable throws.
        c                 ó   — t          ¦   «         ‚r"   )r  )rW  s    r   rY  zJClientServiceTests.test_prepareConnectionThrows.<locals>.prepareConnectionp  s   € Ý"Ñ$Ô$Ð$r   ri  r{   r%  N)
r   rè   rù   r‘   r  r  rO   r  r  Útype)r&   r~   rY  ræ   rà   rs  s         r   Útest_prepareConnectionThrowsz/ClientServiceTests.test_prepareConnectionThrowsi  sã   € õ
 ‘”ˆð	%ð 	%ð 	%ð ×*Ò*Ø/°uð +ñ 
ô 
‰ˆˆGð !(× 5Ò 5ÈÐ 5Ñ JÔ JÐØ×ÒÐ1Ñ2Ô2Ð2à�ŠÕ*Ñ+Ô+Ð+Ø×ÒÐ1Ñ2Ô2Ð2à�ŠÕ*Ñ+Ô+Ð+Ø×ÒÝ˜d×2Ò2Ð3HÑIÔIÔNñ	
ô 	
ð 	
ð 	
ð 	
r   N)$r;   r<   r=   r>   r   rè   r…   rï   rõ   r÷   rþ   r  r	  r  r  r  r  r  r  r#  r-  r;  r=  r@  rE  rI  rN  rP  rR  r[  rb  rf  rj  ro  rt  rx  r   r   r   rÏ   rÏ   þ  s  € € € € € ðð ð
 #°ÀHðAð Að Að AðF2ð 2ð 2ð6ð 6ð 6ð ð  ð  ð:ð :ð :ð +ð +ð +ð8
ð 
ð 
ð"Jð Jð Jð( ð  ð  ð
 ð 
 ð 
 ð
ð 
ð 
ð2ð 2ð 2ð"
ð 
ð 
ð*"ð "ð "ðMð Mð MðBð Bð Bð*81ð 81ð 81ðt0ð 0ð 0ð& ð  ð  ð3ð 3ð 3ð
ð 
ð 
ð21ð 1ð 1ð.1ð 1ð 1ð0Dð Dð Dð)ð )ð )ðJð Jð Jð)ð )ð )ð.)ð )ð )ð.2ð 2ð 2ð&
ð 
ð 
ð.
ð 
ð 
ð 
ð 
r   rÏ   )F)0r>   r�   Úzope.interfacer   Úzope.interface.verifyr   Útwisted.applicationr   Útwisted.application.internetr   r   r   Útwisted.internetr	   Útwisted.internet.deferr
   r   Útwisted.internet.interfacesr   r   r   r   r   Útwisted.internet.protocolr   r   Útwisted.internet.taskr   Útwisted.internet.testingr   Útwisted.loggerr   r   Útwisted.python.failurer   Útwisted.trial.unittestr   r   r   r    r#   rH   ry   r«   r¿   rÍ   r  rÏ   r   r   r   ú<module>r†     s0  ðð
ð ð €€€à &Ð &Ð &Ð &Ð &Ð &Ø -Ð -Ð -Ð -Ð -Ð -à (Ð (Ð (Ð (Ð (Ð (ðð ð ð ð ð ð ð ð ð ð
 "Ð !Ð !Ð !Ð !Ð !Ø ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ðð ð ð ð ð ð ð ð ð ð ð ð ð ð 8Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ð 7Ø 'Ð 'Ð 'Ð 'Ð 'Ð 'Ø 4Ð 4Ð 4Ð 4Ð 4Ð 4Ø :Ð :Ð :Ð :Ð :Ð :Ð :Ð :Ø *Ð *Ð *Ð *Ð *Ð *Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @ð	ð 	ð 	ð €Ð"Ñ#Ô#ð=*ð =*ð =*ð =*ð =*ñ =*ô =*ñ $Ô#ð=*ð@ €Ð! :Ñ .Ô .Ð .ð €ˆ^ÑÔðð ð ð ð ñ ô ñ Ôðð6 €Ð! :Ñ .Ô .Ð .ðV1ð V1ð V1ð V1ð V1˜8ñ V1ô V1ð V1ðrC-ð C-ð C-ð C-ð C-˜ñ C-ô C-ð C-ðL"ð "ð "ð "ð "ñ "ô "ð "ð( &ð  &ð  &ð  &ðF &8ð :ð :ð :ð :ð$ Ð ðB

ð B

ð B

ð B

ð B

Ð,ñ B

ô B

ð B

ð B

ð B

r   