+
    üÐj1  ã                   óð   € R t  ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHtHt  ! R R	4      t ! R
 R]
4      t]! 4       P'                  ]P)                  4       4       R#   ] d    Rt Lli ; i)z6
Tests for implementations of L{IReactorWin32Events}.
N)ÚverifyObject)ÚDeferred)ÚIReactorWin32Events)ÚReactorBuilder)ÚFailure)ÚgetThreadIDÚisInIOThreadc                   óX   a € ] tR t^t o RtRtR;t;ttR t	R t
R tR tR tR	 tR
tV tR# )ÚListeneraœ  
L{Listener} is an object that can be added to a L{IReactorWin32Events}
reactor to receive callback notification when a Windows event is set.  It
records what thread its callback is invoked in and fires a Deferred.

@ivar success: A flag which is set to C{True} when the event callback is
    called.

@ivar logThreadID: The id of the thread in which the C{logPrefix} method is
    called.

@ivar eventThreadID: The id of the thread in which the event callback is
    called.

@ivar connLostThreadID: The id of the thread in which the C{connectionLost}
    method is called.

@ivar _finished: The L{Deferred} which will be fired when the event callback
    is called.
FNc                ó   € Wn         R # ©N)Ú	_finished)ÚselfÚfinisheds   &&ÚH/usr/lib/python3/dist-packages/twisted/internet/test/test_win32events.pyÚ__init__ÚListener.__init__/   s   € Ø!Žó    c                ó$   € \        4       V n        R # )r
   )r   ÚlogThreadID©r   s   &r   Ú	logPrefixÚListener.logPrefix2   s   € Ü&›=ˆÔÙr   c                óh   € R V n         \        4       V n        V P                  P	                  R4       R# )TN)Úsuccessr   ÚeventThreadIDr   Úcallbackr   s   &r   ÚoccurredÚListener.occurred6   s%   € ØˆŒÜ(›]ˆÔØ�‰×Ñ Ö%r   c                ó   € \        R 4      h)zSome problem)ÚRuntimeErrorr   s   &r   ÚbrokenOccurredÚListener.brokenOccurred;   s   € Ü˜>Ó*Ð*r   c                ó   € \        R 4      # )zEntirely different problem)ÚEnvironmentErrorr   s   &r   ÚreturnValueOccurredÚListener.returnValueOccurred>   s   € ÜÐ <Ó=Ð=r   c                óZ   € \        4       V n        V P                  P                  V4       R # r   )r   ÚconnLostThreadIDr   Úerrback)r   Úreasons   &&r   ÚconnectionLostÚListener.connectionLostA   s   € Ü +£ˆÔØ�‰×Ñ˜vÖ&r   )r   r(   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r   r   r(   r   r   r   r!   r%   r+   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r
   r
      sD   ø‡ € ñð* €GØ59Ð9€KÐ9�-Ð"2ò"òò&ò
+ò>÷'ð 'r   r
   c                   óN   a € ] tR t^Ft o Rt].tR tR tR t	R t
R tR tRtV tR	# )
ÚWin32EventsTestsBuilderz<
Builder defining tests relating to L{IReactorWin32Events}.
c                óF   € V P                  4       p\        \        V4       R# )zV
An instance of the reactor has all of the methods defined on
L{IReactorWin32Events}.
N)ÚbuildReactorr   r   )r   Úreactors   & r   Útest_interfaceÚ&Win32EventsTestsBuilder.test_interfaceM   s   € ð
 ×#Ñ#Ó%ˆÜÔ(¨'Ö2r   c                óê  a€ \        4       pV P                  4       o\        P                  ! RRRR4      p\	        4       pVP                  V3R l4       \        V4      pSP                  W$R4       SP                  \        P                  V4       V P                  S4       V P                  VP                  4       V P                  WP                  4       V P                  WP                  4       R# )z‚
When an event which has been added to the reactor is set, the action
associated with the event is invoked in the reactor thread.
NFc                 ó$   <€ SP                  4       # r   ©Ústop©Úignoredr:   s   &€r   Ú<lambda>Ú7Win32EventsTestsBuilder.test_addEvent.<locals>.<lambda>^   s   ø€ ¨W¯\©\¬^r   r   )r   r9   Ú
win32eventÚCreateEventr   ÚaddCallbackr
   ÚaddEventÚcallWhenRunningÚSetEventÚ
runReactorÚ
assertTruer   ÚassertEqualr   r   )r   ÚreactorThreadIDÚeventr   Úlistenerr:   s   &    @r   Útest_addEventÚ%Win32EventsTestsBuilder.test_addEventU   s¼   ø€ ô
 &›-ˆØ×#Ñ#Ó%ˆÜ×&Ò& t¨U°E¸4Ó@ˆÜ“:ˆØ×ÑÔ;Ô<Ü˜HÓ%ˆØ×Ñ˜¨*Ô5Ø×Ñ¤
× 3Ñ 3°UÔ;Ø�‰˜Ô Ø�‰˜×(Ñ(Ô)Ø×Ñ˜×*>Ñ*>Ô?Ø×Ñ˜×*@Ñ*@ÖAr   c                óœ  aa€ . oVV3R lpV P                  4       o\        P                  ! RRRR4      p\        4       p\	        V4      pVP                  V4       SP                  W$R4       SP                  \        P                  V4       V P                  S4       V P                  VP                  4       V P                  R.S4       R# )zc
Using L{IReactorWin32Events.addEvent} does not change which thread is
reported as the I/O thread.
c                 óZ   <€ SP                  \        4       4       SP                  4        R # r   )Úappendr   r@   )rB   r:   Úresultss   &€€r   ÚcheckÚAWin32EventsTestsBuilder.test_ioThreadDoesNotChange.<locals>.checkn   s   ø€ Ø�N‰Nœ<›>Ô*Ø�L‰LŽNr   NFr   T)r9   rE   rF   r   r
   rG   rH   rI   rJ   rK   rL   r   rM   )r   rW   rO   r   rP   r:   rV   s   &    @@r   Útest_ioThreadDoesNotChangeÚ2Win32EventsTestsBuilder.test_ioThreadDoesNotChangeg   sª   ù€ ð
 ˆö	ð ×#Ñ#Ó%ˆÜ×&Ò& t¨U°E¸4Ó@ˆÜ“:ˆÜ˜HÓ%ˆØ×Ñ˜UÔ#Ø×Ñ˜¨*Ô5Ø×Ñ¤
× 3Ñ 3°UÔ;Ø�‰˜Ô Ø�‰˜×(Ñ(Ô)Ø×Ñ˜$˜ Ö)r   c                ó†  a€ \        4       pV P                  4       o\        P                  ! RRRR4      p. p\	        4       pVP                  VP                  4       VP                  V3R l4       \        V4      pSP                  W%R4       SP                  \        P                  V4       V P                  S4       V P                  V^ ,          \        4       V^ ,          P                  \        4       V P!                  WP"                  4       V P!                  ^\%        V P'                  \        4      4      4       R# )zµ
If the event handler raises an exception, the event is removed from the
reactor and the handler's C{connectionLost} method is called in the I/O
thread and the exception is logged.
NFc                 ó$   <€ SP                  4       # r   r?   rA   s   &€r   rC   ÚBWin32EventsTestsBuilder.test_disconnectedOnError.<locals>.<lambda>Š   ó   ø€ ¨¯©¬r   r!   )r   r9   rE   rF   r   ÚaddBothrU   r
   rH   rI   rJ   rK   ÚassertIsInstancer   Útrapr    rM   r(   ÚlenÚflushLoggedErrors©r   rN   rO   Úresultr   rP   r:   s   &     @r   Útest_disconnectedOnErrorÚ0Win32EventsTestsBuilder.test_disconnectedOnError}   sò   ø€ ô &›-ˆØ×#Ñ#Ó%ˆÜ×&Ò& t¨U°E¸4Ó@ˆàˆÜ“:ˆØ×Ñ˜Ÿ™Ô'Ø×ÑÔ7Ô8ä˜HÓ%ˆØ×Ñ˜Ð*:Ô;Ø×Ñ¤
× 3Ñ 3°UÔ;Ø�‰˜Ô à×Ñ˜f Q�i¬Ô1Øˆq�	�‰”|Ô$à×Ñ˜×*CÑ*CÔDØ×Ñ˜œC × 6Ñ 6´|Ó DÓEÖFr   c                ó*  a€ \        4       pV P                  4       o\        P                  ! RRRR4      p. p\	        4       pVP                  VP                  4       VP                  V3R l4       \        V4      pSP                  W%R4       SP                  \        P                  V4       V P                  S4       V P                  V^ ,          \        4       V^ ,          P                  \        4       V P!                  WP"                  4       R# )z•
If the event handler returns a value, the event is removed from the
reactor and the handler's C{connectionLost} method is called in the I/O
thread.
NFc                 ó$   <€ SP                  4       # r   r?   rA   s   &€r   rC   ÚFWin32EventsTestsBuilder.test_disconnectOnReturnValue.<locals>.<lambda>¤   r^   r   r%   )r   r9   rE   rF   r   r_   rU   r
   rH   rI   rJ   rK   r`   r   ra   r$   rM   r(   rd   s   &     @r   Útest_disconnectOnReturnValueÚ4Win32EventsTestsBuilder.test_disconnectOnReturnValue—   sÓ   ø€ ô &›-ˆØ×#Ñ#Ó%ˆÜ×&Ò& t¨U°E¸4Ó@ˆàˆÜ“:ˆØ×Ñ˜Ÿ™Ô'Ø×ÑÔ7Ô8ä˜HÓ%ˆØ×Ñ˜Ð*?Ô@Ø×Ñ¤
× 3Ñ 3°UÔ;Ø�‰˜Ô à×Ñ˜f Q�i¬Ô1Øˆq�	�‰Ô'Ô(à×Ñ˜×*CÑ*CÖDr   c                ó4  € V P                  4       p\        P                  ! RRRR4      p\        4       p\	        V4      pVP                  W$R4       VP                  VP                  4       V P                  V4       V P                  VP                  4       R# )zž
Event handlers added with L{IReactorWin32Events.addEvent} do not have
C{connectionLost} called on them if they are still active when the
reactor shuts down.
NFr   )r9   rE   rF   r   r
   rH   rI   r@   rK   ÚassertIsNoner(   )r   r:   rO   r   rP   s   &    r   Útest_notDisconnectedOnShutdownÚ6Win32EventsTestsBuilder.test_notDisconnectedOnShutdown°   s{   € ð ×#Ñ#Ó%ˆÜ×&Ò& t¨U°E¸4Ó@ˆÜ“:ˆÜ˜HÓ%ˆØ×Ñ˜¨*Ô5Ø×Ñ §¡Ô-Ø�‰˜Ô Ø×Ñ˜(×3Ñ3Ö4r   © N)r-   r.   r/   r0   r1   r   ÚrequiredInterfacesr;   rQ   rY   rf   rk   ro   r2   r3   r4   s   @r   r7   r7   F   s;   ø‡ € ñð .Ð.Ðò3òBò$*ò,Gò4E÷25ð 5r   r7   )r1   rE   ÚImportErrorÚzope.interface.verifyr   Útwisted.internet.deferr   Útwisted.internet.interfacesr   Ú#twisted.internet.test.reactormixinsr   Útwisted.python.failurer   Útwisted.python.threadabler   r   r
   r7   ÚglobalsÚupdateÚmakeTestCaseClassesrq   r   r   Ú<module>r}      ss   ðñðÛõ /å +Ý ;Ý >Ý *ß ?÷-'ñ -'ô`w5˜nô w5ñt ƒ	× Ñ Ð(×<Ñ<Ó>Ö ?øðm ô Ø‚Jðús   „A) Á)	A5Á4A5