
    q(                       S SK Jr  S SKrS SKrS SKrS SK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  S SKJr  S SKJrJr  S SKJr  S SKJrJr  S SKr  S SKr S SKrSrS S
KJ r   S SK!J"r"  S SK#J$r$  S SK%J&r&   S SK'J(s  J)r)  \
RT                  (       a  S SK+r+\
RX                  " S5      r-\
RX                  " S\
R\                  S\
R^                  4   S9r0\Rb                  " 5       S:X  a  Sr2OSr2SS/r3SS/r4Sr5Sr6\Rn                  Rq                  S5      (       d  \Rn                  Rq                  S5      S:X  a  Sr6\"" S5      r9S7S  jr:S8S9S! jjr;\:" S"5      r<\$4S:S# jjr=S;S$ jr>S<S% jr?S<S& jr@S<S' jrAS<S( jrBS<S) jrCSqDS<S* jrES<S+ jrFS=S, jrG " S- S.\R                  5      rI " S/ S05      rJ " S1 S2\5      rK " S3 S4\5      rL " S5 S6\5      rMg! \ a    S SKr GNf = f! \ a    Sr GNf = f! \ a    S	r GNf = f! \ a    Sr) GNf = f)>    )annotationsN)Sequencewraps)LoaderMetaPathFinder)
ModuleSpec)
ModuleTypeTracebackTypeTF)util)ConnectionPool)HTTPWarning)ssl__RT
_TestFuncT.)boundWindowsz	127.0.0.0z	240.0.0.0))z::1r   T))z	127.0.0.1r   F))z192.0.2.255r   F))z2001:db8::1r   TgMbP?g?CIGITHUB_ACTIONStrueg      ?dummyc                     [         R                  " U S[         R                  5        g! [         R                   a     gf = f)z:Returns True if the system can resolve host to an address.NTF)socketgetaddrinfo	AF_UNSPECgaierror)hosts    4platform/gsutil/third_party/urllib3/test/__init__.py_can_resolver   T   s8    4v'7'78?? s   &) A A c                    U =(       d    [         R                  n U " [        R                  S9n [	        US5      (       a   UR                  [        R                  5        g g! [         a     gf = f)z"Detect if ALPN support is enabled.)protocolset_alpn_protocolsTF)r   
SSLContextr   PROTOCOL_TLShasattrr"   ALPN_PROTOCOLSNotImplementedError)ctx_clsctxs     r   has_alpnr*   ]   sk    (G
4,,
-C3,--""4#6#67 .
   s   0A" "
A/.A/z
localhost.c                    / n[         R                   H*  n[        US   U 5      (       a  M  UR                  U5        M,     U[         R                  S S & g )N   )warningsfilters
issubclassappend)clsnew_filtersfs      r   clear_warningsr4   p   sK    KadC  1  &HQ    c                 N    [        5         [        R                  " S[        5        g )Nignore)r4   r-   simplefilterr    r5   r   setUpr:   y   s    (K0r5   c                 j    [         R                  R                  [        R                  " 5       S:H  SS9$ )zSkips this test on Windowsr   zTest does not run on Windowsreason)pytestmarkskipifplatformsystemr9   r5   r   
notWindowsrC   ~   s0    ;;Y&-   r5   c                 J    [         R                  R                  [        S L SS9$ )Nz%only run if brotli library is presentr<   r>   r?   r@   brotlir9   r5   r   
onlyBrotlirG      s(    ;;$F   r5   c                 J    [         R                  R                  [        S LSS9$ )Nz&only run if a brotli library is absentr<   rE   r9   r5   r   	notBrotlirI      s)    ;;d#K   r5   c                 P    [         R                  R                  [        (       + SS9$ )Nz3only run if a python-zstandard library is installedr<   r>   r?   r@   HAS_ZSTDr9   r5   r   onlyZstdrM      s&    ;;R   r5   c                 F    [         R                  R                  [        SS9$ )Nz7only run if a python-zstandard library is not installedr<   rK   r9   r5   r   notZstdrO      s$    ;;H   r5   c                 R   ^^ SS jmSU4S jjmSU4S jjn     SS jnU" U 5      $ )	z-Helps you skip tests that require the networkc                ^    [        U SS 5      [        R                  [        R                  4;   $ )Nerrno)getattrrR   ENETUNREACHEHOSTUNREACH)errs    r   _is_unreachable_err-requires_network.<locals>._is_unreachable_err   s/    sGT*/
 
 	
r5   c                    >  [         R                  " [        S4S5      n U R                  5         g! [         R                   a     g[
         a  nT" U5      (       a   S nAge S nAff = f)NP   g-C6?TF)r   create_connectionTARPIT_HOSTclosetimeoutOSError)sockerW   s     r   
_has_route$requires_network.<locals>._has_route   s[    
	++[",=vFDJJL~~ 	 	"1%%		s!   -1 A(	A(A#"A##A(c                j   >^  [        T 5      SUU 4S jj5       n[        R                  " [        U5      $ )z,Skip test exuction if network is unreachablec                 r   > [         c  T" 5       q [         (       d  [        R                  " S5        T" U 0 UD6$ )Nz5Can't run the test because the network is unreachable)_requires_network_has_router>   skip)argskwargsrb   r3   s     r   wrapper<requires_network.<locals>._skip_if_no_route.<locals>.wrapper   s6     +2.8l+..STd%f%%r5   )rh   
typing.Anyri   rl   returnrl   )r   typingcastr   )r3   rj   rb   s   ` r   _skip_if_no_route+requires_network.<locals>._skip_if_no_route   s.     
q	& 
	& {{:w//r5   c                   ^  SU 4S jjnU$ )z2Mark a decorator with the "requires_internet" markc                N   > [         R                  R                  T" U 5      5      $ N)r>   r?   requires_network)r3   	decorators    r   rj   Grequires_network.<locals>._decorator_requires_internet.<locals>.wrapper   s    ;;//	!==r5   )r3   r   rm   rl   r9   )rv   rj   s   ` r   _decorator_requires_internet6requires_network.<locals>._decorator_requires_internet   s    
	> r5   )rV   	Exceptionrm   bool)rm   r{   )r3   r   rm   r   )rv   )typing.Callable[[_TestFuncT], _TestFuncT]rm   r|   r9   )rp   rx   rb   rW   s     @@r   ru   ru      s5    
0<	2 ((9::r5   c                 P    [         R                  R                  [        (       + SS9$ )z2Test requires successful resolving of 'localhost.'zCan't resolve localhost.r<   )r>   r?   r@   RESOLVES_LOCALHOST_FQDNr9   r5   r   resolvesLocalhostFQDNr      s'    ;;##)   r5   c                4   ^  [        T 5      SU 4S jj5       nU$ )Nc                    > [         (       d  [        R                  " S5        T" U 0 UD6$ [         R                  " 5         T" U 0 UD6n[         R                  " 5         U$ )Nz'pyopenssl not available, skipping test.)	pyopensslr>   rg   inject_into_urllib3extract_from_urllib3)rh   ri   resulttests      r   rj   withPyOpenSSL.<locals>.wrapper   sQ    yKKAB(((%%'t&v&&&(r5   )rh   rl   ri   rl   rm   r   r   )r   rj   s   ` r   withPyOpenSSLr      s     
4[  Nr5   c                  6   ^  \ rS rSrSU 4S jjrSS jrSrU =r$ )_ListHandler   c                0   > [         TU ]  5         / U l        g rt   )super__init__records)self	__class__s    r   r   _ListHandler.__init__   s    02r5   c                :    U R                   R                  U5        g rt   )r   r0   )r   records     r   emit_ListHandler.emit   s    F#r5   )r   rm   None)r   zlogging.LogRecordrm   r   )__name__
__module____qualname____firstlineno__r   r   __static_attributes____classcell__r   s   @r   r   r      s    3$ $r5   r   c                     ^  \ rS rSr\R
                  4S	U 4S jjjr\S
S j5       rSS jr	SS jr
S
S jr        SS jrSrU =r$ )LogRecorder   c                L   > [         TU ]  5         Xl        [        5       U l        g rt   )r   r   _targetr   _handler)r   targetr   s     r   r   LogRecorder.__init__   s    $r5   c                .    U R                   R                  $ rt   )r   r   r   s    r   r   LogRecorder.records   s    }}$$$r5   c                N    U R                   R                  U R                  5        g rt   )r   
addHandlerr   r   s    r   installLogRecorder.install   s    .r5   c                N    U R                   R                  U R                  5        g rt   )r   removeHandlerr   r   s    r   	uninstallLogRecorder.uninstall   s    ""4==1r5   c                :    U R                  5         U R                  $ rt   )r   r   r   s    r   	__enter__LogRecorder.__enter__  s    ||r5   c                $    U R                  5         g)NF)r   )r   exc_type	exc_value	tracebacks       r   __exit__LogRecorder.__exit__  s     	r5   )r   r   )r   zlogging.Loggerrm   r   )rm   zlist[logging.LogRecord]r   )r   ztype[BaseException] | Noner   zBaseException | Noner   zTracebackType | Nonerm   ztyping.Literal[False])r   r   r   r   loggingrootr   propertyr   r   r   r   r   r   r   r   s   @r   r   r      sg    07 ' '
 % %/2, ( (	
 
 r5   r   c                  2    \ rS rSrSS jrSS jrS	S jrSrg)
ImportBlockerLoaderi  c                    Xl         g rt   	_fullnamer   fullnames     r   r   ImportBlockerLoader.__init__  s    !r5   c                     [        SU S35      eNz
import of z is blocked)ImportErrorr   s     r   load_moduleImportBlockerLoader.load_module  s    Jxj<==r5   c                4    [        SU R                   S35      er   )r   r   r   modules     r   exec_moduleImportBlockerLoader.exec_module  s    Jt~~&6kBCCr5   r   N)r   strrm   r   )r   r   rm   r
   )r   r
   rm   r   )r   r   r   r   r   r   r   r   r9   r5   r   r   r     s    ">Dr5   r   c                  Z    \ rS rSrSrSS jr S	     S
S jjr S	       SS jjrSrg)ImportBlockeri  z
Block Imports

To be placed on ``sys.meta_path``. This ensures that the modules
specified cannot be imported, even if they are a builtin.
c                    Xl         g rt   namestoblock)r   r   s     r   r   ImportBlocker.__init__$  s    (r5   Nc                8    XR                   ;   a  [        U5      $ g rt   )r   r   )r   r   paths      r   find_moduleImportBlocker.find_module'  s     (((&x00r5   c                j    U R                  X5      nUc  g [        R                  R                  X5      $ rt   )r   	importlibr   spec_from_loader)r   r   r   r   loaders        r   	find_specImportBlocker.find_spec.  s1     !!(1>~~..x@@r5   r   )r   r   rm   r   rt   )r   r   r   z#typing.Sequence[bytes | str] | Nonerm   zLoader | None)r   r   r   zSequence[bytes | str] | Noner   zModuleType | Nonerm   zModuleSpec | None)	r   r   r   r   __doc__r   r   r   r   r9   r5   r   r   r     sk    ) JN#F	 %)	
A
A +
A "	
A
 

A 
Ar5   r   c                  Z    \ rS rSrSr\R                  4     SS jjrS	S jrS	S jr	Sr
g)
ModuleStashi;  z
Stashes away previously imported modules

If we reimport a module the data from coverage is lost, so we reuse the old
modules
c                *    Xl         X l        0 U l        g rt   )	namespacemodules_data)r   r   r   s      r   r   ModuleStash.__init__C  s     #,.
r5   c                   U R                   U R                  ;   a<  U R                  R                  U R                   5      U R                  U R                   '   [	        U R                  R                  5       5       HP  nUR                  U R                   S-   5      (       d  M(  U R                  R                  U5      U R                  U'   MR     g N.)r   r   popr   listkeys
startswithr   s     r   stashModuleStash.stashJ  s    >>T\\))-)9)9$..)IDJJt~~&4<<,,./F  #!566%)\\%5%5f%=

6" 0r5   c                n   U R                   R                  U R                  S 5        [        U R                   R	                  5       5       HC  nUR                  U R                  S-   5      (       d  M(  U R                   R                  U5        ME     U R                   R                  U R                  5        g r   )r   r   r   r   r   r   updater   r   s     r   r   ModuleStash.popR  sz    .4<<,,./F  #!566  ( 0 	DJJ'r5   )r   r   r   N)r   r   r   zdict[str, ModuleType]rm   r   r   )r   r   r   r   r   sysr   r   r   r   r   r9   r5   r   r   r   ;  s9     @C{{//'</	/>(r5   r   )r   r   rm   r{   rt   )r(   ztype[ssl.SSLContext] | Nonerm   r{   )r1   ztype[Warning]rm   r   r   )rm   r|   )r   typing.Callable[..., _RT]rm   r   )N
__future__r   rR   importlib.utilr   r   osrA   r   r   rn   r-   collections.abcr   	functoolsr   importlib.abcr   r   importlib.machineryr	   typesr
   r   r>   
brotlicffirF   r   	zstandard_unused_module_zstdrL   urllib3r   urllib3.connectionpoolr   urllib3.exceptionsr   urllib3.utilr   urllib3.contrib.pyopensslcontribr   TYPE_CHECKINGsslTypeVarr   CallableAnyr   rB   r\   VALID_SOURCE_ADDRESSESINVALID_SOURCE_ADDRESSESSHORT_TIMEOUTLONG_TIMEOUTenvironget
DUMMY_POOLr   r*   r~   r4   r:   rC   rG   rI   rM   rO   rf   ru   r   r   Handlerr   r   r   r   r   r9   r5   r   <module>r     s   "    	   
   $  0 * + #+ H  1 * 11 
 nnU^^LVZZ0PQ

 ??	!K K -.GH  89ST  ::>>$2::>>*:;vELG$

  '|4  )4 &1
 # .;b$7?? $ <D& DAN A>(. (I	   F
  H  IsN   G G, 7	G; 
GG GG G)(G),G87G8;HH