
    qi                        S r SSKrSSKrSSKrSSKrSSKrSSKJrJ	r	  SSK
r
SSKrSSKrSSKJr  SrSrSrSrSr\R*                  R,                  \\4SS.\R.                  R0                  \\4\R.                  R2                  S	.0r\	S
 5       r\
R8                  S 5       r\
R8                  S 5       r\
R8                  S 5       r\
R8                  S 5       r  " S S5      r!S r"S r#S r$g)zAPytest fixtures and other helpers for doing testing by end-users.    N)closingcontextmanager)webtestz0.0.0.0z::   )	bind_addrwsgi_app)r   gatewayc              #   :  #    [         U    R                  5       nUR                  S5      S   n[        [        4 H  n X24nU " SSU0UD6n  O   SWl        [        R                  " UR                  S9nUR                  5         UR                  (       d)  [        R                  " S5        UR                  (       d  M)   Xe4v   UR                  5         UR                  5         g! [
         a     M  f = f! UR                  5         UR                  5         f = f7f)z/Set up and tear down a Cheroot server instance.r   r   )targetg?N )configcopypopANY_INTERFACE_IPV6ANY_INTERFACE_IPV4OSErrorshutdown_timeout	threadingThread
safe_startstartreadytimesleepstopjoin)server_factoryconf	bind_port	interfaceactual_bind_addr
httpserverserver_threads          D/home/kali/flask_env/lib/python3.13/site-packages/cheroot/testing.pycheroot_serverr&   &   s
     .!&&(D%b)I');;			 )5' *J  < #$J $$J,A,ABM

3 ''%  		" 	sA   ;DC%A1D?C6 !D%
C3/D2C33D6"DDc               #      #    [        [        R                  R                  5       u  pX4v   SSS5        g! , (       d  f       g= f7f)zlSet up and tear down a Cheroot WSGI server instance.

This emits a tuple of a thread and a server instance.
N)r&   cherootwsgiServerr$   srvs     r%   thread_and_wsgi_serverr-   H   s2      
++	,0D   
-	,	,   $A7	A
AAc               #      #    [        [        R                  R                  5       u  pX4v   SSS5        g! , (       d  f       g= f7f)zlSet up and tear down a Cheroot HTTP server instance.

This emits a tuple of a thread and a server instance.
N)r&   r(   server
HTTPServerr+   s     r%   thread_and_native_serverr2   R   s2      
11	26J}   
3	2	2r.   c                     U u  pU$ )z4Set up and tear down a Cheroot WSGI server instance.r   )r-   _server_threadr,   s      r%   wsgi_serverr5   \   s     1NJ    c                     U u  pU$ )z4Set up and tear down a Cheroot HTTP server instance.r   )r2   r4   r,   s      r%   native_serverr8   c   s     3NJr6   c                   8    \ rS rSrS rS r    SS jrS rSrg)	_TestClientj   c                     [        UR                  5      u  U l        U l        U l        Xl        U R                  5       U l        g )N)_get_conn_datar   
_interface_host_portserver_instanceget_connection_http_connection)selfr0   s     r%   __init___TestClient.__init__k   s;    2@3
/TZ  & $ 3 3 5r6   c                     U R                    SU R                   3nU R                  R                  c  [        R
                  R                  O[        R
                  R                  nU" U5      $ )N:)r>   r@   rA   ssl_adapterhttpclientHTTPConnectionHTTPSConnection)rD   nameconn_clss      r%   rB   _TestClient.get_connectionr   s\    //"!DJJ<0 ##//7 KK&&,, 	
 ~r6   Nc           
          [         R                  " UUUU R                  U R                  U=(       d    U R                  US9$ )N)methodheadershostport	http_connprotocol)r   openURLr?   r@   rC   )rD   urirR   rS   rV   rW   s         r%   request_TestClient.request{   s=     84#8#8
 	
r6   c                    ^ ^ UU 4S jnU$ )Nc                 N   > TR                  5       nTR                  " U 4SU0UD6$ )NrR   )upperrZ   )rY   kwargshttp_method	attr_namerD   s      r%   _wrapper)_TestClient.__getattr__.<locals>._wrapper   s(    #//+K<<BKB6BBr6   r   )rD   ra   rb   s   `` r%   __getattr___TestClient.__getattr__   s    	C r6   )r?   rC   r>   r@   rA   )GETNNzHTTP/1.1)	__name__
__module____qualname____firstlineno__rE   rB   rZ   rd   __static_attributes__r   r6   r%   r:   r:   j   s$    6 
$r6   r:   c                 "    [        [        R                  " [        R                  S95       nUR                  U S45        S S S 5        g! , (       d  f       g= f! [         a)  nUR
                  [
        R                  :w  a  e  S nAgS nAff = f)N)familyr   TF)r   socketAF_INET6bindr   errnoEADDRNOTAVAIL)r!   socksock_errs      r%   _probe_ipv6_sockru      sv    V]]&//:;tIIy!n% <  <; 	  >>U000 1
 s4   +A A
A 

AA A 
B%B		Bc                     [        U [        5      (       a  U u  pOU Sp![        R                  " U5      nSU;   a  [	        U5      (       d
  SnSU;   a  UnX1U4$ )Nr   rH   z	127.0.0.1)
isinstancetupler   r!   ru   )r   rT   rU   r!   s       r%   r=   r=      s^    )U##
dd!!$'I
i 0 ; ;	$;DD  r6   c                     [        U 5      $ )z5Create and return a test client for the given server.)r:   )r0   s    r%   get_server_clientrz      s    vr6   )%__doc__rq   http.clientrJ   rn   r   r   
contextlibr   r   pytestcheroot.serverr(   cheroot.wsgicheroot.testr   EPHEMERAL_PORTNO_INTERFACEr   r   SUCCESSFUL_SUBPROCESS_EXITr)   r*   r0   r1   Gatewayr   r&   fixturer-   r2   r5   r8   r:   ru   r=   rz   r   r6   r%   <module>r      s$   G      .            LL"N3 NN"N3>>)) 	
  B ! ! ! !    ( (V! r6   