| Server IP : 195.114.193.97 / Your IP : 216.73.217.111 Web Server : LiteSpeed System : Linux host 5.15.0-126-generic #136-Ubuntu SMP Wed Nov 6 10:38:22 UTC 2024 x86_64 User : sembi4241 ( 1126) PHP Version : 8.1.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/twisted/test/__pycache__/ |
Upload File : |
o
�b� � @ sV d Z ddlZddlmZmZ ddlmZ ddlmZ G dd� d�Z G dd � d e�Z
dS )
z&
Test code for basic Factory classes.
� N)�Protocol�ReconnectingClientFactory)�Clock)�TestCasec @ s e Zd ZdZdd� Zdd� ZdS )�
FakeConnectorzP
A fake connector class, to be used to mock connections failed or lost.
c C � d S �N� ��selfr r �=/usr/lib/python3/dist-packages/twisted/test/test_factories.py�stopConnecting � zFakeConnector.stopConnectingc C r r r r
r r r �connect r zFakeConnector.connectN)�__name__�
__module__�__qualname__�__doc__r
r r r r r r s r c @ s@ e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dS )�ReconnectingFactoryTestsz1
Tests for L{ReconnectingClientFactory}.
c C sJ G dd� d�}t � }t|_|�d� |�� |�|� d� | �|j� dS )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 @ s e Zd Zdd� Zdd� ZdS )zQReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnectorc S � t d��)Nz%Shouldn't be called, we're connected.��RuntimeErrorr
r r r r
) � z`ReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.stopConnectingc S r )NzShouldn't be reconnecting.r r
r r r r , r zYReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.connectN)r r r r
r r r r r �NoConnectConnector( s r N)r r �protocol�
buildProtocol�
stopTrying�clientConnectionLost�assertFalse�continueTrying)r r �cr r r �test_stopTryingWhenConnected! s
z5ReconnectingFactoryTests.test_stopTryingWhenConnectedc sT G � fdd�dt �}t� � t� � _|� � _� �� | �� jj� | �� j�� � dS )z
Calling stopTrying on a L{ReconnectingClientFactory} doesn't attempt a
retry on any active connector.
c s$ e Zd ZdZ� fdd�Zdd� ZdS )z[ReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnectorFc s � � | d� dS )z�
Behave as though an ongoing connection attempt has now
failed, and notify the factory of this.
N)�clientConnectionFailedr
��fr r r
A s zjReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.stopConnectingc S s
d| _ dS )z|
Record an attempt to reconnect, since this is what we
are trying to avoid.
TN)�attemptedRetryr
r r r r H s
zcReconnectingFactoryTests.test_stopTryingDoesNotReconnect.<locals>.FactoryAwareFakeConnector.connectN)r r r r% r
r r r# r r �FactoryAwareFakeConnector>