ó
Ø[c           @` sė  d  d l  m Z m Z m 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 d  d l m Z e j e j d k p± e j d k d  Z e j d e j k d	  Z e j d
 e j k d  Z e j d e j k d  Z e j e j d k  d  Z e j e j d k  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(!   i    (   t   absolute_importt   divisiont   print_functionN(   t   bind_unused_port(   t   unittestt   posixt   cygwins   non-unix platformt   TRAVISs!   timing tests unreliable on travist   APPENGINE_RUNTIMEs"   not available on Google App Enginet
   NO_NETWORKs   network access disabledi   s"   PEP 380 (yield from) not availablei   s#   PEP 492 (async/await) not availablet   CPythons   Not CPython implementationt   PyPyi	   s   pypy3 5.8 has buggy ssl modulec          C` ss   t  j s t Sd  }  z? y# t  j  t  j  }  |  j d  Wn t  j k
 rP t SXWd  |  d  k	 rn |  j   n  Xt S(   Ns   ::1i    (   s   ::1i    (	   t   sockett   has_ipv6t   Falset   Nonet   AF_INET6t   bindt   errort   closet   True(   t   sock(    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt   _detect_ipv6.   s    	 	s   ipv6 support not presentc          C` sr   t    \ }  } |  j d  t j   } | j d | f  |  j   \ } } | j   |  j   | j | d f S(   s“   Returns 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.
    i   s	   127.0.0.1(   R   t   setblockingR   t   connectt   acceptR   (   t   server_sockett   portt   client_sockett   connt   client_addr(    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt   refusing_portB   s    


c         B` s,   e  |  |  } i  } e j |  | | U| S(   sæ   Execute ``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.
    (   t   dictt   textwrapt   dedent(   t   caller_globalst   caller_localst   st   global_namespacet   local_namespace(    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt	   exec_testV   s    	c         O` s@   y |  j  } Wn# t k
 r2 t j d    } n X| | |   S(   sq   Compatibility shim for unittest.TestCase.subTest.

    Usage: ``with tornado.test.util.subTest(self, x=x):``
    c          ` s	   d  Vd  S(   N(    (   t   at   kw(    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt   <lambda>m   s    (   t   subTestt   AttributeErrort
   contextlibt   contextmanager(   t   testt   argst   kwargsR,   (    (    s0   lib/python2.7/site-packages/tornado/test/util.pyR,   e   s
    c           c` s,   t  j    t  j d t  d VWd QXd S(   s/   Context manager to ignore deprecation warnings.t   ignoreN(   t   warningst   catch_warningst   simplefiltert   DeprecationWarning(    (    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt   ignore_deprecationq   s    (   i   i   (   i   i   (   i   (   i   i	   (#   t
   __future__R    R   R   R.   t   ost   platformR   t   sysR!   R4   t   tornado.testingR   R   t   skipIft   namet   skipIfNonUnixt   environt   skipOnTravist   skipOnAppEnginet   skipIfNoNetworkt   version_infot   skipBefore33t   skipBefore35t   python_implementationt   skipNotCPythont   pypy_version_infot   skipPypy3V58R   t   skipIfNoIPv6R   R(   R,   R/   R8   (    (    (    s0   lib/python2.7/site-packages/tornado/test/util.pyt   <module>   s>   !										