
    gF                     |   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k7  xs 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
k7  d      Z ej                   ej"                         dk(  xr  ej&                  dkD  xr ej(                  dk  d      Zd Z ej                   e        d      Zd Zd Zd Ze j6                  d        Zy)    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                  B   t         j                  syd } 	 t        j                   t         j                        } | j                  d       	 | | j                          y# t         j                  $ r Y | | j                          yyw xY w# | | j                          w w xY w)NF)z::1r   T)sockethas_ipv6AF_INET6binderrorclose)socks    F/var/www/openai/venv/lib/python3.12/site-packages/tornado/test/util.py_detect_ipv6r   *   s    ?? D}}V__-		* JJL << JJL  JJL s#   4A B0B	 BB	 	Bzipv6 support not presentc                     t               \  } }| j                  d       t        j                         }|j                  d|f       | j	                         \  }}|j                          | j                          |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!   >   sz     +,M4d#MMOM;-.%,,.D+JJLQ00    c                 b    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   s5     N<m<O	-?r"   c                 v    	 | j                   } ||i |S # t        $ r t        j                  d       }Y )w xY w)zqCompatibility shim for unittest.TestCase.subTest.

    Usage: ``with tornado.test.util.subTest(self, x=x):``
    c               ?      K   d  S )N )akws     r   <lambda>zsubTest.<locals>.<lambda>i   s     er"   )subTestAttributeError
contextlibcontextmanager)testargskwargsr4   s       r   r4   r4   a   sG    
F,, D#F##  F++,DEFs    88c               #      K   t        j                         5  t        j                  dt               d ddd       y# 1 sw Y   yxY ww)z/Context manager to ignore deprecation warnings.ignoreN)warningscatch_warningssimplefilterDeprecationWarningr0   r"   r   ignore_deprecationrA   m   s3      
	 	 	"h(:; 
#	"	"s   A?	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      sK    	   
     ,GGw2#,,(24G x

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