
    bCiU-                        S SK r S SKrS SKrS SKJrJrJrJrJrJ	r	J
r
Jr  S SKrS SKJr  S SKJr  SSKJrJrJrJrJrJrJrJr   S SKr\\\\4   /\\   4   r\\/\\   4   r\\/\\   4   rS r S r!\RD                  S	 5       r#\RD                  S
 5       r$\RJ                  S 5       r&\RJ                  SS j5       r'S r(S r)S r*\RD                  S 5       r+\RD                  S 5       r,\RD                  S\/ \-4   S\/ \-4   4S j5       r\RD                  S\/ \-4   4S j5       r.\RD                  S\ R^                  S\\   4S j5       r0\RD                  S 5       r1\RD                  S\ R^                  S\\   4S j5       r2\RD                  S 5       r3\RD                  S\ R^                  S\\   4S j5       r4\RD                  S 5       r5g! \ a    Sr GNf = f)    N)Any	AwaitableCallableDictIteratorOptionalTypeUnion)isasyncgenfunction)Application   )BaseTestServerRawTestServer
TestClient
TestServerloop_contextsetup_test_loopteardown_test_loopunused_portc                 p    U R                  SSSSS9  U R                  SSSS	S9  U R                  S
SSSS9  g )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    O/home/james-whalen/.local/lib/python3.13/site-packages/aiohttp/pytest_plugin.pypytest_addoptionr"       sc    
9	   B	   %+	      c                    ^^^ U R                   m[        T5      (       a  SmO[        R                  " T5      (       a  SmOgSmSU R                  ;  a  U =R                  S-  sl        SmUUU4S jnXl         g)zbSet up pytest fixture.

Allow fixtures to be coroutines. Run coroutine fixtures in an event loop.
TFNrequestr%   c                  8  >^^ US   nT(       a  US	 SUR                   ;  a  [        S5      eUR                  S5      mT(       a?  T" U 0 UD6mUU4S jnUR                  U5        TR	                  TR                  5       5      $ TR	                  T" U 0 UD65      $ )Nr%   loopz^Asynchronous fixtures must depend on the 'loop' fixture or be used in tests depending from it.c                  d   >  T R                  TR                  5       5      $ ! [         a     g f = fN)run_until_complete	__anext__StopAsyncIteration)_loopgens   r!   	finalizer8pytest_fixture_setup.<locals>.wrapper.<locals>.finalizer`   s1     33CMMODD) s   " 
//)fixturenames	Exceptiongetfixturevalueaddfinalizerr+   r,   )	argskwargsr%   r0   r.   r/   funcis_async_genstrip_requests	       @@r!   wrapper%pytest_fixture_setup.<locals>.wrapperK   s    #y!
 ---6 
 ''/ ''C   +++CMMO<<++D$,A&,ABBr#   )r8   r   asyncioiscoroutinefunctionargnames)
fixturedefr;   r8   r9   r:   s     @@@r!   pytest_fixture_setuprA   5   sp    
 ??D$		$	$T	*	* 	M
+++|+C@ Or#   c                 8    U R                   R                  S5      $ )z--fast config optionr   config	getoptionr&   s    r!   fastrF   n   s     >>##$455r#   c                 8    U R                   R                  S5      $ )z!--enable-loop-debug config optionr   rC   r&   s    r!   
loop_debugrH   t   s     >>##$ABBr#   c            
   #   ~  #    [         R                  " SS9 n Sv   U  Vs/ s H(  nUR                  [        :X  d  M  SR	                  US9PM*     nnU(       aE  [        SR	                  [        U5      [        U5      S:X  a  SOS	S
R                  U5      5      5      e SSS5        gs  snf ! , (       d  f       g= f7f)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)recordNz#{w.filename}:{w.lineno}:{w.message})wz{} Runtime Warning{},
{}r    s
)warningscatch_warningscategoryRuntimeWarningformatRuntimeErrorlenjoin)	_warningsrK   rws      r!   _runtime_warning_contextrY   z   s      
	 	 	- 
zz^+ >18818= 	 

 +22G3r7a<RS$))B-   
.	-
 
.	-s3   B=	B,B'B'AB,	B='B,,
B:6B=c              #   R   #    U (       a  U v   g[        5       n U v   [        XS9  g7f)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.
rF   N)r   r   )r(   rF   s     r!   _passthrough_loop_contextr\      s&      
  
4+s   %'c                     U R                  U5      (       a6  [        R                  " U5      (       a  [        U R	                  X5      5      $ gg)z%Fix pytest collecting for coroutines.N)funcnamefilterr=   r>   list_genfunctions)	collectornameobjs      r!   pytest_pycollect_makeitemrd      sB    %%'*E*Ec*J*JI++D677 +K%r#   c           	      B   U R                   R                  S5      n[        R                  " U R                  5      (       a  U R
                  R                  S5      =(       d    U R
                  R                  SS5      n[        5          [        X!S9 nU R                  R                   Vs0 s H  nX@R
                  U   _M     nnUR                  U R                  " S0 UD65        SSS5        SSS5        ggs  snf ! , (       d  f       N= f! , (       d  f       g= f)zBRun coroutines in an event loop instead of a normal function call.r   proactor_loopr(   Nr[   T )rD   rE   r=   r>   functionfuncargsgetrY   r\   _fixtureinfor?   r+   rc   )
pyfuncitemrF   existing_loopr.   argtestargss         r!   pytest_pyfunc_callrp      s   &&'78D"":#6#677"++//
 3  $$VT2 	 &'*=D  *66??? ,,S11?   (()C()CD E (  8 ED (' s6   	
DC?,C:#C?(D:C??
D		D
Dc           
      J   SU R                   ;  a  g U R                  R                  R                  nS[        R
                  0n[        b  [        R                  US'   US:X  a  Sn0 nUR                  S5       Hh  nUR                  S5      (       + nUR                  S5      nXB;  a3  U(       a*  [        S	U< S
[        UR                  5       5      < 35      eMb  X$   X4'   Mj     U R                  S[        UR                  5       5      [        UR                  5       5      S9  g )Nloop_factoryr   uvloopallzpyloop,uvloop?,?z ?zUnknown loop 'z', available loops: )ids)r2   rD   optionaiohttp_loopr=   DefaultEventLoopPolicyrs   EventLoopPolicysplitendswithstrip
ValueErrorr_   keysparametrizevalues)metafuncloopsavail_factories	factoriesrb   requireds         r!   pytest_generate_testsr      s   X222OO""//E!?!?@O$*$:$:!~ IC }}S))zz$& T).."235 
 )/	 ! Y--/0d9>>;K6L  r#   c              #      #    U " 5       n[         R                  " U5        [        US9 nU(       a  UR                  S5        [         R                  " U5        Uv   SSS5        g! , (       d  f       g= f7f)z%Return an instance of the event loop.r[   TN)r=   set_event_loop_policyr   	set_debugset_event_loop)rr   rF   rH   policyr.   s        r!   r(   r(      sS      ^F!!&)	4	 EOOD!u%	 
!	 	 s   'A63A%	A6%
A3/A6c               #      #    [         R                  " 5       n [         R                  " U 5        [        U R                  5       n[         R
                  " U5        Uv   S S S 5        g ! , (       d  f       g = f7fr*   )r=   WindowsProactorEventLoopPolicyr   r   new_event_loopr   )r   r.   s     r!   rf   rf      sO     335F!!&)	f++	,u% 
-	,	,s   AA8A'	A8'
A51A8aiohttp_unused_portreturnc                 :    [         R                  " S[        SS9  U $ )Nz3Deprecated, use aiohttp_unused_port fixture instead   
stacklevelrO   warnDeprecationWarning)r   s    r!   r   r      s    MM=
 r#   c                      [         $ )z1Return a port that is unused on the current host.)_unused_portrg   r#   r!   r   r      s
     r#   r(   c              #   n   ^ ^#    / mSS.U U4S jjnUv   SU4S jjnT R                  U" 5       5        g7f)zVFactory to create a TestServer instance, given an app.

aiohttp_server(app, **kwargs)
Nportc                   >#    [        XS9nUR                  " SST0UD6I S h  vN   TR                  U5        U$  N7fNr   r(   rg   )r   start_serverappend)appr   r7   serverr(   serverss       r!   goaiohttp_server.<locals>.go	  sB     C+!!6t6v666v 	7   !><>c                     >#    T (       a0  T R                  5       R                  5       I S h  vN   T (       a  M/  g g  N7fr*   popcloser   s   r!   finalize aiohttp_server.<locals>.finalize  +     ++-%%''' g'   )><>>r   Nr+   r(   r   r   r   s   `  @r!   aiohttp_serverr     s8      G"   H( 	HJ'   15c                 :    [         R                  " S[        SS9  U $ )Nz.Deprecated, use aiohttp_server fixture insteadr   r   r   )r   s    r!   test_serverr         MM8
 r#   c              #   n   ^ ^#    / mSS.U U4S jjnUv   SU4S jjnT R                  U" 5       5        g7f)zhFactory to create a RawTestServer instance, given a web handler.

aiohttp_raw_server(handler, **kwargs)
Nr   c                   >#    [        XS9nUR                  " SST0UD6I S h  vN   TR                  U5        U$  N7fr   )r   r   r   )handlerr   r7   r   r(   r   s       r!   r   aiohttp_raw_server.<locals>.go*  sB     w2!!6t6v666v 	7r   c                     >#    T (       a0  T R                  5       R                  5       I S h  vN   T (       a  M/  g g  N7fr*   r   r   s   r!   r   $aiohttp_raw_server.<locals>.finalize2  r   r   r   r   r   s   `  @r!   aiohttp_raw_serverr   "  s8      G"&   H( 	HJ'r   c                 :    [         R                  " S[        SS9  U $ )Nz2Deprecated, use aiohttp_raw_server fixture insteadr   r   r   )r   s    r!   raw_test_serverr   9  s!     MM<
 r#   c              #      ^ ^#    / mSS.S[         [        [        4   S[        S[        [
        [        [        4      S[        S[        4
UU 4S jjjnUv   S
U4S	 jjnT R                  U" 5       5        g7f)zFactory to create a TestClient instance.

aiohttp_client(app, **kwargs)
aiohttp_client(server, **kwargs)
aiohttp_client(raw_server, **kwargs)
N)server_kwargs__paramr6   r   r7   r   c                  >#    [        U [        5      (       a*  [        U [        [        45      (       d  U " T/UQ70 UD6n 0 nOU(       a   S5       e[        U [        5      (       a(  U=(       d    0 n[	        U 4ST0UD6n[        U4ST0UD6nO;[        U [        5      (       a  [        U 4ST0UD6nO[        S[        U 5      -  5      eUR                  5       I S h  vN   TR                  U5        U$  N7f)Nzargs should be emptyr(   zUnknown argument type: %r)

isinstancer   r   r   r   r   r   typer   r   )r   r   r6   r7   r   clientclientsr(   s         r!   r   aiohttp_client.<locals>.goQ  s      gx((k>22
 2
 d4T4V4GF3338g{++)/RMDdDmDF<T<V<F00=d=f=F84=HII!!###v 	$s   CC6C4C6c                     >#    T (       a0  T R                  5       R                  5       I S h  vN   T (       a  M/  g g  N7fr*   r   )r   s   r!   r    aiohttp_client.<locals>.finalizeo  r   r   r   )	r
   r   r   r   r   r   strr   r+   )r(   r   r   r   s   `  @r!   aiohttp_clientr   E  s      G
 37{N23  S#X/ 	
 
 8 H( 	HJ's   A2A6c                 :    [         R                  " S[        SS9  U $ )Nz.Deprecated, use aiohttp_client fixture insteadr   r   r   )r   s    r!   test_clientr   v  r   r#   )F)6r=   
contextlibrO   typingr   r   r   r   r   r   r	   r
   pytestaiohttp.helpersr   aiohttp.webr   
test_utilsr   r   r   r   r   r   r   r   r   rs   ImportErrorAiohttpClientAiohttpRawServerAiohttpServerr"   rA   fixturerF   rH   contextmanagerrY   r\   rd   rp   r   r(   rf   intr   AbstractEventLoopr   r   r   r   r   r   rg   r#   r!   <module>r      s      R R R  . #	 	 	 %^ ;<=y?TTU[M9]+CCD +	*(==>*6r 6 6
 C C
  . , , 8$@     Xb#g%6 8BG;L   Xb#g.  
 (22 (x7N ( (,   (W66 (8DT;U ( (,   -(

#
#-(m-( -(`  
  Fs   G GG