%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_posixbase.cpython-312.pyc

�

Ϫ�f=.��\�dZddlZddlmZddlmZddlmZmZddl	m
Z
ddlmZddl
mZdZ	dd	lmZdd
lmZddlmZdd
lmZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zy#e$rdZY�nwxYw)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�,��eZdZdZ�fd�Z�fd�Z�xZS)�WarningCheckerTestCasezg
    A test case that will make sure that no warnings are left unchecked at the end of a test run.
    c����t�|��tjj	dd�j�dk(r&t
j�r|j�yyy)N�CI��true)	�super�setUp�os�environ�get�lowerr�	isWindows�
flushWarnings)�self�	__class__s ��F/usr/lib/python3/dist-packages/twisted/internet/test/test_posixbase.pyrzWarningCheckerTestCase.setUp sN���
��
���:�:�>�>�$��#�)�)�+�v�5�(�:L�:L�:N���� �;O�5�c���	t�|��|j�}tjjdd�j
�dk(rtj�ry|jt|�dd|���y#|j�}tjjdd�j
�dk(rtj�rYy|jt|�dd|���wxYw)Nrrrrz'Warnings found at the end of the test:
)r�tearDownrrrrrrr�assertEqual�len)r�warningsrs  �rr!zWarningCheckerTestCase.tearDown+s����	��G����)�)�+�H��z�z�~�~�d�B�'�-�-�/�6�9�h�>P�>P�>R������H�
�q�$L�X�J�"W�
���)�)�+�H��z�z�~�~�d�B�'�-�-�/�6�9�h�>P�>P�>R������H�
�q�$L�X�J�"W�
�s�B�AD�  D)�__name__�
__module__�__qualname__�__doc__rr!�
__classcell__)rs@rrrs����	!��rrc�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�TrivialReactorc�J�i|_i|_tj|�y�N)�_readers�_writersr�__init__�rs rr0zTrivialReactor.__init__>s����
���
��!�!�$�'rc�"�d|j|<y�NT�r.�r�readers  r�	addReaderzTrivialReactor.addReaderC��� $��
�
�f�rc��|j|=yr-r4r5s  r�removeReaderzTrivialReactor.removeReaderF����M�M�&�!rc�"�d|j|<yr3�r/�r�writers  r�	addWriterzTrivialReactor.addWriterIr8rc��|j|=yr-r=r>s  r�removeWriterzTrivialReactor.removeWriterLr;rN)r%r&r'r0r7r:r@rB�rrr+r+=s��(�
%�"�%�"rr+c�(�eZdZdZd�Zd�Zd�Zd�Zy)�PosixReactorBaseTestsz(
    Tests for L{PosixReactorBase}.
    c���|j|jt�|j|j|j�|j|j|j
�yr-)�assertIsInstance�wakerr�assertIn�_internalReadersr.�rrs  r�_checkWakerz!PosixReactorBaseTests._checkWakerUsF�����g�m�m�V�4��
�
�g�m�m�W�%=�%=�>��
�
�g�m�m�W�%5�%5�6rc�:�t�}|j|�y)z
        When L{PosixReactorBase} is instantiated, it creates a waker and adds
        it to its internal readers set.
        N)r+rLrKs  r�test_wakerIsInternalReaderz0PosixReactorBaseTests.test_wakerIsInternalReaderZs��
!�"������!rc�f�t�}t�}|jj|�|j|�|j
|j|j�|j|�|j||j�|j||j�y)z�
        Any L{IReadDescriptor}s in L{PosixReactorBase._internalReaders} are
        left alone by L{PosixReactorBase._removeAll}.
        N)
r+�objectrJ�addr7�
_removeAllr.r/rLrI)rr�extras   r�"test_removeAllSkipsInternalReadersz8PosixReactorBaseTests.test_removeAllSkipsInternalReadersbs���
!�"������ � �$�$�U�+�����%� �����7�+�+�W�-=�-=�>�����!��
�
�e�W�5�5�6��
�
�e�W�-�-�.rc��t�}t�}t�}|j|�|j|�|j|j
|j�}|jt|�||h�|j||j
�|j||j�y)z�
        L{PosixReactorBase._removeAll} returns a list of removed
        L{IReadDescriptor} and L{IWriteDescriptor} objects.
        N)
r+rPr7r@rRr.r/r"�set�assertNotIn)rrr6r?�removeds     r�'test_removeAllReturnsRemovedDescriptorsz=PosixReactorBaseTests.test_removeAllReturnsRemovedDescriptorsps���
!�"������������&�!�����&�!�$�'�$�$�W�%5�%5�w�7G�7G�H������W����'7�8������!1�!1�2������!1�!1�2rN)r%r&r'r(rLrNrTrYrCrrrErEPs���7�
"�/�
3rrEc�,�eZdZdZeee�sdZd�Zy)�TCPPortTestsz1
    Tests for L{twisted.internet.tcp.Port}.
    zNon-posixbase reactorc��tdt��}d|_d�|_|j	|j�t�S)z�
        L{Port.stopListening} returns a L{Deferred} which errbacks if
        L{Port.connectionLost} raises an exception.
        i90Tc��ddzS)N�rrC)�reasons r�<lambda>z8TCPPortTests.test_connectionLostFailed.<locals>.<lambda>�s
��Q�!�V�r)r
r�	connected�connectionLost�
assertFailure�
stopListening�ZeroDivisionError)r�ports  r�test_connectionLostFailedz&TCPPortTests.test_connectionLostFailed�s>��
�E�=�?�+�����3����!�!�$�"4�"4�"6�8I�J�JrN)	r%r&r'r(�
isinstancerr�skiprgrCrrr[r[�s����g�/�0�&��Krr[c�H�eZdZdZd�Zdeddfd�Zdeddfd�Zd�Zd	�Z	d
�Z
y)�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�Z�tj|�t�|_d|_y)N�d)rr0r�iterationTimeout�nowr1s rr0zTimeoutReportReactor.__init__�s!���!�!�$�'� (�
�����rr6�returnNc��y)z�
        Ignore the reader.  This is necessary because the waker will be
        added.  However, we won't actually monitor it for any events.
        NrCr5s  rr7zTimeoutReportReactor.addReader���rc��y)z#
        See L{addReader}.
        NrCr5s  rr:z!TimeoutReportReactor.removeReader�rrrc��gS)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.
        rCr1s r�	removeAllzTimeoutReportReactor.removeAll�s	���	rc��|jS)zx
        Override the real clock with a deterministic one that can be easily
        controlled in a unit test.
        )ror1s r�secondszTimeoutReportReactor.seconds�s
��
�x�x�rc�R�|j}|�d|_|j|�yyr-)rn�callback)r�timeout�ds   r�doIterationz TimeoutReportReactor.doIteration�s+���!�!���=�$(�D�!�
�J�J�w��r)r%r&r'r(r0rr7r:rurwr|rCrrrkrk�sA����
���D���?��t��
�� rrkc�@�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zy
)�IterationTimeoutTestsz�
    Tests for the timeout argument L{PosixReactorBase.run} calls
    L{PosixReactorBase.doIteration} with in the presence of various delayed
    calls.
    c���g}�jj|j��jj�fd���j�|dS)Nc�&���j�Sr-)�stop)�ignoredrs �rr`z>IterationTimeoutTests._checkIterationTimeout.<locals>.<lambda>�s���\�W�\�\�^�rr)rn�addCallback�append�run�rrrzs ` r�_checkIterationTimeoutz,IterationTimeoutTests._checkIterationTimeout�sJ������ � �,�,�W�^�^�<�� � �,�,�-K�L�����
��q�z�rc�\�t�}|j|�}|j|�y)zl
        If there are no delayed calls, C{doIteration} is called with a
        timeout of L{None}.
        N)rkr��assertIsNoner�s   r�test_noCallsz"IterationTimeoutTests.test_noCalls�s*��
'�(���-�-�g�6�����'�"rc��t�}|jdd��|j|�}|j|d�y)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.
        rmc��yr-rCrCrrr`z8IterationTimeoutTests.test_delayedCall.<locals>.<lambda>�rrrN�rk�	callLaterr�r"r�s   r�test_delayedCallz&IterationTimeoutTests.test_delayedCall�s>��'�(������#�|�,��-�-�g�6������#�&rc��t�}|jdd��|xjdz
c_|j|�}|j	|d�y)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.
        rmc��yr-rCrCrrr`z7IterationTimeoutTests.test_timePasses.<locals>.<lambda>�rrr��KN)rkr�ror�r"r�s   r�test_timePassesz%IterationTimeoutTests.test_timePasses�sL��'�(������#�|�,����r����-�-�g�6������"�%rc���t�}|jdd��|jdd��|jdd��|j|�}|j|d�y)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.
        �2c��yr-rCrCrrr`zAIterationTimeoutTests.test_multipleDelayedCalls.<locals>.<lambda>�rrr�
c��yr-rCrCrrr`zAIterationTimeoutTests.test_multipleDelayedCalls.<locals>.<lambda>�rrrrmc��yr-rCrCrrr`zAIterationTimeoutTests.test_multipleDelayedCalls.<locals>.<lambda>�rrrNr�r�s   r�test_multipleDelayedCallsz/IterationTimeoutTests.test_multipleDelayedCalls�sb��'�(������"�l�+�����"�l�+�����#�|�,��-�-�g�6������"�%rc���t�}|jdd��}|xjdz
c_|jd�|j	|�}|j|d�y)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.
        r�c��yr-rCrCrrr`z=IterationTimeoutTests.test_resetDelayedCall.<locals>.<lambda>rrrr��N)rkr�ro�resetr�r"�rr�callrzs    r�test_resetDelayedCallz+IterationTimeoutTests.test_resetDelayedCall�sY��'�(�� �w� � ��\�2�����r����
�
�2���-�-�g�6������"�%rc���t�}|jdd��}|xjdz
c_|jd�|j	|�}|j|d�y)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.
        r�c��yr-rCrCrrr`z=IterationTimeoutTests.test_delayDelayedCall.<locals>.<lambda>rrrr���<N)rkr�ro�delayr�r"r�s    r�test_delayDelayedCallz+IterationTimeoutTests.test_delayDelayedCallsY��'�(�� �w� � ��\�2�����r����
�
�2���-�-�g�6������"�%rc��t�}|jdd��}|j�|j|�}|j	|�y)zp
        If the only delayed call is canceled, L{None} is the timeout passed
        to C{doIteration}.
        r�c��yr-rCrCrrr`z>IterationTimeoutTests.test_cancelDelayedCall.<locals>.<lambda>rrrN)rkr��cancelr�r�r�s    r�test_cancelDelayedCallz,IterationTimeoutTests.test_cancelDelayedCallsG��
'�(�� �w� � ��\�2�����
��-�-�g�6�����'�"rN)r%r&r'r(r�r�r�r�r�r�r�r�rCrrr~r~�s/����#�	'�
&�&�&�&�	#rr~c�$�eZdZdZe�eZd�Zd�Zy)�ConnectedDatagramPortTestsz/
    Test connected datagram UNIX sockets.
    Nc�|���fd�}tjdt��}||_|j	d�y)z�
        L{ConnectedDatagramPort} does not call the deprecated C{loseConnection}
        in L{ConnectedDatagramPort.connectionFailed}.
        c�(���jd�y)z�
            Dummy C{loseConnection} method. C{loseConnection} is deprecated and
            should not get called.
            z7loseConnection is deprecated and should not get called.N)�failr1s�r�loseConnectionz`ConnectedDatagramPortTests.test_connectionFailedDoesntCallLoseConnection.<locals>.loseConnection0s���

�I�I�O�PrN�goodbye)r
�ConnectedDatagramPortrr��connectionFailed)rr�rfs`  r�-test_connectionFailedDoesntCallLoseConnectionzHConnectedDatagramPortTests.test_connectionFailedDoesntCallLoseConnection*s5���	Q��)�)�$��
�>��,������i�(rc���d�_�fd�}tjdt��}||_|jd��j
�j�y)z�
        L{ConnectedDatagramPort} calls L{ConnectedDatagramPort.stopListening}
        instead of the deprecated C{loseConnection} in
        L{ConnectedDatagramPort.connectionFailed}.
        Fc���d�_y)z8
            Dummy C{stopListening} method.
            TN)�calledr1s�rrdzYConnectedDatagramPortTests.test_connectionFailedCallsStopListening.<locals>.stopListeningCs����D�KrNr�)r�r
r�rrdr��
assertTrue)rrdrfs`  r�'test_connectionFailedCallsStopListeningzBConnectedDatagramPortTests.test_connectionFailedCallsStopListening;sM������	��)�)�$��
�>��*������i�(�������$r)r%r&r'r(�skipSocketsrir�r�rCrrr�r�"s�������)�"%rr�c��eZdZd�Zy)�
WakerTestsc���t�}|j�}|jt|�d|�|j	d�|j�}|jt|�d|�y)zH
        No warnings are generated when constructing the waker.
        rN)rrr"r#rb)rrHr$s   r� test_noWakerConstructionWarningsz+WakerTests.test_noWakerConstructionWarningsPsc������%�%�'������X���8�4�	���T�"��%�%�'������X���8�4rN)r%r&r'r�rCrrr�r�Os��5rr�) r(r�twisted.internet.deferr�twisted.internet.interfacesr�twisted.internet.posixbaserr�twisted.internet.protocolr�twisted.python.runtimer�twisted.trial.unittestr	r��twisted.internetr
�twisted.test.test_unixr�ImportErrorr�twisted.internet.tcpr
rr+rEr[rkr~r�r�rCrr�<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+

Zerion Mini Shell 1.0