관리-도구
편집 파일: test_utils.cpython-37.opt-1.pyc
B �k�a�R � @ sP d Z ddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl mZmZ ddl mZ ddlmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZmZ dd l m!Z! ddl"Z"dd l#m$Z$m%Z% ddl&m'Z'm(Z( dd l m)Z) ddl*m+Z+ ddl,m-Z- ddl.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;m<Z< ddl=m>Z> e�r|ddl?m@Z@ ndZ@e/�r�ddlmAZB nddlCmBZB ejDdk�o�ejEdkZFejGfeHejIejd�dd�ZJeHeKejIejd�dd�ZLeKd�d d!�ZMG d"d#� d#e�ZNG d$d%� d%eN�ZOG d&d'� d'eN�ZPG d(d)� d)�ZQG d*d+� d+eB�ZReeeed,�d-d.�ZSeg ejTf ZUejVejWd/feUeXeejT d0�d1d2��ZYejWfeUejTd3�d4d5�ZZdGejTeXdd6�d7d8�Z[ej\d�d9d:�Z]dHee@ ej^d;�d<d=�Z_dIe0e2dd�d/de0e0e0e0dd>d?d@�eHeHeee2eXeeeeeee@ eKee8dA�dBdC�Z`e0e0feeedD�dEdF�ZadS )JzUtilities shared by tests.� N)�ABC�abstractmethod)� TracebackType) � TYPE_CHECKING�Any�Callable�Iterator�List�Optional�Type�Union�cast)�mock)�Signal)�CIMultiDict�CIMultiDictProxy)�URL)�_RequestContextManager�_WSRequestContextManager� )� ClientSession�hdrs)�AbstractCookieJar)�ClientResponse)�ClientWebSocketResponse)�PY_38�sentinel)�HttpVersion�RawRequestMessage)�Application� AppRunner� BaseRunner�Request�Server�ServerRunner�SockSite�UrlMappingMatchInfo)�_RequestHandler)� SSLContext)�IsolatedAsyncioTestCase)�TestCase�posix�cygwin)�host�family�returnc C s t | d|�S )Nr )�get_port_socket)r- r. � r1 �E/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/test_utils.py�get_unused_port_socketA s r3 )r- �portr. r/ c C s6 t � |t j�}tr$|�t jt jd� |�| |f� |S )Nr )�socket�SOCK_STREAM� REUSE_ADDRESSZ setsockoptZ SOL_SOCKETZSO_REUSEADDR�bind)r- r4 r. �sr1 r1 r2 r0 G s r0 )r/ c C s8 t � t jt j��} | �d� tt| �� d �S Q R X dS )z1Return a port that is unused on the current host.)z 127.0.0.1r r N)r5 �AF_INETr6 r8 r �int�getsockname)r9 r1 r1 r2 �unused_portT s r= c @ sF e Zd ZdZedddded�eeef e e j ee e e eeeejgejf edd�dd�Zd#e e j edd�d d �Zeeed�dd ��Zeed�dd�Zee d�dd��Zee d�dd��Zeed�dd��Zdd�dd�Zdd�dd�Ze e e! e e! e e" dd�dd�Z#d d�dd �Z$e e e! e e! e e" dd�d!d"�Z%dS )$�BaseTestServerFNz 127.0.0.1)�scheme�loopr- r4 �skip_url_asserts�socket_factory)r? r@ r- r4 rA rB �kwargsr/ c K s: || _ d | _d | _|| _|| _d| _|| _|| _|| _d S )NF) �_loop�runner�_rootr- r4 �_closedr? rA rB )�selfr? r@ r- r4 rA rB rC r1 r1 r2 �__init__^ s zBaseTestServer.__init__)r@ rC r/ c � sV | j r d S || _|�dd �| _| jf |�I d H | _ | j �� I d H | jsNd| _yt�| j �j }W n tk rx d}Y nX |dkr�tj ntj}| �| j | j|�}|�� d d� \| _ | _t| j || jd�}|�� I d H |j}|d k s�t�|j}|d k s�t�|d �� d | _| jtk�r2| j�r(d} nd } | | _t| j� d | j � d| j� ��| _d S )N�sslr � � � )ZsockZssl_contextr Zhttps�httpz://�:)rE rD �popZ_ssl�_make_runnerZsetupr4 � ipaddressZ ip_addressr- �version� ValueErrorr5 ZAF_INET6r: rB r<