+
    üÐj=.  ã                   ób  € R t ^ RIt^ RIHt ^ RIHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHt Rt ^ RIHt ^ R	IHt ^ RIHt ^ RIHt  ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR#   ] d    R
t Lqi ; i)z>
Tests for L{twisted.internet.posixbase} and supporting code.
N)ÚDeferred©ÚIReadDescriptor)ÚPosixReactorBaseÚ_Waker)ÚServerFactory)Úplatform)ÚTestCase)Úunix)ÚClientProtoz)Platform does not support AF_UNIX sockets)Úreactor)ÚPortc                   óB   a a€ ] tR t^t oRtV 3R ltV 3R ltRtVtV ;t	# )ÚWarningCheckerTestCasez_
A test case that will make sure that no warnings are left unchecked at the end of a test run.
c                óè   <€ \         SV `  4        \        P                  P	                  R R4      P                  4       R8X  d0   \        P                  ! 4       '       d   V P                  4        R# R# R# )ÚCIÚ ÚtrueN)	ÚsuperÚsetUpÚosÚenvironÚgetÚlowerr   Ú	isWindowsÚflushWarnings)ÚselfÚ	__class__s   &€ÚF/usr/lib/python3/dist-packages/twisted/internet/test/test_posixbase.pyr   ÚWarningCheckerTestCase.setUp    sQ   ø€ Ü‰‰Œô �:‰:�>‰>˜$ Ó#×)Ñ)Ó+¨vÔ5¼(×:LÒ:L×:NÒ:NØ×ÑÖ ñ ;OÑ5ó    c                ó0  <€  \         SV `  4        V P                  4       p\        P                  P                  R R4      P                  4       R8X  d   \        P                  ! 4       '       d   R# V P                  \        V4      ^ RV 24       R#   T P                  4       p\        P                  P                  R R4      P                  4       R8X  d    \        P                  ! 4       '       d     R# T P                  \        T4      ^ RT 24       i ; i)r   r   r   Nz'Warnings found at the end of the test:
)r   ÚtearDownr   r   r   r   r   r   r   ÚassertEqualÚlen)r   Úwarningsr   s   & €r   r"   ÚWarningCheckerTestCase.tearDown+   sÛ   ø€ ð	Ü‰GÑÔà×)Ñ)Ó+ˆHÜ�z‰z�~‰~˜d BÓ'×-Ñ-Ó/°6Ô9¼h×>PÒ>P×>RÒ>Rñ Ø×ÑÜ�H“˜qÐ$LÈXÈJÐ"Wöøð ×)Ñ)Ó+ˆHÜ�z‰z�~‰~˜d BÓ'×-Ñ-Ó/°6Ô9¼h×>PÒ>P×>RÒ>Ró Ø×ÑÜ�H“˜qÐ$LÈXÈJÐ"Wõús   ƒB ÂADÃ1DÃ5 D© )
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r"   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r   Ú__classdict__s   @@r   r   r      s   ù‡ € ñõ	!÷õ r    r   c                   ó>   a € ] tR t^=t o R tR tR tR tR tRt	V t
R# )ÚTrivialReactorc                óN   € / V n         / V n        \        P                  ! V 4       R # ©N)Ú_readersÚ_writersr   Ú__init__©r   s   &r   r7   ÚTrivialReactor.__init__>   s   € ØˆŒØˆŒÜ×!Ò! $Ö'r    c                ó$   € R V P                   V&   R# ©TN©r5   ©r   Úreaders   &&r   Ú	addReaderÚTrivialReactor.addReaderC   ó   € Ø $ˆ�‰�fÓr    c                ó    € V P                   V R # r4   r<   r=   s   &&r   ÚremoveReaderÚTrivialReactor.removeReaderF   ó   € Ø�M‰M˜&Ò!r    c                ó$   € R V P                   V&   R# r;   ©r6   ©r   Úwriters   &&r   Ú	addWriterÚTrivialReactor.addWriterI   rA   r    c                ó    € V P                   V R # r4   rG   rH   s   &&r   ÚremoveWriterÚTrivialReactor.removeWriterL   rE   r    )r5   r6   N)r(   r)   r*   r+   r7   r?   rC   rJ   rM   r-   r.   ©r0   s   @r   r2   r2   =   s#   ø‡ € ò(ò
%ò"ò%÷"ð "r    r2   c                   ó<   a € ] tR t^Pt o RtR tR tR tR tRt	V t
R# )ÚPosixReactorBaseTestsz 
Tests for L{PosixReactorBase}.
c                óÞ   € V P                  VP                  \        4       V P                  VP                  VP                  4       V P                  VP                  VP
                  4       R # r4   )ÚassertIsInstanceÚwakerr   ÚassertInÚ_internalReadersr5   ©r   r   s   &&r   Ú_checkWakerÚ!PosixReactorBaseTests._checkWakerU   sF   € Ø×Ñ˜gŸm™m¬VÔ4Ø�‰�g—m‘m W×%=Ñ%=Ô>Ø�‰�g—m‘m W×%5Ñ%5Ö6r    c                ó<   € \        4       pV P                  V4       R# )zg
When L{PosixReactorBase} is instantiated, it creates a waker and adds
it to its internal readers set.
N)r2   rX   rW   s   & r   Útest_wakerIsInternalReaderÚ0PosixReactorBaseTests.test_wakerIsInternalReaderZ   s   € ô
 !Ó"ˆØ×Ñ˜Ö!r    c                ód  € \        4       p\        4       pVP                  P                  V4       VP                  ! V4       VP
                  ! VP                  VP                  4       V P                  V4       V P                  W!P                  4       V P                  W!P                  4       R# )zs
Any L{IReadDescriptor}s in L{PosixReactorBase._internalReaders} are
left alone by L{PosixReactorBase._removeAll}.
N)
r2   ÚobjectrV   Úaddr?   Ú
_removeAllr5   r6   rX   rU   )r   r   Úextras   &  r   Ú"test_removeAllSkipsInternalReadersÚ8PosixReactorBaseTests.test_removeAllSkipsInternalReadersb   sƒ   € ô
 !Ó"ˆÜ“ˆØ× Ñ ×$Ñ$ UÔ+Ø×Ò˜%Ô Ø×Ò˜7×+Ñ+¨W×-=Ñ-=Ô>Ø×Ñ˜Ô!Ø�‰�e×5Ñ5Ô6Ø�‰�e×-Ñ-Ö.r    c                ó|  € \        4       p\        4       p\        4       pVP                  ! V4       VP                  ! V4       VP                  ! VP
                  VP                  4      pV P                  \        V4      W#04       V P                  W!P
                  4       V P                  W1P                  4       R# )zn
L{PosixReactorBase._removeAll} returns a list of removed
L{IReadDescriptor} and L{IWriteDescriptor} objects.
N)
r2   r^   r?   rJ   r`   r5   r6   r#   ÚsetÚassertNotIn)r   r   r>   rI   Úremoveds   &    r   Ú'test_removeAllReturnsRemovedDescriptorsÚ=PosixReactorBaseTests.test_removeAllReturnsRemovedDescriptorsp   s“   € ô
 !Ó"ˆÜ“ˆÜ“ˆØ×Ò˜&Ô!Ø×Ò˜&Ô!Ø×$Ò$ W×%5Ñ%5°w×7GÑ7GÓHˆØ×Ñœ˜W›¨Ð'7Ô8Ø×Ñ˜×!1Ñ!1Ô2Ø×Ñ˜×!1Ñ!1Ö2r    r'   N)r(   r)   r*   r+   r,   rX   r[   rb   rh   r-   r.   rO   s   @r   rQ   rQ   P   s#   ø‡ € ñò7ò
"ò/÷3ð 3r    rQ   c                   óL   a € ] tR t^€t o Rt]! ]]4      '       g   RtR t	Rt
V tR# )ÚTCPPortTestsz)
Tests for L{twisted.internet.tcp.Port}.
zNon-posixbase reactorc                ó�   € \        R\        4       4      pRVn        R Vn        V P	                  VP                  4       \        4      # )zk
L{Port.stopListening} returns a L{Deferred} which errbacks if
L{Port.connectionLost} raises an exception.
i90  Tc                 ó   € ^^ ,          # )é   r'   )Úreasons   &r   Ú<lambda>Ú8TCPPortTests.test_connectionLostFailed.<locals>.<lambda>�   s   € ¨Q°!®Vr    )r   r   Ú	connectedÚconnectionLostÚassertFailureÚstopListeningÚZeroDivisionError)r   Úports   & r   Útest_connectionLostFailedÚ&TCPPortTests.test_connectionLostFailedˆ   s>   € ô
 �Eœ=›?Ó+ˆØˆŒÙ3ˆÔØ×!Ñ! $×"4Ñ"4Ó"6Ô8IÓJÐJr    r'   N)r(   r)   r*   r+   r,   Ú
isinstancer   r   Úskiprx   r-   r.   rO   s   @r   rk   rk   €   s+   ø‡ € ññ �gÐ/×0Ò0Ø&ˆ÷Kð Kr    rk   c                   ó`   a € ] tR t^“t o RtR tV 3R lR ltV 3R lR ltR tR t	R	 t
R
tV tR# )ÚTimeoutReportReactorzÐ
A reactor which is just barely runnable and which cannot monitor any
readers or writers, and which fires a L{Deferred} with the timeout
passed to its C{doIteration} method as soon as that method is invoked.
c                ó^   € \         P                  ! V 4       \        4       V n        ^dV n        R# )éd   N)r   r7   r   ÚiterationTimeoutÚnowr8   s   &r   r7   ÚTimeoutReportReactor.__init__š   s!   € Ü×!Ò! $Ô'Ü (£
ˆÔØˆŽr    c                ó$   <€ V ^8„  d   QhRS[ RR/# ©é   r>   ÚreturnNr   )Úformatr0   s   "€r   Ú__annotate__Ú!TimeoutReportReactor.__annotate__Ÿ   s   ø€ ÷ ñ ¡ð °Dñ r    c                ó   € R# )z
Ignore the reader.  This is necessary because the waker will be
added.  However, we won't actually monitor it for any events.
Nr'   r=   s   &&r   r?   ÚTimeoutReportReactor.addReaderŸ   ó   ‚ r    c                ó$   <€ V ^8„  d   QhRS[ RR/# r„   r   )r‡   r0   s   "€r   rˆ   r‰   ¥   s   ø€ ÷ ñ ¡?ð °tñ r    c                ó   € R# )z
See L{addReader}.
Nr'   r=   s   &&r   rC   Ú!TimeoutReportReactor.removeReader¥   rŒ   r    c                ó   € . # )z�
There are no readers or writers, so there is nothing to remove.
This will be called when the reactor stops, though, so it must be
implemented.
r'   r8   s   &r   Ú	removeAllÚTimeoutReportReactor.removeAllª   s	   € ð ˆ	r    c                ó   € V P                   # )z`
Override the real clock with a deterministic one that can be easily
controlled in a unit test.
)r�   r8   s   &r   ÚsecondsÚTimeoutReportReactor.seconds²   s   € ð
 �x‰xˆr    c                óZ   € V P                   pVe   R V n         VP                  V4       R # R # r4   )r€   Úcallback)r   ÚtimeoutÚds   && r   ÚdoIterationÚ TimeoutReportReactor.doIteration¹   s+   € Ø×!Ñ!ˆØŠ=Ø$(ˆDÔ!Ø�J‰J�wÖñ r    )r€   r�   N)r(   r)   r*   r+   r,   r7   r?   rC   r‘   r”   rš   r-   r.   rO   s   @r   r}   r}   “   s7   ø‡ € ñò÷
ð ÷ð ò
ò÷ ð  r    r}   c                   óT   a € ] tR t^Àt o RtR tR tR tR tR t	R t
R tR	 tR
tV tR# )ÚIterationTimeoutTestsz�
Tests for the timeout argument L{PosixReactorBase.run} calls
L{PosixReactorBase.doIteration} with in the presence of various delayed
calls.
c                óÄ   a€ . pSP                   P                  VP                  4       SP                   P                  V3R  l4       SP                  ! 4        V^ ,          # )c                 ó&   <€ SP                   ! 4       # r4   )Ústop)Úignoredr   s   &€r   rp   Ú>IterationTimeoutTests._checkIterationTimeout.<locals>.<lambda>Ê   s   ø€ ¸W¿\º\¼^r    )r€   ÚaddCallbackÚappendÚrun©r   r   r˜   s   &f r   Ú_checkIterationTimeoutÚ,IterationTimeoutTests._checkIterationTimeoutÇ   sH   ø€ ØˆØ× Ñ ×,Ñ,¨W¯^©^Ô<Ø× Ñ ×,Ñ,Ô-KÔLØ�ŠŒØ�q�zÐr    c                ó^   € \        4       pV P                  V4      pV P                  V4       R# )zT
If there are no delayed calls, C{doIteration} is called with a
timeout of L{None}.
N)r}   r§   ÚassertIsNoner¦   s   &  r   Útest_noCallsÚ"IterationTimeoutTests.test_noCallsÎ   s*   € ô
 'Ó(ˆØ×-Ñ-¨gÓ6ˆØ×Ñ˜'Ö"r    c                óˆ   € \        4       pVP                  ! ^dR 4       V P                  V4      pV P                  V^d4       R# )z¡
If there is a delayed call, C{doIteration} is called with a timeout
which is the difference between the current time and the time at
which that call is to run.
c                  ó   € R # r4   r'   r'   r    r   rp   Ú8IterationTimeoutTests.test_delayedCall.<locals>.<lambda>Þ   ó   € ¡tr    N©r}   Ú	callLaterr§   r#   r¦   s   &  r   Útest_delayedCallÚ&IterationTimeoutTests.test_delayedCall×   s<   € ô 'Ó(ˆØ×Ò˜#™|Ô,Ø×-Ñ-¨gÓ6ˆØ×Ñ˜ #Ö&r    c                óº   € \        4       pVP                  ! ^dR 4       V;P                  ^,          un        V P                  V4      pV P	                  V^K4       R# )z�
If a delayed call is scheduled and then some time passes, the
timeout passed to C{doIteration} is reduced by the amount of time
which passed.
c                  ó   € R # r4   r'   r'   r    r   rp   Ú7IterationTimeoutTests.test_timePasses.<locals>.<lambda>é   r°   r    N)r}   r²   r�   r§   r#   r¦   s   &  r   Útest_timePassesÚ%IterationTimeoutTests.test_timePassesâ   sJ   € ô 'Ó(ˆØ×Ò˜#™|Ô,Ø�Š�rÕ�Ø×-Ñ-¨gÓ6ˆØ×Ñ˜ "Ö%r    c                óØ   € \        4       pVP                  ! ^2R 4       VP                  ! ^
R 4       VP                  ! ^dR 4       V P                  V4      pV P                  V^
4       R# )z¼
If there are several delayed calls, C{doIteration} is called with a
timeout which is the difference between the current time and the
time at which the earlier of the two calls is to run.
c                  ó   € R # r4   r'   r'   r    r   rp   ÚAIterationTimeoutTests.test_multipleDelayedCalls.<locals>.<lambda>õ   ó   € ¡dr    c                  ó   € R # r4   r'   r'   r    r   rp   r¼   ö   r½   r    c                  ó   € R # r4   r'   r'   r    r   rp   r¼   ÷   r°   r    Nr±   r¦   s   &  r   Útest_multipleDelayedCallsÚ/IterationTimeoutTests.test_multipleDelayedCallsî   s\   € ô 'Ó(ˆØ×Ò˜"™lÔ+Ø×Ò˜"™lÔ+Ø×Ò˜#™|Ô,Ø×-Ñ-¨gÓ6ˆØ×Ñ˜ "Ö%r    c                óÜ   € \        4       pVP                  ! ^2R 4      pV;P                  ^,          un        VP                  ^4       V P	                  V4      pV P                  V^4       R# )z 
If a delayed call is reset, the timeout passed to C{doIteration} is
based on the interval between the time when reset is called and the
new delay of the call.
c                  ó   € R # r4   r'   r'   r    r   rp   Ú=IterationTimeoutTests.test_resetDelayedCall.<locals>.<lambda>  ó   € ©Tr    N)r}   r²   r�   Úresetr§   r#   ©r   r   Úcallr˜   s   &   r   Útest_resetDelayedCallÚ+IterationTimeoutTests.test_resetDelayedCallû   sW   € ô 'Ó(ˆØ× Ò  ¡\Ó2ˆØ�Š�rÕ�Ø�
‰
�2ŒØ×-Ñ-¨gÓ6ˆØ×Ñ˜ "Ö%r    c                óÜ   € \        4       pVP                  ! ^2R 4      pV;P                  ^
,          un        VP                  ^4       V P	                  V4      pV P                  V^<4       R# )zÉ
If a delayed call is re-delayed, the timeout passed to
C{doIteration} is based on the remaining time before the call would
have been made and the additional amount of time passed to the delay
method.
c                  ó   € R # r4   r'   r'   r    r   rp   Ú=IterationTimeoutTests.test_delayDelayedCall.<locals>.<lambda>  rÅ   r    N)r}   r²   r�   Údelayr§   r#   rÇ   s   &   r   Útest_delayDelayedCallÚ+IterationTimeoutTests.test_delayDelayedCall  sW   € ô 'Ó(ˆØ× Ò  ¡\Ó2ˆØ�Š�rÕ�Ø�
‰
�2ŒØ×-Ñ-¨gÓ6ˆØ×Ñ˜ "Ö%r    c                ó¦   € \        4       pVP                  ! ^2R 4      pVP                  4        V P                  V4      pV P	                  V4       R# )zX
If the only delayed call is canceled, L{None} is the timeout passed
to C{doIteration}.
c                  ó   € R # r4   r'   r'   r    r   rp   Ú>IterationTimeoutTests.test_cancelDelayedCall.<locals>.<lambda>  rÅ   r    N)r}   r²   Úcancelr§   rª   rÇ   s   &   r   Útest_cancelDelayedCallÚ,IterationTimeoutTests.test_cancelDelayedCall  sE   € ô
 'Ó(ˆØ× Ò  ¡\Ó2ˆØ�‰ŒØ×-Ñ-¨gÓ6ˆØ×Ñ˜'Ö"r    r'   N)r(   r)   r*   r+   r,   r§   r«   r³   r¸   rÀ   rÉ   rÏ   rÕ   r-   r.   rO   s   @r   r�   r�   À   s7   ø‡ € ñòò#ò	'ò
&ò&ò&ò&÷	#ð 	#r    r�   c                   ó<   a € ] tR tRt o Rt]e   ]tR tR tRt	V t
R# )ÚConnectedDatagramPortTestsi"  z'
Test connected datagram UNIX sockets.
Nc                ó€   a € V 3R lp\         P                  ! R\        4       4      pWn        VP	                  R4       R# )zw
L{ConnectedDatagramPort} does not call the deprecated C{loseConnection}
in L{ConnectedDatagramPort.connectionFailed}.
c                 ó*   <€ S P                  R4       R# )z\
Dummy C{loseConnection} method. C{loseConnection} is deprecated and
should not get called.
z7loseConnection is deprecated and should not get called.N)Úfailr8   s   €r   ÚloseConnectionÚ`ConnectedDatagramPortTests.test_connectionFailedDoesntCallLoseConnection.<locals>.loseConnection0  s   ø€ ð
 �I‰IÐOÖPr    NÚgoodbye)r
   ÚConnectedDatagramPortr   rÜ   ÚconnectionFailed)r   rÜ   rw   s   f  r   Ú-test_connectionFailedDoesntCallLoseConnectionÚHConnectedDatagramPortTests.test_connectionFailedDoesntCallLoseConnection*  s3   ø€ õ	Qô ×)Ò)¨$´³Ó>ˆØ,ÔØ×Ñ˜iÖ(r    c                óÄ   a € RS n         V 3R lp\        P                  ! R\        4       4      pWn        VP                  R4       S P                  S P                   4       R# )z¡
L{ConnectedDatagramPort} calls L{ConnectedDatagramPort.stopListening}
instead of the deprecated C{loseConnection} in
L{ConnectedDatagramPort.connectionFailed}.
Fc                 ó   <€ RS n         R# )z 
Dummy C{stopListening} method.
TN©Úcalledr8   s   €r   ru   ÚYConnectedDatagramPortTests.test_connectionFailedCallsStopListening.<locals>.stopListeningC  s   ø€ ð ˆDŽKr    NrÞ   )ræ   r
   rß   r   ru   rà   Ú
assertTrue)r   ru   rw   s   f  r   Ú'test_connectionFailedCallsStopListeningÚBConnectedDatagramPortTests.test_connectionFailedCallsStopListening;  sK   ø€ ð ˆŒõ	ô ×)Ò)¨$´³Ó>ˆØ*ÔØ×Ñ˜iÔ(Ø�‰˜Ÿ™Ö$r    rå   )r(   r)   r*   r+   r,   ÚskipSocketsr{   rá   ré   r-   r.   rO   s   @r   rØ   rØ   "  s&   ø‡ € ñð ÒØˆò)÷"%ð %r    rØ   c                   ó&   a € ] tR tRt o R tRtV tR# )Ú
WakerTestsiO  c                óì   € \        4       pV P                  4       pV P                  \        V4      ^ V4       VP	                  R4       V P                  4       pV P                  \        V4      ^ V4       R# )z8
No warnings are generated when constructing the waker.
N)r   r   r#   r$   rs   )r   rT   r%   s   &  r   Ú test_noWakerConstructionWarningsÚ+WakerTests.test_noWakerConstructionWarningsP  sc   € ô “ˆà×%Ñ%Ó'ˆØ×Ñœ˜X›¨¨8Ô4ð 	×Ñ˜TÔ"Ø×%Ñ%Ó'ˆØ×Ñœ˜X›¨¨8Ö4r    r'   N)r(   r)   r*   r+   rï   r-   r.   rO   s   @r   rí   rí   O  s   ø‡ € ÷5ð 5r    rí   ) r,   r   Útwisted.internet.deferr   Útwisted.internet.interfacesr   Útwisted.internet.posixbaser   r   Útwisted.internet.protocolr   Útwisted.python.runtimer   Útwisted.trial.unittestr	   rë   Útwisted.internetr
   Útwisted.test.test_unixr   ÚImportErrorr   Útwisted.internet.tcpr   r   r2   rQ   rk   r}   r�   rØ   rí   r'   r    r   Ú<module>rû      sÀ   ðñó 
å +Ý 7ß ?Ý 3Ý +Ý +à€ð>Ý%Ý2õ %Ý %ô˜Xô ôD"Ð%ô "ô&-3Ð2ô -3ô`KÐ)ô Kô&* Ð+ô * ôZ_#Ð2ô _#ôD*%Ð!7ô *%ôZ5Ð'ö 5øðw	 ô >Ø=‚Kð>ús   °B" Â"	B.Â-B.