File: //lib/python3/dist-packages/twisted/test/__pycache__/test_unix.cpython-310.pyc
o
�b5 � @ s d Z ddlZddlZddlZddlmZ ddlmZmZm Z m
Z
mZmZm
Z
ddlmZ ddlmZ ddlmZ ddlmZmZ dd lmZ G d
d� dej�Zee
�ed� d�G d
d� dej��ZG dd� dej�ZG dd� dej�Z ee
�!ed� d�G dd� dej��Z"dS )zK
Tests for implementations of L{IReactorUNIX} and L{IReactorUNIXDatagram}.
� N)�skipIf)�address�defer�error�
interfaces�protocol�reactor�utils)�lockfile)�
networkString)�FilePath)�MyClientFactory�MyServerFactory)�unittestc @ � e Zd Zdd� Zdd� ZdS )�FailedConnectionClientFactoryc C s
|| _ d S �N)�onFail)�selfr � r �8/usr/lib/python3/dist-packages/twisted/test/test_unix.py�__init__ �
z&FailedConnectionClientFactory.__init__c C s | j �|� d S r )r �errback)r � connector�reasonr r r �clientConnectionFailed s z4FailedConnectionClientFactory.clientConnectionFailedN)�__name__�
__module__�__qualname__r r r r r r r � r �1This reactor does not support UNIX domain socketsc @ sh e Zd ZdZe�ed�sdZdd� Zdd� Z dd � Z
d
d� Zdd
� Zdd� Z
dd� Zdd� Zdd� ZdS )�UnixSocketTestsz
Test unix sockets.
Nr! c s� �� � }�� � � t� �t�� }�_t�|��}��|j� t � t j
t j�}��|j� |�
� � |�|� � ��fdd�}|�|� |S )z�
The address passed to the server factory's C{buildProtocol} method and
the address returned by the connected protocol's transport's C{getPeer}
method match the address the client socket is bound to.
c s0 t �� �}���j|g� ��| j�� |� d S r )r �UNIXAddress�assertEqual�
peerAddresses� transport�getPeer)�proto�expected��peernamer �
serverFactoryr r �
cbConnMade; s
z1UnixSocketTests.test_peerBind.<locals>.cbConnMade)�mktempr r �Deferred�protocolConnectionMader �
listenUNIX�
addCleanup�
stopListening�socket�AF_UNIX�SOCK_STREAM�close�bind�connect�addCallback)r �filename�connMade�unixPort�
unixSocketr- r r* r �
test_peerBind* s
zUnixSocketTests.test_peerBindc s� �� � �t� }t�� }||_t��|�}��|j� t � � t�� }|� _t�
�� � t�||g�}� ��fdd�}|�|� |S )z�
L{IReactorUNIX.connectUNIX} can be used to connect a client to a server
started with L{IReactorUNIX.listenUNIX}.
c s6 | \}}�� � jt���g� |j�� |j�� d S r )r$ r% r r# r&