File: //lib/python3/dist-packages/twisted/test/__pycache__/test_unix.cpython-38.pyc
U
W[5; � @ s* d Z ddlmZmZ ddlZddlZddlZddlZddlm Z m
Z
mZmZm
Z
ddlmZmZ ddlmZ ddlmZmZ ddlmZ dd lmZ dd
lmZmZ G dd� dej�ZG d
d� dej�ZG dd� dej �Z!G dd� dej"�Z#G dd� dej�Z$e �%e
d��sde_&e �'e
d��s&de$_&dS )zK
Tests for implementations of L{IReactorUNIX} and L{IReactorUNIXDatagram}.
� )�division�absolute_importN)�
interfaces�reactor�protocol�error�address)�defer�utils)�lockfile)�_PY3�
networkString)�FilePath)�unittest)�MyServerFactory�MyClientFactoryc @ s 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__ s z&FailedConnectionClientFactory.__init__c C s | j �|� d S r )r Zerrback)r Z connector�reasonr r r �clientConnectionFailed s z4FailedConnectionClientFactory.clientConnectionFailedN)�__name__�
__module__�__qualname__r r r r r r r s r c @ sj e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dd� Zdd� Ze
r^de_dd� ZdS )�UnixSocketTestsz
Test unix sockets.
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� transportZgetPeer)�protoZexpected�Zpeernamer �
serverFactoryr r �
cbConnMade6 s
z1UnixSocketTests.test_peerBind.<locals>.cbConnMade)�mktempr r �Deferred�protocolConnectionMader �
listenUNIX�
addCleanup�
stopListening�socketZAF_UNIXZSOCK_STREAM�closeZbindZconnect�addCallback)r �filenameZconnMade�unixPortZ
unixSocketr&