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/python35/lib64/python3.5/site-packages/aiohttp/__pycache__/pytest_plugin.cpython-35.pyc


���Z-&�@sJddlZddlZddlZddlZddlZddlmZddlmZddl	m
Z
mZmZm
Z
mZmZmZddl	mZyddlZWnek
r�dZYnXyddlZWnek
r�dZYnXdd�Zd	d
�Zejdd��Zejd
d��Zejdd��Zejddd��Zdd�Zdd�Zdd�Z ejdd��Z!ejdd��Zejdd��Z"ejd d!��Z#ejd"d#��Z$ejd$d%��Z%ejd&d'��Z&ejd(d)��Z'ejd*d+��Z(dS),�N)�isasyncgenfunction)�Application�)�BaseTestServer�
RawTestServer�
TestClient�
TestServer�loop_context�setup_test_loop�teardown_test_loop)�unused_portcCsa|jddddddd�|jddd	dd
dd�|jddddddd
�dS)Nz--aiohttp-fast�action�
store_true�defaultF�helpz*run tests faster by disabling extra checksz--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�/pytest_plugin.py�pytest_addoptionsrcs�|j�t��rd�ntj��r6d�ndSd�d|jkrd|jd7_d����fdd�}||_dS)zS
    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFN�requestcs�|d}�r|d=d|jkr2td��|jd���r��||����fdd�}|j|��j�j��S�j�||��SdS)Nr�loopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.cs0y�j�j��SWntk
r+YnXdS)N)�run_until_complete�	__anext__�StopAsyncIterationr)�_loop�genrr�	finalizerQs
z8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer)�fixturenames�	ExceptionZgetfixturevalueZaddfinalizerrr)�args�kwargsrr)�func�is_async_gen�
strip_request)rrr�wrapper<s
	
z%pytest_fixture_setup.<locals>.wrapper)r)r"r�asyncio�iscoroutinefunction�argnames)Z
fixturedefr%r)r"r#r$r�pytest_fixture_setup's			 r)cCs|jjd�S)z--fast config optionz--aiohttp-fast)�config�	getoption)rrrr�fast_sr,cCs|jjd�S)z!--enable-loop-debug config optionz--aiohttp-enable-loop-debug)r*r+)rrrr�
loop_debugesr-c
cs�tjdd��g}dVdd�|D�}|rutdjt|�t|�dkr]dnd	d
j|����WdQRXdS)z�
    Context manager which checks for RuntimeWarnings, specifically to
    avoid "coroutine 'X' was never awaited" warnings being missed.

    If RuntimeWarnings occur in the context a RuntimeError is raised.
    �recordTNcSs1g|]'}|jtkrdjd|��qS)z#{w.filename}:{w.lineno}:{w.message}�w)�category�RuntimeWarning�format)�.0r/rrr�
<listcomp>us	z,_runtime_warning_context.<locals>.<listcomp>z{} Runtime Warning{},
{}r��s�
)�warnings�catch_warnings�RuntimeErrorr2�len�join)�	_warnings�rwrrr�_runtime_warning_contextks	
		r?Fccs0|r|Vnt�}|Vt|d|�dS)z{
    setups and tears down a loop unless one is passed in via the loop
    argument when it's passed straight through.
    r,N)r
r)rr,rrr�_passthrough_loop_contexts
	r@cCs8|j|�r4tj|�r4t|j||��SdS)z/
    Fix pytest collecting for coroutines.
    N)Zfuncnamefilterr&r'�listZ
_genfunctions)Z	collector�name�objrrr�pytest_pycollect_makeitem�srDcs��jjd�}tj�j�r��jjdd�}t��Vt|d|��<}�fdd��j	j
D�}|j�j|��WdQRXWdQRXdSdS)zL
    Run coroutines in an event loop instead of a normal function call.
    z--aiohttp-fastrNr,cs i|]}�j||�qSr)�funcargs)r3�arg)�
pyfuncitemrr�
<dictcomp>�s	z&pytest_pyfunc_call.<locals>.<dictcomp>T)
r*r+r&r'�functionrE�getr?r@Z_fixtureinfor(rrC)rGr,Z
existing_looprZtestargsr)rGr�pytest_pyfunc_call�s
$rKcCs.d|jkrdS|jjj}dtji}tdk	rJtj|d<tdk	rctj|d<|dkrud}i}x~|jd�D]m}|j	d�}|j
d	�}||kr�|r�td
|t|j
��f��nq�||||<q�W|jdt|j��dt|j
���dS)N�loop_factoryr�uvloop�tokio�allzpyloop,uvloop?,tokio?�,�?z ?z&Unknown loop '%s', available loops: %sZids)rr*ZoptionZaiohttp_loopr&Znew_event_looprMrN�split�endswith�strip�
ValueErrorrA�keysZparametrize�values)ZmetafuncZloopsZavail_factoriesZ	factoriesrBZrequiredrrr�pytest_generate_tests�s0

	rXc	csEt|d|��}|r(|jd�|VWdQRXtjd�dS)z%Return an instance of the event loop.r,TN)r	Z	set_debugr&Zset_event_loop)rLr,r-rrrrr�s

rcCstjdt�|S)Nz3Deprecated, use aiohttp_unused_port fixture instead)r8�warn�DeprecationWarning)�aiohttp_unused_portrrrr�s	rcCstS)z1Return a port that is unused on the current host.)�_unused_portrrrrr[�sr[c#sLg�dd��fdd�}|V�fdd�}�j|��dS)z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    �portNc�s;t|d|�}|jd�|�IdH�j|�|S)Nr]r)r�start_server�append)Zappr]r!�server)r�serversrr�go�s
zaiohttp_server.<locals>.goc�s&x�r!�j�j�IdHqWdS)N)�pop�closer)rarr�finalize�s	z aiohttp_server.<locals>.finalize)r)rrbrer)rrar�aiohttp_server�s
rfcCstjdt�|S)Nz.Deprecated, use aiohttp_server fixture instead)r8rYrZ)rfrrr�test_server�s	rgc#sLg�dd��fdd�}|V�fdd�}�j|��dS)zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    r]Nc�s;t|d|�}|jd�|�IdH�j|�|S)Nr]r)rr^r_)�handlerr]r!r`)rrarrrbs
zaiohttp_raw_server.<locals>.goc�s&x�r!�j�j�IdHqWdS)N)rcrdr)rarrre
s	z$aiohttp_raw_server.<locals>.finalize)r)rrbrer)rrar�aiohttp_raw_server�s
ricCstjdt�|S)Nz2Deprecated, use aiohttp_raw_server fixture instead)r8rYrZ)rirrr�raw_test_servers	rjc#sLg�dd��fdd�}|V�fdd�}�j|��dS)z�Factory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    �
server_kwargsNc�s�t|tj�rCt|ttf�rC|�||�}i}n|sVtd��t|t�r�|pni}t|d�|�}t|d�|�}n=t|t�r�t|d�|�}ntdt	|���|j
�IdH�j|�|S)Nzargs should be emptyrzUnknown argument type: %r)�
isinstance�collections�Callablerr�AssertionErrorrrrU�typer^r_)Z__paramrkr r!r`�client)�clientsrrrrb%s	
zaiohttp_client.<locals>.goc�s&x�r!�j�j�IdHqWdS)N)rcrdr)rrrrre=s	z aiohttp_client.<locals>.finalize)r)rrbrer)rrrr�aiohttp_clients
rscCstjdt�|S)Nz.Deprecated, use aiohttp_client fixture instead)r8rYrZ)rsrrr�test_clientDs	rt))r&rm�
contextlibr8ZpytestZaiohttp.helpersrZaiohttp.webrZ
test_utilsrrrrr	r
rrr\rM�ImportErrorrNrr)Zfixturer,r-�contextmanagerr?r@rDrKrXrr[rfrgrirjrsrtrrrr�<module>sF4

8!
)