
    tnie2              
          d dl Z d dlZd dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZmZ d dlZddlmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZ 	 d dlZn# e $ r dZY nw xY w G d de          Z! G d	 d
e          Z" G d de          Z#d Z$d Z%ej&        d             Z'ej&        d             Z(ej)        d             Z*ej)        d'd            Z+d Z,d Z-d Z.ej&        deg e j/        f         de0de0de	e j/                 fd            Z1ej&        de	e j/                 fd            Z2ej&        deg e3f         deg e3f         fd            Zej&        deg e3f         fd            Z4ej&        d e j/        de	e"         fd!            Z5ej&        d"             Z6ej&        d e j/        de	e#         fd#            Z7ej&        d$             Z8ej&        d e j/        de	e!         fd%            Z9ej&        d&             Z:dS )(    N)	Any	AwaitableCallableDictIteratorOptionalProtocolUnionoverload   )BaseTestServerRawTestServer
TestClient
TestServerloop_contextsetup_test_loopteardown_test_loopunused_port)ApplicationBaseRequestRequest)_RequestHandlerc                       e Zd Zedddedeeeef                  dede	e
ef         fd            Zedddedeeeef                  dede	edf         fd            ZdS )	AiohttpClientNserver_kwargs_AiohttpClient__paramr   kwargsreturnc                
   K   d S N selfr   r   r   s       R/var/www/html/gpu-tools/venv/lib/python3.11/site-packages/aiohttp/pytest_plugin.py__call__zAiohttpClient.__call__'   s       ,/3    c                
   K   d S r!   r"   r#   s       r%   r&   zAiohttpClient.__call__/   s       ),r'   )__name__
__module____qualname__r   r   r   r   strr   r   r   r&   r   r   r"   r'   r%   r   r   &   s        
 37	/ / //  S#X/	/
 / 
G[(	)/ / / X/ 
 37	, , ,,  S#X/	,
 , 
K%	&, , , X, , ,r'   r   c            
       D    e Zd Zdddedee         dedee         fdZ	dS )AiohttpServerNportappr0   r   r   c                    d S r!   r"   )r$   r1   r0   r   s       r%   r&   zAiohttpServer.__call__:   s     #r'   )
r)   r*   r+   r   r   intr   r   r   r&   r"   r'   r%   r.   r.   9   s^        9=$ $ $$)1#$IL$	:	$ $ $ $ $ $r'   r.   c            
       D    e Zd Zdddedee         dedee         fdZ	dS )AiohttpRawServerNr/   handlerr0   r   r   c                    d S r!   r"   )r$   r6   r0   r   s       r%   r&   zAiohttpRawServer.__call__@   s    #&3r'   )
r)   r*   r+   r   r   r3   r   r   r   r&   r"   r'   r%   r5   r5   ?   s^        AE' ' '&'19#'QT'	=	!' ' ' ' ' 'r'   r5   c                     |                      dddd           |                      dddd	           |                      d
ddd           d S )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-debugzenable event loop debug mode)	addoption)parsers    r%   pytest_addoptionrC   E   s    
9	     B	     %+	      r'   c                     | j         t          j                  rdnt          j                  rdndS dd| j        vr| xj        dz  c_        dfd}|| _         dS )zjSet up pytest fixture.

    Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
    TFNrequestrE   c                  J   |d         }r|d= d|j         vrt          d          |                    d          rJ | i |fd}|                    |                                                                         S                      | i |          S )NrE   loopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.c                  v    	                                                                 S # t          $ r Y d S w xY wr!   )run_until_complete	__anext__StopAsyncIteration)_loopgens   r%   	finalizerz8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer   sF     33CMMOODDD)   DDs   &* 
88)fixturenames	ExceptiongetfixturevalueaddfinalizerrJ   rK   )	argsr   rE   rO   rM   rN   funcis_async_genstrip_requests	       @@r%   wrapperz%pytest_fixture_setup.<locals>.wrapperp   s    # 	"y!
 ---6  
 ''// 	C $'''C        +++++CMMOO<<<++DD$,A&,A,ABBBr'   )rU   inspectisasyncgenfunctioniscoroutinefunctionargnames)
fixturedefrX   rU   rV   rW   s     @@@r%   pytest_fixture_setupr^   Z   s    
 ?D!$'' 		$T	*	*  	M
+++|+C C C C C C C@ JOOOr'   c                 6    | j                             d          S )z--fast config optionr9   config	getoptionrF   s    r%   fastrc      s     >##$4555r'   c                 6    | j                             d          S )z!--enable-loop-debug config optionr@   r`   rF   s    r%   
loop_debugre      s     >##$ABBBr'   c            
   #   >  K   t          j        d          5 } dV  d | D             }|rYt          d                    t	          |          t	          |          dk    rdndd	                    |                              	 ddd           dS # 1 swxY w Y   dS )
zContext 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)recordNc                 Z    g | ](}|j         t          k    d                     |          )S )z#{w.filename}:{w.lineno}:{w.message})w)categoryRuntimeWarningformat).0ri   s     r%   
<listcomp>z,_runtime_warning_context.<locals>.<listcomp>   s@     
 
 
z^++ 28818==+++r'   z{} Runtime Warning{},
{}r    s
)warningscatch_warningsRuntimeErrorrl   lenjoin)	_warningsrws     r%   _runtime_warning_contextry      s      
	 	-	-	- 
 

 
 

  	+22GG3r77a<<RRS$))B--   	                 s   A,BBBFc              #   `   K   | r| V  dS t                      } | V  t          | |           dS )zPassthrough loop context.

    Sets up and tears down a loop unless one is passed in via the loop
    argument when it's passed straight through.
    rc   N)r   r   )rH   rc   s     r%   _passthrough_loop_contextr|      sL        ,




   


4d++++++r'   c                     |                      |          r7t          j        |          r%t          |                     ||                    S dS dS )z%Fix pytest collecting for coroutines.N)funcnamefilterrY   r[   list_genfunctions)	collectornameobjs      r%   pytest_pycollect_makeitemr      s\    %% 8'*Ec*J*J 8I++D#667778 8 8 8r'   c           	      R     j                             d          }t          j         j                  r j                            d          pN j                            d          p4 j                            d          p j                            dd          }t                      5  t          ||          5 } fd j	        j
        D             }|                      j        d
i |           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   d	S dS )zBRun coroutines in an event loop instead of a normal function call.r9   proactor_loopselector_loopuvloop_looprH   Nr{   c                 ,    i | ]}|j         |         S r"   )funcargs)rm   arg
pyfuncitems     r%   
<dictcomp>z&pytest_pyfunc_call.<locals>.<dictcomp>   s3        ,S1  r'   Tr"   )ra   rb   rY   r[   functionr   getry   r|   _fixtureinfor\   rJ   r   )r   rc   existing_looprM   testargss   `    r%   pytest_pyfunc_callr      s   &&'788D":#677 ##O44 5"&&775"&&}555 "&&vt44	 	 &'' 	E 	E*=tDDD E   )6?   (()C)C()C)CDDDE E E E E E E E E E E E E E E	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E 	E t! s6   ,D>9D7DD	D
D	DD!Dc           
      X   d| j         vrd S | j        j        j        }dt          j        i}t          t          j        |d<   |dk    rd}i }|                    d          D ]s}|                    d           }|	                    d          }||vr7|r4t          d	|d
t          |                                                    h||         ||<   t|                     dt          |                                          t          |                                                     d S )Nloop_factoryr?   uvloopallzpyloop,uvloop?,?z ?zUnknown loop 'z', available loops: )ids)rP   ra   optionaiohttp_loopasyncionew_event_loopr   splitendswithstrip
ValueErrorr   keysparametrizevalues)metafuncloopsavail_factories	factoriesr   requireds         r%   pytest_generate_testsr      sH   X222O"/E!78O$*$9!~~ IC   0 0}}S)))zz$&&  jttT).."2"23335  
 )$/	$Y--//00d9>>;K;K6L6L      r'   r   rc   re   r   c              #      K   t          | |          5 }|r|                    d           t          j        |           |V  ddd           dS # 1 swxY w Y   dS )z%Return an instance of the event loop.r{   TN)r   	set_debugr   set_event_loop)r   rc   re   rM   s       r%   rH   rH     s       
l	.	.	. % 	"OOD!!!u%%%	                 s   0AAAc               #      K   t           j        } t          |           5 }t          j        |           |V  d d d            d S # 1 swxY w Y   d S r!   )r   ProactorEventLoopr   r   )factoryrM   s     r%   r   r     s      'G	g		 %u%%%                 s   AAAaiohttp_unused_portc                 >    t          j        dt          d           | S )Nz3Deprecated, use aiohttp_unused_port fixture instead   
stacklevelrr   warnDeprecationWarning)r   s    r%   r   r     s,    M=   
 r'   c                      t           S )z1Return a port that is unused on the current host.)_unused_portr"   r'   r%   r   r   %  s
     r'   rH   c              #       K   g ddddt           dt          dt          t                   dt          dt
          f
 fd	}|V  dfd
}                      |                       dS )z^Factory to create a TestServer instance, given an app.

    aiohttp_server(app, **kwargs)
    z	127.0.0.1Nhostr0   r1   r   r0   r   r   c                   K   t          | ||          } |j        ddi| d {V                      |           |S )Nr   rH   r"   )r   start_serverappend)r1   r   r0   r   serverrH   serverss        r%   gozaiohttp_server.<locals>.go3  sd       Cd666!f!66t6v666666666vr'   c                  p   K    r0                                                                   d {V   .d S d S r!   popcloser   s   r%   finalizez aiohttp_server.<locals>.finalizeA  Y       	(++--%%'''''''''  	( 	( 	( 	( 	(r'   r   N)r   r,   r   r3   r   r   rJ   rH   r   r   r   s   `  @r%   aiohttp_serverr   +  s       G
  "	
 
 

 
 sm	

 
 

 
 
 
 
 
 
 HHH( ( ( ( ( ( 	HHJJ'''''r'   c                 >    t          j        dt          d           | S )Nz.Deprecated, use aiohttp_server fixture insteadr   r   r   )r   s    r%   test_serverr   H  ,    M8   
 r'   c           	   #       K   g dddt           dt          t                   dt          dt          f fd}|V  d	fd}                      |                       dS )
zpFactory to create a RawTestServer instance, given a web handler.

    aiohttp_raw_server(handler, **kwargs)
    Nr/   r6   r0   r   r   c                   K   t          | |          } |j        ddi| d {V                      |           |S )Nr/   rH   r"   )r   r   r   )r6   r0   r   r   rH   r   s       r%   r   zaiohttp_raw_server.<locals>.goZ  sb       wT222!f!66t6v666666666vr'   c                  p   K    r0                                                                   d {V   .d S d S r!   r   r   s   r%   r   z$aiohttp_raw_server.<locals>.finalized  r   r'   r   )r   r   r3   r   r   rJ   r   s   `  @r%   aiohttp_raw_serverr   R  s       G <@   +3C=KN	       HHH( ( ( ( ( ( 	HHJJ'''''r'   c                 >    t          j        dt          d           | S )Nz2Deprecated, use aiohttp_raw_server fixture insteadr   r   r   )r   s    r%   raw_test_serverr   k  s.     M<   
 r'   c              #      K   g t           dddt          dt          t          t          t
          f                  dt
          dt          t          t          f         fd            }t           dddt          dt          t          t          t
          f                  dt
          dt          t          df         fd            }dddt          t          t          f         d	t
          dt          t          t          t
          f                  dt
          dt          t
          t
          f         f
 fd
}|V  dfd}                      |                       dS )zFactory to create a TestClient instance.

    aiohttp_client(app, **kwargs)
    aiohttp_client(server, **kwargs)
    aiohttp_client(raw_server, **kwargs)
    Nr   __paramr   r   r   c                
   K   d S r!   r"   r   r   r   s      r%   r   zaiohttp_client.<locals>.go  s       ,/3r'   c                
   K   d S r!   r"   r   s      r%   r   zaiohttp_client.<locals>.go  s       ),r'   rT   c                  K   t          | t                    r+t          | t          t          f          s | g|R i |} i }n|r
J d            t          | t                    r#|pi }t	          | fdi|}t          |fdi|}nDt          | t                    rt          | fdi|}nt          dt          |           z            |                                 d {V  	                    |           |S )Nzargs should be emptyrH   zUnknown argument type: %r)

isinstancer   r   r   r   r   r   typer   r   )r   r   rT   r   r   clientclientsrH   s         r%   r   zaiohttp_client.<locals>.go  sJ      gx(( 	4k>22
 2
 	4 gd4T444V44GFF333333g{++ 	J)/RMDDdDmDDF<<T<V<<FF00 	J==d=f==FF84==HIII!!#########vr'   c                  p   K    r0                                                                   d {V   .d S d S r!   r   )r   s   r%   r   z aiohttp_client.<locals>.finalize  r   r'   r   )r   r   r   r   r,   r   r   r   r   r   r
   rJ   )rH   r   r   r   s   `  @r%   aiohttp_clientr   w  s      G 37/ / //  S#X// 	/
 
G[(	)/ / / X/  37, , ,,  S#X/, 	,
 
K%	&, , , X, 37  {N23  S#X/ 	
 
CH	      6 HHH( ( ( ( ( ( 	HHJJ'''''r'   c                 >    t          j        dt          d           | S )Nz.Deprecated, use aiohttp_client fixture insteadr   r   r   )r   s    r%   test_clientr     r   r'   )F);r   
contextlibrY   rr   typingr   r   r   r   r   r   r	   r
   r   pytest
test_utilsr   r   r   r   r   r   r   r   r   webr   r   r   web_protocolr   r   ImportErrorr   r.   r5   rC   r^   fixturerc   re   contextmanagerry   r|   r   r   r   AbstractEventLoopboolrH   r   r3   r   r   r   r   r   r   r   r"   r'   r%   <module>r      s         
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 3 2 2 2 2 2 2 2 2 2 ) ) ) ) ) )MMMM   FFF, , , , ,H , , ,&$ $ $ $ $H $ $ $' ' ' ' 'x ' ' '  *6 6 6r 6 6 6
 C C C
   . , , , , 8 8 8  ,  @ 
2w889


 
 g'(	
 
 
 
 x 9:     Xb#g%6 8BG;L     Xb#g.    
 (2 (x7N ( ( ( (8    (W6 (8DT;U ( ( ( (0    :(2 :(x7N :( :( :( :(z     s   A AA