Файловый менеджер - Редактировать - /opt/imh-python/lib/python3.9/site-packages/twisted/test/__pycache__/test_factories.cpython-39.pyc
Ðазад
a k�h� � @ 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 s d S �N� ��selfr r ��/root/rpmbuild/BUILDROOT/imh-python39-modules-3.9.7-92.el8.x86_64/opt/imh-python/lib/python3.9/site-packages/twisted/test/test_factories.py�stopConnecting s zFakeConnector.stopConnectingc C s d S r r r r r r �connect s 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 s t d��d S )Nz%Shouldn't be called, we're connected.��RuntimeErrorr r r r r ) s z`ReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.stopConnectingc S s t d��d S )NzShouldn't be reconnecting.r r r r r r , s zYReconnectingFactoryTests.test_stopTryingWhenConnected.<locals>.NoConnectConnector.connectN)r r r r r r r r r �NoConnectConnector( s r N)r r �protocolZ 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>