+
    TŎiY                        R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
HtHt ^ RIHt ^ RIHtHtHtHtHtHtHtHtHtHtHt ^ RIHtHt ^ RIHt ^ RI H!t!H"t" ^ RI#H$t$ ^ RI%t%^ R	I&H't'H(t(H)t) ^R
I*H+t+H,t, ^RI
H-t- ^RI.H/t/ ^RI0H1t1 ^RI2H3t3 ^RI4H5t5H6t6 ^RI7H8t8H9t9 ^RI:H;t; ^RI<H=t=H>t>H?t?H@t@HAtAHBtBHCtCHDtDHEtE ^RIFHGtG ]'       d   ^ RIHHItI MRtI]P                  RI8  d   ]'       d   ^ RIHKtK ]P                  RI8  d   ^ RIHLtL M]tL]! R]=R4      tM]! R]?R7      tN]P                  R8H  ;'       d    ]P                  R8g  tQ]P                  3R R lltSR R ltTR  R! ltU ! R" R#]4      tV ! R$ R%]V4      tW ! R& R']V4      tX ! R( R)]]N]M3,          4      tY ! R* R+]4      tZR, R- lt[]. ]P                  3,          t]]P                  ]P                  R.3R/ R0 ll4       t`]P                  3R1 R2 lltaRJR3 R4 lltbR5 R6 ltcRKR7 R8 lltdRKR9]3R:]5! ^^4      R;R.R<RR=]3R>]3R?]3R@]8RARRBRLRCRD/RE RF lllte]3]33RG RH lltfR# )MzUtilities shared by tests.N)ABCabstractmethod)TracebackType)TYPE_CHECKINGAnyCallableGenericIteratorListOptionalTypeTypeVarcastoverload)IsolatedAsyncioTestCasemock)Signal)CIMultiDictCIMultiDictProxy)URL)_RequestContextManager_RequestOptions_WSRequestContextManager)ClientSessionhdrs)AbstractCookieJar)ClientResponse)ClientWebSocketResponse)sentinel)HttpVersionRawRequestMessage)EMPTY_PAYLOADStreamReader)StrOrURL)	Application	AppRunnerBaseRequest
BaseRunnerRequestServerServerRunnerSockSiteUrlMappingMatchInfo)_RequestHandler)
SSLContext)UnpackSelf_ApplicationNone_Request)boundposixcygwinc                d    V ^8  d   QhR\         R\        P                  R\        P                  /# )   hostfamilyreturn)strsocketAddressFamily)formats   "a/Users/ahmad/.openclaw/workspace/scripts/.venv/lib/python3.14/site-packages/aiohttp/test_utils.py__annotate__rA   P   s.     , ,
,++,]],    c                     \        V ^ V4      # )    )get_port_socket)r9   r:   s   &&r@   get_unused_port_socketrF   P   s     4F++rB   c                p    V ^8  d   QhR\         R\        R\        P                  R\        P                  /# )r8   r9   portr:   r;   )r<   intr=   r>   )r?   s   "r@   rA   rA   V   s6     
 



"("6"6
]]
rB   c                     \         P                   ! V\         P                  4      p\        '       d0   VP                  \         P                  \         P
                  ^4       VP                  W34       V# )   )r=   SOCK_STREAMREUSE_ADDRESS
setsockopt
SOL_SOCKETSO_REUSEADDRbind)r9   rH   r:   ss   &&& r@   rE   rE   V   sP     	ff001A} 	
V&&(;(;Q?FFD<HrB   c                $    V ^8  d   QhR\         /# r8   r;   )rI   )r?   s   "r@   rA   rA   c   s     - -S -rB   c                 "   \         P                   ! \         P                  \         P                  4      ;_uu_ 4       p V P                  R4       \	        \
        V P                  4       ^,          4      uuRRR4       #   + '       g   i     R# ; i)z1Return a port that is unused on the current host.N)	127.0.0.1rD   )r=   AF_INETrL   rQ   r   rI   getsockname)rR   s    r@   unused_portrY   c   sP    	v~~v'9'9	:	:a	 C+, 
;	:	:	:s   6A==B	c                   D  a  ] tR t^jt o RtRRRRRRRRR	RR
]/V 3R lR lltR$V 3R lR llt]V 3R lR l4       t	V 3R lR lt
]V 3R lR l4       t]V 3R lR l4       t]V 3R lR l4       tV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR  ltV 3R! lR" ltR#tV tR# )%BaseTestServerFscheme loopNr9   rV   rH   skip_url_assertssocket_factoryc                   < V ^8  d   QhRS[ RS[S[P                  ,          RS[ RS[S[,          RS[RS[S[ S[S[P                  .S[P                  3,          RS[	RR	/# )
r8   r\   r^   r9   rH   r_   r`   kwargsr;   N)
r<   r   asyncioAbstractEventLooprI   boolr   r=   r>   r   )r?   __classdict__s   "r@   rA   BaseTestServer.__annotate__m   s     - - - w001	-
 - sm- - !#v++,fmm;
- - 
-rB   c               x    W n         R V n        R V n        W0n        W@n        RV n        Wn        WPn        W`n        R # )NF)	_looprunner_rootr9   rH   _closedr\   r_   r`   )selfr\   r^   r9   rH   r_   r`   rb   s   &$$$$$$,r@   __init__BaseTestServer.__init__m   s9     
,0$(
		 0,rB   c                N   < V ^8  d   QhRS[ S[P                  ,          RS[RR/# )r8   r^   rb   r;   N)r   rc   rd   r   )r?   rf   s   "r@   rA   rg      s5     I IW667IJMI	IrB   c                  "   V P                   '       d   R # Wn        VP                  RR 4      V n        V P                  ! RRR/VB G R j  xL
 V n         V P                   P                  4       G R j  xL
  V P                  '       g   ^ V n        V P                  p \        P                  ! V P                  4      P                  pV^8X  d   RV P                   R2pV^8X  d   \        P                  M\        P                  pV P                  V P                  V P                  V4      pVP!                  4       R,          w  V n        V n        \#        V P                   W`P                  R7      pVP%                  4       G R j  xL
  VP&                  pVf   Q hVP(                  p	V	f   Q hV	^ ,          P!                  4       ^,          V n        V P*                  '       g   V P                  '       d   RMR	V n        \-        V P*                   R
V RV P                   24      V n        R #  EL EL  \         d    ^p ELzi ; i L5i)Nsslhandler_cancellationT[]:Nr8   N)sockssl_contexthttpshttpz://: )rj   ri   pop_ssl_make_runnersetuprH   r9   	ipaddress
ip_addressversion
ValueErrorr=   AF_INET6rW   r`   rX   r+   start_serversocketsr\   r   rk   )
rm   r^   rb   absolute_hostr   r:   _socksiteserverr   s
   &&,       r@   start_serverBaseTestServer.start_server   s     ;;;
JJud+	 --R4R6RRkk!!!yyyDI			**4995==G a<		{!,M$+qLfnn##DIItyy&A$00226	49%YYGjjl!!!.."""AJ**,Q/	{{{%)YYY'FDKDKK=M?!DII;GH
/ S!  	G	 	sh   A	IH+&I2H.3I	I*H1 B=IIAI"I48I.I1I>IIIc                &   < V ^8  d   QhRS[ RS[/# r8   rb   r;   r   r'   )r?   rf   s   "r@   rA   rg      s      3 : rB   c                   "   R # 5iNr{   rm   rb   s   &,r@   r~   BaseTestServer._make_runner   s     s   c                &   < V ^8  d   QhRS[ RS[/# r8   pathr;   r#   r   )r?   rf   s   "r@   rA   rg      s     4 4X 4# 4rB   c                   V P                   f   Q h\        V4      pV P                  '       g0   VP                  '       d   Q hV P                   P	                  V4      # \        \        V P                   4      \        V4      ,           4      # r   )rk   r   r_   absolutejoinr<   )rm   r   urls   && r@   make_urlBaseTestServer.make_url   se    zz%%%$i$$$|||##::??3''s4::T233rB   c                    < V ^8  d   QhRS[ /# rT   re   )r?   rf   s   "r@   rA   rg      s     ' ' 'rB   c                    V P                   R J# r   )rj   rm   s   &r@   startedBaseTestServer.started   s    {{$&&rB   c                    < V ^8  d   QhRS[ /# rT   r   )r?   rf   s   "r@   rA   rg      s       rB   c                    V P                   # r   )rl   r   s   &r@   closedBaseTestServer.closed       ||rB   c                    < V ^8  d   QhRS[ /# rT   )r)   )r?   rf   s   "r@   rA   rg      s       rB   c                ^    V P                   pVf   Q hVP                  f   Q hVP                  # r   )rj   r   )rm   rj   s   & r@   handlerBaseTestServer.handler   s3     !!!}}(((}}rB   c                   < V ^8  d   QhRR/# r8   r;   Nr{   )r?   rf   s   "r@   rA   rg      s        T  rB   c                   "   V P                   '       d^   V P                  '       gJ   V P                  f   Q hV P                  P                  4       G Rj  xL
  RV n        RV n        RV n        R# R# R#  L5i)a0  Close all fixtures created by the test client.

After that point, the TestClient is no longer usable.

This is an idempotent function: running close multiple times
will not have any additional effects.

close is also run when the object is garbage collected, and on
exit when used as a context manager.

NT)r   r   rj   cleanuprk   rH   rl   r   s   &r@   closeBaseTestServer.close   s]      <<<;;***++%%'''DJDIDL !,<'s   $A6-A6A4 A6c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   rg           2 24 2rB   c                    \        R 4      hzUse async with instead	TypeErrorr   s   &r@   	__enter__BaseTestServer.__enter__       011rB   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r8   exc_type	exc_value	tracebackr;   Nr   r   BaseExceptionr   )r?   rf   s   "r@   rA   rg      sG      4./ M* M*	
 
rB   c                    R # r   r{   rm   r   r   r   s   &&&&r@   __exit__BaseTestServer.__exit__        	rB   c                   < V ^8  d   QhRR/# )r8   r;   r[   r{   )r?   rf   s   "r@   rA   rg      s      "2 rB   c                Z   "   V P                  V P                  R 7      G Rj  xL
  V #  L5ir^   N)r   ri   r   s   &r@   
__aenter__BaseTestServer.__aenter__   s*     TZZ000 	1s    +)+c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r   r   )r?   rf   s   "r@   rA   rg      sG      4./ M* M*	
 
rB   c                B   "   V P                  4       G R j  xL
  R #  L5ir   r   r   s   &&&&r@   	__aexit__BaseTestServer.__aexit__         jjl   )
rl   ri   rk   r}   r9   rH   rj   r\   r_   r`   r   )__name__
__module____qualname____firstlineno____test__rE   rn   r   r   r~   r   propertyr   r   r   r   r   r   r   r   __static_attributes____classdictcell__rf   s   @r@   r[   r[   j   s     H- - 59	-
  - #- "'- - -.I I@  4 4 ' '       &2 2   rB   r[   c                   `   a a ] tR t^t oRRRRRR/V3R lV 3R llltV3R	 lR
 ltRtVtV ;t# )
TestServerr\   r]   r9   rV   rH   Nc          
      H   < V ^8  d   QhRS[ RS[RS[RS[S[,          RS[/# )r8   appr\   r9   rH   rb   )r$   r<   r   rI   r   )r?   rf   s   "r@   rA   TestServer.__annotate__   sH     
H 
H
H 	
H
 
H sm
H 
HrB   c          	     @   < Wn         \        SV `  ! RR VRVRV/VB  R# r\   r9   rH   Nr{   )r   superrn   )rm   r   r\   r9   rH   rb   	__class__s   &&$$$,r@   rn   TestServer.__init__   s)     GGTGGGrB   c                &   < V ^8  d   QhRS[ RS[/# r   r   )r?   rf   s   "r@   rA   r      s     - -3 -: -rB   c                6   "   \        V P                  3/ VB # 5ir   )r%   r   r   s   &,r@   r~   TestServer._make_runner   s     ,V,,   )r   	r   r   r   r   rn   r~   r   r   __classcell__r   rf   s   @@r@   r   r      sA     
H 	
H
  
H #
H 
H- - -rB   r   c                   d   a a ] tR t^t oRRRRRR/V3R lV 3R llltRV3R	 lR
 lltRtVtV ;t# )RawTestServerr\   r]   r9   rV   rH   Nc                L   < V ^8  d   QhRS[ RS[RS[RS[S[,          RS[RR/# )r8   r   r\   r9   rH   rb   r;   N)r-   r<   r   rI   r   )r?   rf   s   "r@   rA   RawTestServer.__annotate__   sS     
H 
H 
H 	
H
 
H sm
H 
H 

HrB   c          	     @   < Wn         \        SV `  ! RR VRVRV/VB  R# r   )_handlerr   rn   )rm   r   r\   r9   rH   rb   r   s   &&$$$,r@   rn   RawTestServer.__init__   s)      GGTGGGrB   c                ,   < V ^8  d   QhRS[ RS[RS[/# )r8   debugrb   r;   )re   r   r*   )r?   rf   s   "r@   rA   r     s"     8 8 8s 8| 8rB   c                n   "   \        V P                  3R V P                  RV/VB p\        V3RV/VB # 5i)r^   r   )r)   r   ri   r*   )rm   r   rb   srvs   &&, r@   r~   RawTestServer._make_runner  s;     T]]KK5KFKC7u777s   35)r   )Tr   r   s   @@r@   r   r      sA     
H 	
H
  
H #
H 
H8 8 8rB   r   c                   "  a  ] tR tRt o RtRt]RR/V 3R lR ll4       t]RR/V 3R lR	 ll4       tRRR
R/V 3R lR lltV 3R lR lt]	V 3R lR l4       t
]	V 3R lR l4       t]	V 3R lR l4       t]	V 3R lR l4       t]	V 3R lR l4       tV 3R lR ltV 3R lR lt]P$                  RL8  dR   ]'       dJ   V 3R lR ltV 3R lR  ltV 3R! lR" ltV 3R# lR$ ltV 3R% lR& ltV 3R' lR( ltV 3R) lR* ltV 3R+ lR, ltMHV 3R- lR. ltV 3R/ lR0 ltV 3R1 lR2 ltV 3R3 lR4 ltV 3R5 lR6 ltV 3R7 lR8 ltV 3R9 lR: ltV 3R; lR< ltV 3R= lR> ltV 3R? lR@ ltV 3RA lRB ltV 3RC lRD ltV 3RE lRF lt V 3RG lRH lt!V 3RI lRJ lt"RKt#V t$R# )M
TestClienti  zV
A test client implementation.

To write functional tests for aiohttp based servers.

F
cookie_jarNc          
      D   < V ^8  d   QhRRRS[ RS[S[,          RS[RR/# )r8   rm   z TestClient[Request, Application]r   r   rb   r;   N)r   r   r   r   )r?   rf   s   "r@   rA   TestClient.__annotate__  sA      0 ./	
  
rB   c                   R # r   r{   rm   r   r   rb   s   &&$,r@   rn   TestClient.__init__       rB   c          
      D   < V ^8  d   QhRRRS[ RS[S[,          RS[RR/# )r8   rm   zTestClient[_Request, None]r   r   rb   r;   N)r[   r   r   r   )r?   rf   s   "r@   rA   r   $  sA      * ./	
  
rB   c                   R # r   r{   r  s   &&$,r@   rn   r  #  r  rB   r^   c          
      j   < V ^8  d   QhRS[ RS[S[,          RS[S[P                  ,          RS[RR/# )r8   r   r   r^   rb   r;   N)r[   r   r   rc   rd   r   )r?   rf   s   "r@   rA   r   +  sN     = == ./	=
 w001= = 
=rB   c               ,   \        V\        4      '       g   \        R \        V4      ,          4      hWn        W0n        Vf   \        P                  ! RVR7      p\        RRVRV/VB V n	        RV P                  n
        RV n        . V n        . V n        R# )z2server must be TestServer instance, found type: %rNT)unsafer^   r^   r   Fr{   )
isinstancer[   r   typer   ri   aiohttp	CookieJarr   _session_retry_connectionrl   
_responses_websockets)rm   r   r   r^   rb   s   &&$$,r@   rn   r  +  s     &.11DtF|S  
 **$TBJ%Q4QJQ&Q*/'02:<rB   c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r   A  s     9 9D 9rB   c                n   "   V P                   P                  V P                  R 7      G Rj  xL
  R#  L5ir   )r   r   ri   r   s   &r@   r   TestClient.start_serverA  s$     ll''TZZ'888s   *535c                    < V ^8  d   QhRS[ /# rT   )r<   )r?   rf   s   "r@   rA   r   E  s     ! !c !rB   c                .    V P                   P                  # r   )r   r9   r   s   &r@   r9   TestClient.hostD      ||   rB   c                0   < V ^8  d   QhRS[ S[,          /# rT   )r   rI   )r?   rf   s   "r@   rA   r   I  s     ! !hsm !rB   c                .    V P                   P                  # r   )r   rH   r   s   &r@   rH   TestClient.portH  r  rB   c                    < V ^8  d   QhRS[ /# rT   )r[   )r?   rf   s   "r@   rA   r   M  s       rB   c                    V P                   # r   )r   r   s   &r@   r   TestClient.serverL  r   rB   c                    < V ^8  d   QhRS[ /# rT   )r2   )r?   rf   s   "r@   rA   r   Q  s     2 2% 2rB   c                0    \        V P                  R R4      # )r   N)getattrr   r   s   &r@   r   TestClient.appP  s    t||UD11rB   c                    < V ^8  d   QhRS[ /# rT   )r   )r?   rf   s   "r@   rA   r   U  s       rB   c                    V P                   # )zAn internal aiohttp.ClientSession.

Unlike the methods on the TestClient, client session requests
do not automatically include the host in the url queried, and
will require an absolute path to the resource.

)r  r   s   &r@   sessionTestClient.sessionT  s     }}rB   c                &   < V ^8  d   QhRS[ RS[/# r   r   )r?   rf   s   "r@   rA   r   _  s     + +X +# +rB   c                8    V P                   P                  V4      # r   )r   r   )rm   r   s   &&r@   r   TestClient.make_url_  s    ||$$T**rB   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# r8   methodr   rb   r;   )r<   r#   r   r   )r?   rf   s   "r@   rA   r   b  s-      !)58	rB   c                   "   V P                   P                  ! WP                  V4      3/ VB G R j  xL
 pV P                  P	                  V4       V#  L!5ir   )r  requestr   r  append)rm   r,  r   rb   resps   &&&, r@   _requestTestClient._requestb  sI      ]]**6==3FQ&QQt$ R   0AA"Ac                B   < V ^8  d   QhRS[ RS[RS[S[,          RS[/# r+  )r<   r#   r/   r   r   )r?   rf   s   "r@   rA   r   l  s2     	) 	)	)%-	)9?9P	)#	)rB   c                    R # r   r{   rm   r,  r   rb   s   &&&,r@   r.  TestClient.requestl  s    %(rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r8   r   rb   r;   r#   r/   r   r   )r?   rf   s   "r@   rA   r   p  .     	) 	)	) _-	) $		)rB   c                    R # r   r{   rm   r   rb   s   &&,r@   getTestClient.getp       &)rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r   v  r;  rB   c                    R # r   r{   r=  s   &&,r@   optionsTestClient.optionsv  r@  rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r   |  r;  rB   c                    R # r   r{   r=  s   &&,r@   headTestClient.head|  r@  rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r     r;  rB   c                    R # r   r{   r=  s   &&,r@   postTestClient.post  r@  rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r     r;  rB   c                    R # r   r{   r=  s   &&,r@   putTestClient.put  r@  rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r     r;  rB   c                    R # r   r{   r=  s   &&,r@   patchTestClient.patch  r@  rB   c                <   < V ^8  d   QhRS[ RS[S[,          RS[/# r9  r:  )r?   rf   s   "r@   rA   r     r;  rB   c                    R # r   r{   r=  s   &&,r@   deleteTestClient.delete  r@  rB   c                2   < V ^8  d   QhRS[ RS[RS[RS[/# r+  )r<   r#   r   r   )r?   rf   s   "r@   rA   r     s3     
	Q 
	Q
	Q%-
	Q9<
	Q#
	QrB   c                :    \        V P                  ! W3/ VB 4      # )zRoutes a request to tested http server.

The interface is identical to aiohttp.ClientSession.request,
except the loop kwarg is overridden by the instance used by the
test server.

)r   r1  r6  s   &&&,r@   r.  r7    s     *$--*O*OPPrB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r#   r   r   )r?   rf   s   "r@   rA   r     (     	X 	XH 	X 	X8N 	XrB   c                X    \        V P                  ! \        P                  V3/ VB 4      # )zPerform an HTTP GET request.)r   r1  r   METH_GETr=  s   &&,r@   r>  r?    !    )$--t*Vv*VWWrB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     (     	Y 	YX 	Y 	Y9O 	YrB   c                X    \        V P                  ! \        P                  V3/ VB 4      # )zPerform an HTTP POST request.)r   r1  r   	METH_POSTr=  s   &&,r@   rK  rL    "    )$--*WPV*WXXrB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     s#     	 	 	C 	<R 	rB   c                X    \        V P                  ! \        P                  V3/ VB 4      # )z Perform an HTTP OPTIONS request.)r   r1  r   METH_OPTIONSr=  s   &&,r@   rC  rD    s(    )d//@@ rB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     rb  rB   c                X    \        V P                  ! \        P                  V3/ VB 4      # )zPerform an HTTP HEAD request.)r   r1  r   	METH_HEADr=  s   &&,r@   rG  rH    re  rB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     r]  rB   c                X    \        V P                  ! \        P                  V3/ VB 4      # )zPerform an HTTP PUT request.)r   r1  r   METH_PUTr=  s   &&,r@   rO  rP    r`  rB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     s#     	 	h 	# 	:P 	rB   c                X    \        V P                  ! \        P                  V3/ VB 4      # zPerform an HTTP PATCH request.)r   r1  r   
METH_PATCHr=  s   &&,r@   rS  rT    s&    )doot>v> rB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  r\  )r?   rf   s   "r@   rA   r     s#     	 	x 	3 	;Q 	rB   c                X    \        V P                  ! \        P                  V3/ VB 4      # rq  )r   r1  r   METH_DELETEr=  s   &&,r@   rW  rX    s(    )d..?? rB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  )r#   r   r   )r?   rf   s   "r@   rA   r     s(     J Jx J3 J;S JrB   c                :    \        V P                  ! V3/ VB 4      # )zZInitiate websocket connection.

The api corresponds to aiohttp.ClientSession.ws_connect.

)r   _ws_connectr=  s   &&,r@   
ws_connectTestClient.ws_connect  s     ((8(8(H(HIIrB   c                ,   < V ^8  d   QhRS[ RS[RS[/# r9  )r#   r   r   )r?   rf   s   "r@   rA   r     s%      (+	 rB   c                   "   V P                   P                  ! V P                  V4      3/ VB G R j  xL
 pV P                  P	                  V4       V#  L!5ir   )r  ry  r   r  r/  )rm   r   rb   wss   &&, r@   rx  TestClient._ws_connect  sK      ==++DMM$,?J6JJ#	 Kr3  c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r     s        T  rB   c                t  "   V P                   '       g   V P                   F  pVP                  4        K  	  V P                   F  pVP                  4       G Rj  xL
  K  	  V P                  P                  4       G Rj  xL
  V P
                  P                  4       G Rj  xL
  RV n         R# R#  LW L3 L5i)a  Close all fixtures created by the test client.

After that point, the TestClient is no longer usable.

This is an idempotent function: running close multiple times
will not have any additional effects.

close is also run on exit when used as a(n) (asynchronous)
context manager.

NT)rl   r  r   r  r  r   )rm   r0  r}  s   &  r@   r   TestClient.close  s      |||

 (&&hhj   '--%%''',,$$&&&DL  !'&s6   AB8B2%B8 B4!B8"B6#B84B86B8c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r     r   rB   c                    \        R 4      hr   r   r   s   &r@   r   TestClient.__enter__  r   rB   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r8   r   exctbr;   Nr   )r?   rf   s   "r@   rA   r     sG      4./ m$ ]#	
 
rB   c                    R # r   r{   rm   r   r  r  s   &&&&r@   r   TestClient.__exit__  r   rB   c                    < V ^8  d   QhRS[ /# rT   r0   )r?   rf   s   "r@   rA   r     s      $ rB   c                B   "   V P                  4       G R j  xL
  V #  L5ir   )r   r   s   &r@   r   TestClient.__aenter__  s!     !!! 	"r   c                p   < V ^8  d   QhRS[ S[S[,          ,          RS[ S[,          RS[ S[,          RR/# r  r   )r?   rf   s   "r@   rA   r     sG      4./ m$ ]#	
 
rB   c                B   "   V P                  4       G R j  xL
  R #  L5ir   r   r  s   &&&&r@   r   TestClient.__aexit__  r   r   )rl   ri   r  r   r  r        )%r   r   r   r   __doc__r   r   rn   r   r   r9   rH   r   r   r%  r   r1  sysversion_infor   r.  r>  rC  rG  rK  rO  rS  rW  ry  rx  r   r   r   r   r   r   r   r   s   @r@   r   r     s     H 37	    37	  = 37	=
 59= =,9 9 ! ! ! !   2 2  + +  7"}	) 	)	) 	)	) 	)	) 	)	) 	)	) 	)	) 	)	) 	)
	Q 
	Q	X 	X	Y 	Y	 		Y 	Y	X 	X	 		 	J J    *2 2   rB   r   c                      a  ] tR tRt o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R	 lR
 ltV 3R lR lt	V 3R lR lt
V 3R lR ltV 3R lR ltRtV tR# )AioHTTPTestCasei  a  A base class to allow for unittest web applications using aiohttp.

Provides the following:

* self.client (aiohttp.test_utils.TestClient): an aiohttp test client.
* self.loop (asyncio.BaseEventLoop): the event loop in which the
    application and server are running.
* self.app (aiohttp.web.Application): the application returned by
    self.get_application()

Note that the TestClient's methods are asynchronous: you have to
execute function on the test client using asynchronous methods.
c                    < V ^8  d   QhRS[ /# rT   r$   )r?   rf   s   "r@   rA   AioHTTPTestCase.__annotate__  s      { rB   c                *   "   V P                  4       # 5i)ziGet application.

This method should be overridden
to return the aiohttp.web.Application
object to test.
)get_appr   s   &r@   get_applicationAioHTTPTestCase.get_application  s      ||~s   c                    < V ^8  d   QhRS[ /# rT   r  )r?   rf   s   "r@   rA   r    s     J J JrB   c                    \        R4      h)zaObsolete method used to constructing web application.

Use .get_application() coroutine instead.
z+Did you forget to define get_application()?)RuntimeErrorr   s   &r@   r  AioHTTPTestCase.get_app  s    
 HIIrB   c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r  &  s     ' '$ 'rB   c                r   "   \         P                  ! 4       V n        V P                  4       G R j  xL
 #  L5ir   )rc   get_running_loopr^   
setUpAsyncr   s   &r@   
asyncSetUpAioHTTPTestCase.asyncSetUp&  s(     ,,.	__&&&&s   .757c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r  *  s     ) )$ )rB   c                <  "   V P                  4       G R j  xL
 V n        V P                  V P                  4      G R j  xL
 V n        V P	                  V P                  4      G R j  xL
 V n        V P
                  P                  4       G R j  xL
  R #  L} LW L1 L5ir   )r  r   
get_serverr   
get_clientclientr   r   s   &r@   r  AioHTTPTestCase.setUpAsync*  sj     --// OODHH55 OODKK88kk&&(((	 058(sC   BB'BB'B&B'&BBBBBBc                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r  1  s     * *T *rB   c                >   "   V P                  4       G R j  xL
 #  L5ir   )tearDownAsyncr   s   &r@   asyncTearDownAioHTTPTestCase.asyncTearDown1  s     ''))))s   c                   < V ^8  d   QhRR/# r   r{   )r?   rf   s   "r@   rA   r  4  s     " "T "rB   c                V   "   V P                   P                  4       G R j  xL
  R #  L5ir   )r  r   r   s   &r@   r  AioHTTPTestCase.tearDownAsync4  s     kk!!!s   )')c                &   < V ^8  d   QhRS[ RS[/# )r8   r   r;   )r$   r   )r?   rf   s   "r@   rA   r  7  s     / /K /J /rB   c                6   "   \        WP                  R7      # 5i)zReturn a TestServer instance.r   )r   r^   )rm   r   s   &&r@   r  AioHTTPTestCase.get_server7  s     #II..r   c                <   < V ^8  d   QhRS[ RS[S[S[3,          /# )r8   r   r;   )r   r   r(   r$   )r?   rf   s   "r@   rA   r  ;  s%     2 2z 2j+AU6V 2rB   c                6   "   \        WP                  R7      # 5i)zReturn a TestClient instance.r   )r   r^   )rm   r   s   &&r@   r  AioHTTPTestCase.get_client;  s     &yy11r   )r   r  r^   r   N)r   r   r   r   r  r  r  r  r  r  r  r  r  r   r   r   s   @r@   r  r    s\      J J' ') )* *" "/ /2 2rB   r  c                H    V ^8  d   QhR\         R\         R\         R\         /# )r8   funcargsrb   r;   r   )r?   s   "r@   rA   rA   @  s(      C  s s rB   c                @    \         P                  ! R\        ^R7       V # )zk
A decorator dedicated to use with asynchronous AioHTTPTestCase test methods.

In 3.8+, this does nothing.
zBDecorator `@unittest_run_loop` is no longer needed in aiohttp 3.8+)
stacklevel)warningswarnDeprecationWarning)r  r  rb   s   &*,r@   unittest_run_loopr  @  s      MML
 KrB   Fc                f    V ^8  d   QhR\         R\        R\        \        P                  ,          /# )r8   loop_factoryfastr;   )_LOOP_FACTORYre   r	   rc   rd   )r?   s   "r@   rA   rA   R  s/     	( 	(	(@D	(g''(	(rB   c              #  D   "   \        V 4      pVx  \        W!R7       R# 5i)zrA contextmanager that creates an event_loop, for test purposes.

Handles the creation and cleanup of a test loop.
)r  N)setup_test_loopteardown_test_loop)r  r  r^   s   && r@   loop_contextr  Q  s      <(D
Jt's    c                D    V ^8  d   QhR\         R\        P                  /# )r8   r  r;   )r  rc   rd   )r?   s   "r@   rA   rA   ^  s"     
 


rB   c                @    V ! 4       p\         P                  ! V4       V# )zCreate and return an asyncio.BaseEventLoop instance.

The caller should also call teardown_test_loop,
once they are done with the loop.
)rc   set_event_loop)r  r^   s   & r@   r  r  ^  s     >D4 KrB   c                H    V ^8  d   QhR\         P                  R\        RR/# )r8   r^   r  r;   N)rc   rd   re   )r?   s   "r@   rA   rA   k  s'     ! !W66 !d !t !rB   c                   V P                  4       pV'       g<   V P                  V P                  4       V P                  4        V P	                  4        V'       g   \
        P                  ! 4        \        P                  ! R4       R# )z>Teardown and cleanup an event_loop created by setup_test_loop.N)		is_closed	call_soonstoprun_foreverr   gccollectrc   r  )r^   r  r   s   && r@   r  r  k  sP    ^^Ftyy!




4 rB   c                8    V ^8  d   QhR\         P                  /# rT   )r   	MagicMock)r?   s   "r@   rA   rA   y  s      $.. rB   c                      R  R lp R R lp\         P                  ! \        R7      p/ Vn        Wn        Wn        RVn        \        V4      Vn        VP                  P                  4        V# )c                <    V ^8  d   QhR\         R\        R\         /# )r8   r   keyr;   r   r<   )r?   s   "r@   rA   &_create_app_mock.<locals>.__annotate__z  s!     # #c # # #rB   c                 (    V P                   V,          # r   
__app_dict)r   r  s   &&r@   get_dict"_create_app_mock.<locals>.get_dictz  s    ~~c""rB   c                @    V ^8  d   QhR\         R\        R\         RR/# )r8   r   r  valuer;   Nr  )r?   s   "r@   rA   r  }  s(     $ $c $ $C $D $rB   c                 "    W P                   V&   R # r   r  )r   r  r  s   &&&r@   set_dict"_create_app_mock.<locals>.set_dict}  s    #srB   )specF)
r   r  r$   r  __getitem____setitem___debugr   on_response_preparefreeze)r  r  r   s      r@   _create_app_mockr  y  sW    #$ ..k
*CCNOOCJ$SkC""$JrB   c                Z    V ^8  d   QhR\         \        ,          R\        P                  /# )r8   
sslcontextr;   )r   r.   r   Mock)r?   s   "r@   rA   rA     s#     
 
(:"6 
$)) 
rB   c                 d   a  \         P                  ! 4       pR  V 3R llpW!P                  n        V# )c                F    V ^8  d   QhR\         R\        \        ,          /# )r8   r  r;   )r<   r   r.   )r?   s   "r@   rA   '_create_transport.<locals>.__annotate__  s      C HZ$8 rB   c                    < V R 8X  d   S# R# )r  Nr{   )r  r  s   &r@   get_extra_info)_create_transport.<locals>.get_extra_info  s    ,rB   )r   r  r  side_effect)r  	transportr  s   f  r@   _create_transportr    s,    		I  ,:(rB   
match_infor   closingr   writerprotocolr  payloadr  client_max_sizer^   .c                    V ^8  d   QhR\         R\         R\        R\        R\        R\        R\        R\        R	\        R
\        R\        R\
        \        ,          R\        R\        R\        /# )r8   r,  r   headersr   r   r  r   r  r  r  r  r  r  r^   r;   )	r<   r   r   re   r"   r   r.   rI   r(   )r?   s   "r@   rA   rA     s     _ __
_ _
 _ _ _ 
_ _ _ _ _ $_ _ _  !_rB   c               V   \         P                  ! 4       pVRJ d    \        P                  ! 4       pV\        ^^4      8  d   RpV'       d^   \        \        V4      4      p\        ;QJ d"    . R VP                  4        4       F  NK  	  5M! R VP                  4        4       4      pM\        \        4       4      pRpRVP                  \        P                  R4      P                  4       9   p\!        V VVVVVRRV\#        V4      4
      pVf   \%        4       pV	\&        J d   \)        V4      p	V\&        J du   \         P                  ! 4       pWn        \         P,                  ! V	P/                  R4      R	7      \1        V4      n        \         P,                  ! VR	7      \1        V4      n        V\&        J d\   \         P                  ! 4       p\7        R4      Vn        \7        R4      Vn        \7        R4      Vn        \7        R4      Vn        Wn        Wn        Wxn         \C        VWW~WR
7      p\E        V\&        J d   / MT\         P                  ! 4       4      pVPG                  V4       VVn$        V#   \         d+    \         P                  ! 4       pRTP
                  n         ELui ; i)zCreates mocked web.Request testing purposes.

Useful in unit tests, when spinning full web server is overkill or
specific conditions and errors are hard to trigger.
.Tc              3   j   "   T F)  w  rVP                  R 4      VP                  R 4      3x  K+  	  R# 5i)zutf-8N)encode).0kvs   &  r@   	<genexpr>&make_mocked_request.<locals>.<genexpr>  s,      
?NtqQXXg 12s   13chunkedr]   NFpeername)return_value)r  r{   )%r   r  rc   r  r  create_futurer  r   r   r   tupleitemsr>  r   TRANSFER_ENCODINGlowerr    r   r  r   r  r  PropertyMockr  r  r  rw   make_mocked_corowrite_headerswrite	write_eofdrainr  r(   r,   add_app_match_info)r,  r   r  r   r   r  r   r  r  r  r  r  r  r^   taskraw_hdrsr  messagereqs   &&&$$$$$$$$$$$     r@   make_mocked_requestr$    s2   , 99;Ds{
	1++-D
 Q""";w#785 
?F}}
55 
?F}}
 
 #;=17;;t'='=rBHHJJGD	G { H%j1	899;&"&"3"3"11*=#
X &*%6%6J%OX"/5'-+D1'-$"O
F$C %H$*diikJ s COJC  	199;D.0D+	1s   I3 31J('J(c                <    V ^8  d   QhR\         R\         R\         /# )r8   r  raise_exceptionr;   r  )r?   s   "r@   rA   rA     s$     & &&36&&rB   c                H   a a R VV 3R llp\         P                  ! VR7      # )zCreates a coroutine mock.c                <    V ^8  d   QhR\         R\         R\         /# )r8   r  rb   r;   r  )r?   s   "r@   rA   &make_mocked_coro.<locals>.__annotate__  s!      s c c rB   c                  |   <"   S\         Jd   Sh\        P                  ! S4      '       g   S# SG R j  xL
  R #  L5ir   )r   inspectisawaitable)r  rb   r&  r  s   *,r@   	mock_coro#make_mocked_coro.<locals>.mock_coro  s4     (*!!""<00s   (<<:<)wraps)r   r  )r  r&  r-  s   ff r@   r  r    s    
  999%%rB   r  )Fr   i   )gr  rc   
contextlibr  r+  r   osr=   r  r  abcr   r   typesr   typingr   r   r   r   r	   r
   r   r   r   r   r   unittestr   r   	aiosignalr   	multidictr   r   yarlr   r  aiohttp.clientr   r   r   r]   r   r   r   client_reqrepr   	client_wsr   helpersr   ry   r   r    streamsr!   r"   typedefsr#   webr$   r%   r&   r'   r(   r)   r*   r+   r,   web_protocolr-   rr   r.   r  r/   r1   r2   r3   nameplatformrM   rW   rF   rE   rY   r[   r   r   r   r  r  rd   r  contextmanagernew_event_loopr  r  r  r  r  r$  r  r{   rB   r@   <module>rE     sZ       	   	  
  #     3  3    " " ) .  0 0 
 
 
 *Jw=wD-{DA :[17"??s||x'? /5nn,
-AS AH- -"8N 8$s#334 sl62- 62r W6667 ")"8"8u	( 	( #*"8"8
!$
_
 _ 'q!,_ _ _ _ _ _ *_ (,_ #_ _ _F !& &rB   