%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_win32events.cpython-312.pyc

�

Ϫ�f1����dZ	ddlZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZmZGd	�d
�ZGd�de
�Ze�j'ej)��y#e$rdZY�iwxYw)
z6
Tests for implementations of L{IReactorWin32Events}.
�N)�verifyObject)�Deferred)�IReactorWin32Events)�ReactorBuilder)�Failure)�getThreadID�isInIOThreadc�D�eZdZdZdZdxZxZZd�Zd�Z	d�Z
d�Zd�Zd	�Z
y)
�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��||_y�N)�	_finished)�self�finisheds  �H/usr/lib/python3/dist-packages/twisted/internet/test/test_win32events.py�__init__zListener.__init__/s	��!���c�"�t�|_y)Nr)r�logThreadID�rs r�	logPrefixzListener.logPrefix2s��&�=���rc�f�d|_t�|_|jj	d�y)NT)�successr�
eventThreadIDr�callbackrs r�occurredzListener.occurred6s%�����(�]���������%rc��td��)NzSome problem)�RuntimeErrorrs r�brokenOccurredzListener.brokenOccurred;s
���>�*�*rc��td�S)NzEntirely different problem)�EnvironmentErrorrs r�returnValueOccurredzListener.returnValueOccurred>s��� <�=�=rc�X�t�|_|jj|�yr
)r�connLostThreadIDr�errback)r�reasons  r�connectionLostzListener.connectionLostAs�� +�
��������v�&r)�__name__�
__module__�__qualname__�__doc__rrrr$rrrrr"r'�rrrrs<���*�G�59�9�K�9�-�"2�"��&�
+�>�'rrc�:�eZdZdZegZd�Zd�Zd�Zd�Z	d�Z
d�Zy)	�Win32EventsTestsBuilderzD
    Builder defining tests relating to L{IReactorWin32Events}.
    c�D�|j�}tt|�y)zn
        An instance of the reactor has all of the methods defined on
        L{IReactorWin32Events}.
        N)�buildReactorrr)r�reactors  r�test_interfacez&Win32EventsTestsBuilder.test_interfaceMs��
�#�#�%���(�'�2rc����t�}|j��tjdddd�}t	�}|j�fd��t
|�}�j||d��jtj|�|j��|j|j�|j||j�|j||j�y)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�$���j�Sr
��stop��ignoredr1s �r�<lambda>z7Win32EventsTestsBuilder.test_addEvent.<locals>.<lambda>^s
���W�\�\�^�rr)rr0�
win32event�CreateEventr�addCallbackr�addEvent�callWhenRunning�SetEvent�
runReactor�
assertTruer�assertEqualrr)r�reactorThreadID�eventr�listenerr1s     @r�
test_addEventz%Win32EventsTestsBuilder.test_addEventUs����
&�-���#�#�%���&�&�t�U�E�4�@���:�����;�<��H�%�������*�5����
� 3� 3�U�;����� �����(�(�)�����(�*>�*>�?�����(�*@�*@�Arc����g���fd�}|j��tjdddd�}t�}t	|�}|j|��j
||d��jtj|�|j��|j|j�|jdg��y)z{
        Using L{IReactorWin32Events.addEvent} does not change which thread is
        reported as the I/O thread.
        c�X���jt���j�yr
)�appendr	r6)r8r1�resultss ��r�checkzAWin32EventsTestsBuilder.test_ioThreadDoesNotChange.<locals>.checkns����N�N�<�>�*��L�L�NrNFrT)
r0r:r;rrr<r=r>r?r@rArrB)rrKrDrrEr1rJs     @@r�test_ioThreadDoesNotChangez2Win32EventsTestsBuilder.test_ioThreadDoesNotChangegs����
��	��#�#�%���&�&�t�U�E�4�@���:���H�%�����U�#������*�5����
� 3� 3�U�;����� �����(�(�)����$���)rc�t��t�}|j��tjdddd�}g}t	�}|j|j�|j�fd��t|�}�j||d��jtj|�|j��|j|dt�|djt�|j!||j"�|j!dt%|j't���y)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�$���j�Sr
r5r7s �rr9zBWin32EventsTestsBuilder.test_disconnectedOnError.<locals>.<lambda>��
�������rrr�)rr0r:r;r�addBothrIrr=r>r?r@�assertIsInstancer�traprrBr$�len�flushLoggedErrors�rrCrD�resultrrEr1s      @r�test_disconnectedOnErrorz0Win32EventsTestsBuilder.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�Frc���t�}|j��tjdddd�}g}t	�}|j|j�|j�fd��t|�}�j||d��jtj|�|j��|j|dt�|djt�|j!||j"�y)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�$���j�Sr
r5r7s �rr9zFWin32EventsTestsBuilder.test_disconnectOnReturnValue.<locals>.<lambda>�rOrr"r)rr0r:r;rrQrIrr=r>r?r@rRrrSr!rBr$rVs      @r�test_disconnectOnReturnValuez4Win32EventsTestsBuilder.test_disconnectOnReturnValue�s����&�-���#�#�%���&�&�t�U�E�4�@�����:��������'����7�8��H�%�������*?�@����
� 3� 3�U�;����� ����f�Q�i��1��q�	���'�(�����(�*C�*C�Drc�2�|j�}tjdddd�}t�}t	|�}|j||d�|j
|j�|j|�|j|j�y)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)r0r:r;rrr=r>r6r@�assertIsNoner$)rr1rDrrEs     r�test_notDisconnectedOnShutdownz6Win32EventsTestsBuilder.test_notDisconnectedOnShutdown�s}���#�#�%���&�&�t�U�E�4�@���:���H�%�������*�5�������-����� ����(�3�3�4rN)r(r)r*r+r�requiredInterfacesr2rFrLrXr[r^r,rrr.r.Fs3���.�.��3�B�$*�,G�4E�2
5rr.)r+r:�ImportError�zope.interface.verifyr�twisted.internet.deferr�twisted.internet.interfacesr�#twisted.internet.test.reactormixinsr�twisted.python.failurer�twisted.python.threadablerr	rr.�globals�update�makeTestCaseClassesr,rr�<module>rjss�����/�+�;�>�*�?�-'�-'�`w5�n�w5�t�	���(�<�<�>�?��m���J��s�A(�(A2�1A2

Zerion Mini Shell 1.0