
    R?gF                        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
  \R                  " \R                  S:g  =(       d    \R                  S:H  S5      r\R                  " S\R                  ;   S5      r\R                  " S\R                  ;   S	5      r\R                  " \R"                  " 5       S
:g  S5      r\R                  " \R"                  " 5       S:H  =(       a%    \R&                  S:  =(       a    \R(                  S:  S5      rS r\R                  " \" 5       (       + S5      rS rS rS r\ R6                  S 5       rg)    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                  V   [         R                  (       d  gS n  [         R                   " [         R                  5      n U R                  S5         U b  U R                  5         g! [         R                   a     U b  U R                  5         ggf = f! U b  U R                  5         f f = f)NF)z::1r   T)sockethas_ipv6AF_INET6binderrorclose)socks    3/usr/lib/python3/dist-packages/tornado/test/util.py_detect_ipv6r   *   s    ?? D}}V__-		* JJL << JJL  JJL s#   5A$ $B8B BB B(zipv6 support not presentc                     [        5       u  pU R                  S5        [        R                  " 5       nUR                  SU45        U R	                  5       u  p4UR                  5         U R                  5         UR
                  US   4$ )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!   >   sv     +,Md#MMOM;-.%,,.DJJLQ00    c                 b    [        U 40 UD6n0 n[        [        R                  " U5      X45        U$ )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   s3     N<m<O	-?r"   c                 z     U R                   nU" U0 UD6$ ! [         a    [        R                  " S 5      n N+f = f)ziCompatibility shim for unittest.TestCase.subTest.

Usage: ``with tornado.test.util.subTest(self, x=x):``
c               ?      #    S v $ )N )akws     r   <lambda>subTest.<locals>.<lambda>i   s     er"   )subTestAttributeError
contextlibcontextmanager)testargskwargsr5   s       r   r5   r5   a   sG    
F,, D#F##  F++,DEFs    !::c               #      #    [         R                  " 5          [         R                  " S[        5        Sv   SSS5        g! , (       d  f       g= f7f)z/Context manager to ignore deprecation warnings.ignoreN)warningscatch_warningssimplefilterDeprecationWarningr0   r"   r   ignore_deprecationrB   m   s2      
	 	 	"h(:; 
#	"	"s   A A	A
AA)r7   osplatformr   sysr&   typingunittestr>   tornado.testingr   skipIfnameskipIfNonUnixenvironskipOnTravisskipIfNoNetworkpython_implementationskipNotCPythonversion_infopypy_version_infoskipPypy3V58r   skipIfNoIPv6r!   r-   r5   r8   rB   r0   r"   r   <module>rU      s;    	   
     ,GGw2#,,(24G 

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