HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/aiohttp/__pycache__/pytest_plugin.cpython-310.pyc
o

���g�1�@s>ddlZddlZddlZddlZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
mZddlZddlmZmZmZmZmZmZmZmZddlmZmZmZddlmZzddl Z Wne!yadZ YnwGdd�de�Z"Gd	d
�d
e�Z#Gdd�de�Z$d
d�Z%dd�Z&ej'dd��Z(ej'dd��Z)ej*dd��Z+ej*d5dd��Z,dd�Z-dd�Z.dd�Z/ej'd d!��Z0ej'd"d#��Z1ej'd$ege2fd%ege2ffd&d'��Zej'd%ege2ffd(d$��Z3ej'd!ej4d%e	e#fd)d*��Z5ej'd+d,��Z6ej'd!ej4d%e	e$fd-d.��Z7ej'd/d0��Z8ej'd!ej4d%e	e"fd1d2��Z9ej'd3d4��Z:dS)6�N)
�Any�	Awaitable�Callable�Dict�Iterator�Optional�Protocol�Type�Union�overload�)�BaseTestServer�
RawTestServer�
TestClient�
TestServer�loop_context�setup_test_loop�teardown_test_loop�unused_port)�Application�BaseRequest�Request)�_RequestHandlerc@s|eZdZedd�dedeeeefdede	e
effdd��Zedd�dedeeeefdede	e
dffd	d��ZdS)
�
AiohttpClientN��
server_kwargs�_AiohttpClient__paramr�kwargs�returnc���dS�N���selfrrrr!r!�@/usr/local/lib/python3.10/dist-packages/aiohttp/pytest_plugin.py�__call__(��zAiohttpClient.__call__c�rr r!r"r!r!r$r%0r&)�__name__�
__module__�__qualname__rrrr�strrrrr%r
rr!r!r!r$r's.����
�����
�rc
@�4eZdZdd�dedeededeefdd�Z	dS)	�
AiohttpServerN��port�appr.rrcK�dSr r!)r#r/r.rr!r!r$r%;�zAiohttpServer.__call__)
r'r(r)rr�intrrrr%r!r!r!r$r,:������r,c
@r+)	�AiohttpRawServerNr-�handlerr.rrcKr0r r!)r#r5r.rr!r!r$r%Ar1zAiohttpRawServer.__call__)
r'r(r)rrr2rrrr%r!r!r!r$r4@r3r4cCs:|jddddd�|jdddd	d�|jd
dddd�dS)N�--aiohttp-fast�
store_trueFz*run tests faster by disabling extra checks)�action�default�helpz--aiohttp-loop�store�pyloopz3run tests with specific loop: pyloop, uvloop or all�--aiohttp-enable-loop-debugzenable event loop debug mode)�	addoption)�parserr!r!r$�pytest_addoptionFs$��
�r@csd|j�t���rd�n
t���rd�ndSd�d|jvr%|jd7_d����fdd�}||_dS)zjSet up pytest fixture.

    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFN�request�rAcsz|d}�r	|d=d|jvrtd��|�d���r3�|i|�����fdd�}|�|�������S���|i|���S)NrA�loopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.cs&z������WStyYdSwr )�run_until_complete�	__anext__�StopAsyncIterationr!��_loop�genr!r$�	finalizer�s
�z8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer)�fixturenames�	Exception�getfixturevalue�addfinalizerrDrE)�argsrrArJ��func�is_async_gen�
strip_requestrGr$�wrapperqs
�

z%pytest_fixture_setup.<locals>.wrapper)rQ�inspect�isasyncgenfunction�asyncio�iscoroutinefunction�argnames)�
fixturedefrTr!rPr$�pytest_fixture_setup[s



 r[cC�|j�d�S)z--fast config optionr6��config�	getoptionrBr!r!r$�fast��r`cCr\)z!--enable-loop-debug config optionr=r]rBr!r!r$�
loop_debug�rarbc	csx�tjdd��+}dVdd�|D�}|r*td�t|�t|�dkr"dnd	d
�|����Wd�dS1s5wYdS)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)�.0rdr!r!r$�
<listcomp>�s


�z,_runtime_warning_context.<locals>.<listcomp>z{} Runtime Warning{},
{}r��s�
)�warnings�catch_warnings�RuntimeErrorrg�len�join)�	_warnings�rwr!r!r$�_runtime_warning_context�s�	� ���"�rtFccs,�|r|VdSt�}|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.
    �r`N)rr)rCr`r!r!r$�_passthrough_loop_context�s�
rvcCs,|�|�rt�|�rt|�||��SdSdS)z%Fix pytest collecting for coroutines.N)�funcnamefilterrWrX�list�
_genfunctions)�	collector�name�objr!r!r$�pytest_pycollect_makeitem�s�r}c	s��j�d�}t��j�rc�j�d�p�j�dd�}t��=t||d��}�fdd��j	j
D�}|��jd	i|���Wd�n1sDwYWd�dSWd�dS1s\wYdSdS)
zBRun coroutines in an event loop instead of a normal function call.r6�
proactor_looprCNrucsi|]}|�j|�qSr!)�funcargs)rh�arg��
pyfuncitemr!r$�
<dictcomp>�s
��z&pytest_pyfunc_call.<locals>.<dictcomp>Tr!)
r^r_rWrX�functionr�getrtrv�_fixtureinforYrDr|)r�r`�
existing_looprH�testargsr!r�r$�pytest_pyfunc_call�s,��
��
��
���r�cCs�d|jvrdS|jjj}dtji}tdurtj|d<|dkr d}i}|�d�D]&}|�	d�}|�
d�}||vrG|rFtd	|t|�
��f��q'||||<q'|jdt|���t|�
��d
�dS)N�loop_factoryr<�uvloop�allzpyloop,uvloop?�,�?z ?z&Unknown loop '%s', available loops: %s)�ids)rKr^�option�aiohttp_looprW�DefaultEventLoopPolicyr��EventLoopPolicy�split�endswith�strip�
ValueErrorrx�keys�parametrize�values)�metafunc�loops�avail_factories�	factoriesr{�requiredr!r!r$�pytest_generate_tests�s0




��
�r�ccs`�|�}t�|�t|d��}|r|�d�t�|�|VWd�dS1s)wYdS)z%Return an instance of the event loop.ruTN)rW�set_event_loop_policyr�	set_debug�set_event_loop)r�r`rb�policyrHr!r!r$rCs�


"�rCccsT�t��}t�|�t|j��}t�|�|VWd�dS1s#wYdSr )rW�WindowsProactorEventLoopPolicyr�r�new_event_loopr�)r�rHr!r!r$r~
s�

"�r~�aiohttp_unused_portrcC�tjdtdd�|S)Nz3Deprecated, use aiohttp_unused_port fixture instead���
stacklevel�rm�warn�DeprecationWarning)r�r!r!r$r��rcCstS)z1Return a port that is unused on the current host.)�_unused_portr!r!r!r$r�!sc	#�T�g�dd�dtdttdtdtf��fdd�}|Vd�fd	d
�}��|��dS)z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    Nr-r/r.rrc��6�t||d�}|jdd�i|��IdH��|�|S�Nr-rCr!)r�start_server�append)r/r.r�server�rC�serversr!r$�go/�
�
zaiohttp_server.<locals>.goc��$��r�����IdH�sdSdSr ��pop�closer!�r�r!r$�finalize9���z aiohttp_server.<locals>.finalize�rN)rrr2rrrD�rCr�r�r!r�r$�aiohttp_server'�������r�cCr�)Nz.Deprecated, use aiohttp_server fixture insteadr�r�r�)r�r!r!r$�test_server@r�r�c	#r�)zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    Nr-r5r.rrc�r�r�)rr�r�)r5r.rr�r�r!r$r�Rr�zaiohttp_raw_server.<locals>.goc�r�r r�r!r�r!r$r�\r�z$aiohttp_raw_server.<locals>.finalizer�)rrr2rrrDr�r!r�r$�aiohttp_raw_serverJr�r�cCr�)Nz2Deprecated, use aiohttp_raw_server fixture insteadr�r�r�)r�r!r!r$�raw_test_servercs�r�c
#s��g�tdd�dtdttttfdtdtttffdd��}tdd�dtdttttfdtdtt	dffd	d��}dd�dt
ttfd
tdttttfdtdtttff
��fdd�}|Vd�fdd
�}��|��dS)z�Factory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    Nr�__paramrrrc�rr r!�r�rrr!r!r$r�y��zaiohttp_client.<locals>.goc�rr r!r�r!r!r$r��r�rOc�s��t|t�rt|ttf�s|�g|�Ri|��}i}n|r!Jd��t|t�r?|p)i}t|fd�i|��}t|fd�i|��}nt|t�rOt|fd�i|��}ntdt|���|��IdH��	|�|S)Nzargs should be emptyrCzUnknown argument type: %r)
�
isinstancerrr
rrr��typer�r�)r�rrOrr��client��clientsrCr!r$r��s"��


c�r�r r�r!)r�r!r$r��r�z aiohttp_client.<locals>.finalizer�)rrrrr*rrrr
rr
rDr�r!r�r$�aiohttp_clientosN�����
�����
�
�
����
�r�cCr�)Nz.Deprecated, use aiohttp_client fixture insteadr�r�r�)r�r!r!r$�test_client�r�r�)F);rW�
contextlibrUrm�typingrrrrrrrr	r
r�pytest�
test_utilsr
rrrrrrrr��webrrr�web_protocolrr��ImportErrorrr,r4r@r[�fixturer`rb�contextmanagerrtrvr}r�r�rCr~r2r��AbstractEventLoopr�r�r�r�r�r�r!r!r!r$�<module>sd0
(
�9


 

	$	
	
=