%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f���b�dZddlZddlmZmZddlmZddlmZGd�d�Z	Gd�d	e�Z
y)
z&
Test code for basic Factory classes.
�N)�Protocol�ReconnectingClientFactory)�Clock)�TestCasec��eZdZdZd�Zd�Zy)�
FakeConnectorzP
    A fake connector class, to be used to mock connections failed or lost.
    c��y�N���selfs �=/usr/lib/python3/dist-packages/twisted/test/test_factories.py�stopConnectingzFakeConnector.stopConnecting����c��yr
rrs r�connectzFakeConnector.connectrrN)�__name__�
__module__�__qualname__�__doc__rrrrrrrs���
�
rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�ReconnectingFactoryTestsz1
    Tests for L{ReconnectingClientFactory}.
    c���Gd�d�}t�}t|_|jd�|j	�|j|�d�|j
|j�y)z�
        If a L{ReconnectingClientFactory} has C{stopTrying} called while it is
        connected, it does not subsequently attempt to reconnect if the
        connection is later lost.
        c��eZdZd�Zd�Zy)�QReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnectorc��td��)Nz%Shouldn't be called, we're connected.��RuntimeErrorrs rrz`ReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.stopConnecting)s��"�#J�K�Krc��td��)NzShouldn't be reconnecting.rrs rrzYReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.connect,s��"�#?�@�@rN)rrrrrrrr�NoConnectConnectorr(s��
L�
Arr!N)rr�protocol�
buildProtocol�
stopTrying�clientConnectionLost�assertFalse�continueTrying)r
r!�cs   r�test_stopTryingWhenConnectedz5ReconnectingFactoryTests.test_stopTryingWhenConnected!s\��	A�	A�
&�'����
�	�����	����	���1�3�T�:�����)�)�*rc�.��G�fd�dt�}t��t��_|��_�j�|j
�jj�|j
�jj��y)z
        Calling stopTrying on a L{ReconnectingClientFactory} doesn't attempt a
        retry on any active connector.
        c�"��eZdZdZ�fd�Zd�Zy)�[ReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnectorFc�*���j|d�y)z�
                Behave as though an ongoing connection attempt has now
                failed, and notify the factory of this.
                N)�clientConnectionFailed)r
�fs �rrzjReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.stopConnectingAs���
�(�(��t�4rc��d|_y)z|
                Record an attempt to reconnect, since this is what we
                are trying to avoid.
                TN)�attemptedRetryrs rrzcReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.connectHs��
'+��#rN)rrrr1rr)r/s�r�FactoryAwareFakeConnectorr,>s���"�N�
5�
+rr2N)	rrr�clock�	connectorr$r&r1�getDelayedCalls)r
r2r/s  @r�test_stopTryingDoesNotReconnectz8ReconnectingFactoryTests.test_stopTryingDoesNotReconnect8sl���	+�
�	+�"
&�'���'���0�1���	����	
������3�3�4�������0�0�2�3rc��t�}tjtj|��}|j	|j
|j
�y)z�
        A L{ReconnectingClientFactory} which hasn't been used for anything
        can be pickled and unpickled and end up with the same state.
        N)r�pickle�loads�dumps�assertEqual�__dict__)r
�original�
reconstituteds   r�test_serializeUnusedz-ReconnectingFactoryTests.test_serializeUnused[s?��
-�.�����V�\�\�(�%;�<�
�����*�*�M�,B�,B�Crc��t�}t�}||_tjtj
|��}|j
|j�y)z�
        The clock attribute of L{ReconnectingClientFactory} is not serialized,
        and the restored value sets it to the default value, the reactor.
        N)rrr3r8r9r:�assertIsNone)r
r3r=r>s    r�test_serializeWithClockz0ReconnectingFactoryTests.test_serializeWithClockdsE��
���,�.��������V�\�\�(�%;�<�
����-�-�-�.rc��t�}|jt�d�|j|j�tj|�}tj|�}|j|j�|j|j�|j|jd�|j|j|j�|j|j �y)z�
        A L{ReconnectingClientFactory} which is unpickled does not have an
        L{IConnector} and has its reconnecting timing parameters reset to their
        initial values.
        Nr)rr.r�
addCleanupr$r8r:r9rAr4�_callIDr;�retries�delay�initialDelay�
assertTruer')r
�factory�
serialized�unserializeds    r�$test_deserializationResetsParametersz=ReconnectingFactoryTests.test_deserializationResetsParametersos���,�-���&�&�}���=�����*�*�+��\�\�'�*�
��|�|�J�/�����,�0�0�1����,�.�.�/�����-�-�q�1�����+�+�W�-A�-A�B�����3�3�4rc��t�}t�}||_|jt	�d�|jt
|j�d�y)z�
        The clock used by L{ReconnectingClientFactory} can be parametrized, so
        that one can cleanly test reconnections.
        N�)rrr3r%rr;�len�calls)r
r3rJs   r�test_parametrizedClockz/ReconnectingFactoryTests.test_parametrizedClock�sE��
���+�-����
��$�$�]�_�d�;�����U�[�[�)�1�-rN)
rrrrr)r6r?rBrMrRrrrrrs'���+�.!4�FD�	/�5�$
.rr)rr8�twisted.internet.protocolrr�twisted.internet.taskr�twisted.trial.unittestrrrrrr�<module>rVs0���
�I�'�+�	
�	
�o.�x�o.r

Zerion Mini Shell 1.0