
    [4%eF                     $   d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl	m
Z
  ej        ej        dk    p
ej        dk    d          Z ej        dej        v d          Z ej        dej        v d	          Z ej         ej                    d
k    d          Z ej         ej                    dk    oej        dk    o
ej        dk     d          Zd Z ej         e             d          Zd Zd Zd Ze j        d             ZdS )    N)bind_unused_portposixcygwinznon-unix platformTRAVISz!timing tests unreliable on travis
NO_NETWORKznetwork access disabledCPythonzNot CPython implementationPyPy)   )   	   zpypy3 5.8 has buggy ssl modulec                  T   t           j        sdS d } 	 t          j         t           j                  } |                     d           n.# t           j        $ r Y | |                                  dS dS w xY w	 | |                                  n# | |                                  w w xY wdS )NF)z::1r   T)sockethas_ipv6AF_INET6binderrorclose)socks    1lib/python3.11/site-packages/tornado/test/util.py_detect_ipv6r   *   s    ?  uD}V_--		*<   JJLLLLL  	 JJLLL JJLLLL 4s)   3A B A1B 0A11B B%zipv6 support not presentc                  >   t                      \  } }|                     d           t          j                    }|                    d|f           |                                 \  }}|                                 |                                  |j        |d         fS )zReturns a local port number that will refuse all connections.

    Return value is (cleanup_func, port); the cleanup function
    must be called to free the port to be reused.
    Tz	127.0.0.1   )r   setblockingr   connectacceptr   )server_socketportclient_socketconnclient_addrs        r   refusing_portr!   >   s     +,,M4d###MOOM;-...%,,..D+JJLLLQ00    c                 j    t          | fi |}i }t          t          j        |          ||           |S )zExecute ``s`` in a given context and return the result namespace.

    Used to define functions for tests in particular python
    versions that would be syntax errors in older versions.
    )dictexectextwrapdedent)caller_globalscaller_localssglobal_namespacelocal_namespaces        r   	exec_testr-   R   sB     N<<m<<O		-???r"   c                 n    	 | j         }n%# t          $ r t          j        d           }Y nw xY w ||i |S )zqCompatibility shim for unittest.TestCase.subTest.

    Usage: ``with tornado.test.util.subTest(self, x=x):``
    c               ?      K   d V S )N )akws     r   <lambda>zsubTest.<locals>.<lambda>i   s      eeeer"   )subTestAttributeError
contextlibcontextmanager)testargskwargsr4   s       r   r4   r4   a   s]    
F, F F F+,D,DEEF7D#F###s   
 ,,c               #      K   t          j                    5  t          j        dt                     dV  ddd           dS # 1 swxY w Y   dS )z/Context manager to ignore deprecation warnings.ignoreN)warningscatch_warningssimplefilterDeprecationWarningr0   r"   r   ignore_deprecationrA   m   s       
	 	"	"  h(:;;;                 s   AA	A)r6   osplatformr   sysr&   typingunittestr=   tornado.testingr   skipIfnameskipIfNonUnixenvironskipOnTravisskipIfNoNetworkpython_implementationskipNotCPythonversion_infopypy_version_infoskipPypy3V58r   skipIfNoIPv6r!   r-   r4   r7   rA   r0   r"   r   <module>rT      s       				   



     , , , , , ,Gw2#,(24G  x
?  "(/,"*"<>WXX "H"$$	13O  x"H"$$. '4'&$	   " x<<>>13MNN1 1 1(  	$ 	$ 	$     r"   