MOON
Server: Apache
System: Linux server30c.hostingraja.org 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64
User: jibhires (1887)
PHP: 8.1.30
Disabled: show_source, system, shell_exec, passthru, exec, popen, proc_open, allow_url_fopen, symlink, escapeshellcmd, pcntl_exec
Upload Files
File: //opt/alt/python37/lib64/python3.7/site-packages/aiohttp/__pycache__/pytest_plugin.cpython-37.pyc
B

�k�a�-�@sddlZddlZddlZddlmZddlmZmZmZmZm	Z	m
Z
mZddlZddl
mZmZddlmZddlmZmZmZmZmZmZmZmZyddlZWnek
r�dZYnXyddlZWnek
r�dZYnXeeeefgeefZdd	�Z d
d�Z!ej"dd
��Z#ej"dd��Z$ej%dd��Z&ej%d0dd��Z'dd�Z(dd�Z)dd�Z*ej"dd��Z+ej"dd��Z,ej"dd ��Zej"d!d"��Z-ej"d#d$��Z.ej"d%d&��Z/ej"d'd(��Z0ej"d)d*��Z1ej"ej2e	eddfd+�d,d-��Z3ej"d.d/��Z4dS)1�N)�Callable)�Any�	Awaitabler�Dict�	Generator�Optional�Union)�PY_37�isasyncgenfunction)�Application�)�BaseTestServer�
RawTestServer�
TestClient�
TestServer�loop_context�setup_test_loop�teardown_test_loop�unused_portcCs:|jddddd�|jdddd	d�|jd
dddd�dS)Nz--aiohttp-fast�
store_trueFz*run tests faster by disabling extra checks)�action�default�helpz--aiohttp-loopZstore�pyloopz:run tests with specific loop: pyloop, uvloop, tokio or allz--aiohttp-enable-loop-debugzenable event loop debug mode)Z	addoption)�parser�r�H/opt/alt/python37/lib64/python3.7/site-packages/aiohttp/pytest_plugin.py�pytest_addoption$srcsb|j�t��rd�nt���r$d�ndSd�d|jkrH|jd7_d����fdd�}||_dS)zjSet up pytest fixture.

    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFN�request)rcsv|d}�r|d=d|jkr$td��|�d���rb�||����fdd�}|�|�������S���||��SdS)Nr�loopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.cs(y������Stk
r"YnXdS)N)�run_until_complete�	__anext__�StopAsyncIterationr)�_loop�genrr�	finalizerdsz8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer)�fixturenames�	ExceptionZgetfixturevalueZaddfinalizerr r!)�args�kwargsrr%)�func�is_async_gen�
strip_request)r#r$r�wrapperOs



z%pytest_fixture_setup.<locals>.wrapper)r*r
�asyncio�iscoroutinefunction�argnames)Z
fixturedefr-r)r*r+r,r�pytest_fixture_setup9s

 r1cCs|j�d�S)z--fast config optionz--aiohttp-fast)�config�	getoption)rrrr�fastrsr4cCs|j�d�S)z!--enable-loop-debug config optionz--aiohttp-enable-loop-debug)r2r3)rrrr�
loop_debugxsr5c	cs`tjdd��J}dVdd�|D�}|rRtd�t|�t|�dkrBdnd	d
�|����WdQRXdS)z�Context manager which checks for RuntimeWarnings.

    This exists specifically to
    avoid "coroutine 'X' was never awaited" warnings being missed.

    If RuntimeWarnings occur in the context a RuntimeError is raised.
    T)�recordNcSs"g|]}|jtkrdj|d��qS)z#{w.filename}:{w.lineno}:{w.message})�w)�category�RuntimeWarning�format)�.0r7rrr�
<listcomp>�sz,_runtime_warning_context.<locals>.<listcomp>z{} Runtime Warning{},
{}r��s�
)�warnings�catch_warnings�RuntimeErrorr:�len�join)�	_warningsZrwrrr�_runtime_warning_context~s	rFFccs(|r|Vnt�}|Vt||d�dS)z�Passthrough loop context.

    Sets up and tears down a loop unless one is passed in via the loop
    argument when it's passed straight through.
    )r4N)rr)rr4rrr�_passthrough_loop_context�s
rGcCs(|�|�r$t�|�r$t|�||��SdS)z%Fix pytest collecting for coroutines.N)Zfuncnamefilterr.r/�listZ
_genfunctions)Z	collector�name�objrrr�pytest_pycollect_makeitem�srKc
s��j�d�}t��j�r��j�d�p0�j�dd�}t��Ft||d��.}�fdd��j	j
D�}|��jf|��WdQRXWdQRXdSdS)	zBRun coroutines in an event loop instead of a normal function call.z--aiohttp-fast�
proactor_looprN)r4csi|]}�j||�qSr)�funcargs)r;�arg)�
pyfuncitemrr�
<dictcomp>�sz&pytest_pyfunc_call.<locals>.<dictcomp>T)
r2r3r.r/ZfunctionrM�getrFrGZ_fixtureinfor0r rJ)rOr4Z
existing_loopr#Ztestargsr)rOr�pytest_pyfunc_call�s
&rRcCs�d|jkrdS|jjj}dtji}tdk	r4tj|d<tdk	rFtj|d<|dkrRd}i}x\|�	d�D]N}|�
d�}|�d	�}||kr�|rbtd
|t
|���f��nqb||||<qbW|jdt
|���t
|���d�dS)N�loop_factoryr�uvloop�tokio�allzpyloop,uvloop?,tokio?�,�?z ?z&Unknown loop '%s', available loops: %s)Zids)r&r2ZoptionZaiohttp_loopr.ZDefaultEventLoopPolicyrTZEventLoopPolicyrU�split�endswith�strip�
ValueErrorrH�keysZparametrize�values)ZmetafuncZloopsZavail_factoriesZ	factoriesrIZrequiredrrr�pytest_generate_tests�s.





r_c	csH|�}t�|�t|d��$}|r*|�d�t�|�|VWdQRXdS)z%Return an instance of the event loop.)r4TN)r.�set_event_loop_policyrZ	set_debug�set_event_loop)rSr4r5�policyr#rrrr�s


rc	csRtst��}tj|_nt��}t�|�t|j��}t�	|�|VWdQRXdS)N)
r	r.Zget_event_loop_policyZProactorEventLoopZ
_loop_factoryZWindowsProactorEventLoopPolicyr`rZnew_event_loopra)rbr#rrrrL�s


rLcCstjdtdd�|S)Nz3Deprecated, use aiohttp_unused_port fixture instead�)�
stacklevel)r@�warn�DeprecationWarning)�aiohttp_unused_portrrrr�s
rcCstS)z1Return a port that is unused on the current host.)�_unused_portrrrrrgsrgc#s@g�dd���fdd�
}|Vdd��fdd�}��|��dS)z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    N)�portc�s4t||d�}|jfd�i|��IdH��|�|S)N)rir)r�start_server�append)Zapprir)�server)r�serversrr�gos
zaiohttp_server.<locals>.go)�returnc�s x�r�����IdHqWdS)N)�pop�closer)rmrr�finalizesz aiohttp_server.<locals>.finalize)r )rrnrrr)rrmr�aiohttp_servers
rscCstjdtdd�|S)Nz.Deprecated, use aiohttp_server fixture insteadrc)rd)r@rerf)rsrrr�test_server"s
rtc#s@g�dd���fdd�
}|Vdd��fdd�}��|��dS)zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    N)ric�s4t||d�}|jfd�i|��IdH��|�|S)N)rir)rrjrk)Zhandlerrir)rl)rrmrrrn4s
zaiohttp_raw_server.<locals>.go)roc�s x�r�����IdHqWdS)N)rprqr)rmrrrr<sz$aiohttp_raw_server.<locals>.finalize)r )rrnrrr)rrmr�aiohttp_raw_server,s
rucCstjdtdd�|S)Nz2Deprecated, use aiohttp_raw_server fixture insteadrc)rd)r@rerf)rurrr�raw_test_serverCs
rv)rroc#sbg�dd�tttftttttfttd���fdd�}|Vdd��fdd�}��|��dS)	z�Factory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    N)�
server_kwargs)�__paramr(rwr)roc�s�t|t�r.t|ttf�s.|�f|�|�}i}n|r:td��t|t�rv|pJi}t|fd�i|��}t|fd�i|��}n0t|t�r�t|fd�i|��}ntdt|���|�	�IdH��
|�|S)Nzargs should be emptyrzUnknown argument type: %r)�
isinstancerrr
�AssertionErrorrrr\�typerjrk)rxrwr(r)rlZclient)�clientsrrrrn[s


zaiohttp_client.<locals>.go)roc�s x�r�����IdHqWdS)N)rprqr)r|rrrrysz aiohttp_client.<locals>.finalize)	rrr
rrr�strrr )rrnrrr)r|rr�aiohttp_clientOs
 r~cCstjdtdd�|S)Nz.Deprecated, use aiohttp_client fixture insteadrc)rd)r@rerf)r~rrr�test_client�s
r)F)5r.�
contextlibr@Zcollections.abcr�typingrrrrrrZpytestZaiohttp.helpersr	r
Zaiohttp.webrZ
test_utilsr
rrrrrrrrhrT�ImportErrorrUZ
AiohttpClientrr1Zfixturer4r5�contextmanagerrFrGrKrRr_rrLrgrsrtrurvZAbstractEventLoopr~rrrrr�<module>sN$(

9"

.