ó
wŪjc           @   s   d  Z  d d l Z d d l m Z e j d  Z d d l Z d d l Z d e j f d     YZ	 d e j f d     YZ
 d	   Z e d
 k r e   n  d S(   s&   Unit tests for socket timeout feature.i’’’’N(   t   test_supportt   networkt   CreationTestCasec           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   s9   Test case for socket.gettimeout() and socket.settimeout()c         C   s   t  j  t  j t  j  |  _ d  S(   N(   t   sockett   AF_INETt   SOCK_STREAMt   sock(   t   self(    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   setUp   s    c         C   s   |  j  j   d  S(   N(   R   t   close(   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   tearDown   s    c         C   s    |  j  |  j j   d  d  d  S(   Ns   timeout not disabled by default(   t   assertEqualR   t
   gettimeoutt   None(   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testObjectCreation   s    c         C   s   |  j  j d  |  j |  j  j   d  |  j  j d  |  j |  j  j   d  |  j  j d   |  j |  j  j   d   d  S(   Ngįz®Ga@i   (   R   t
   settimeoutR   R   R   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testFloatReturnValue   s    c         C   sn   |  j  j d  |  j t |  j  j    t d   |  j  j d  |  j t |  j  j    t d   d  S(   Ni   g      š?g333333@(   R   R   R   t   typeR   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testReturnType&   s    %c         C   sŚ   |  j  j d  |  j  j d  |  j  j d  |  j  j d   |  j t |  j  j d  |  j t |  j  j d  |  j t |  j  j d  |  j t |  j  j g   |  j t |  j  j i   |  j t |  j  j d  d  S(   Ni    l    g        t    u    y                (    (   R   R   R   t   assertRaisest	   TypeError(   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testTypeCheck.   s    c         C   sO   |  j  t |  j j d  |  j  t |  j j d  |  j  t |  j j d  d  S(   Ni’’’’l’’’’ g      šæ(   R   t
   ValueErrorR   R   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testRangeCheck;   s    c         C   sČ   |  j  j d  |  j  j d  |  j |  j  j   d   |  j  j d  |  j |  j  j   d  |  j  j d  |  j  j d  |  j |  j  j   d  |  j  j d  |  j |  j  j   d   d  S(   Ni
   i   i    g        (   R   R   t   setblockingR   R   R   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testTimeoutThenBlockingA   s    c         C   sv   |  j  j d  |  j  j d  |  j |  j  j   d  |  j  j d  |  j  j d  |  j |  j  j   d  d  S(   Ni    i   (   R   R   R   R   R   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testBlockingThenTimeoutO   s    (   t   __name__t
   __module__t   __doc__R   R
   R   R   R   R   R   R   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyR      s   								t   TimeoutTestCasec           B   s¤   e  Z d  Z d Z d   Z d   Z e j e d  d    Z	 d   Z
 d   Z d   Z e j d	  d
    Z e j d	  d    Z e j d	  d    Z RS(   s/   Test case for socket.socket() timeout functionsg       @c         C   s1   t  j  t  j t  j  |  _ d |  _ d |  _ d  S(   Ns   www.python.org.iP   s	   127.0.0.1(   s   www.python.org.iP   (   R   R   R   R   t   addr_remotet	   localhost(   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyR   e   s    	c         C   s   |  j  j   d  S(   N(   R   R	   (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyR
   j   s    s*   need to replace these hosts; see bpo-35518c         C   s   d } d } |  j  j |  t j   } |  j t j |  j  j |  t j   } t | |  } |  j | | |  j	 k  d | |  j	 | f  d  S(   Ns   10.0.0.0i90  gü©ńŅMbP?s<   timeout (%g) is more than %g seconds more than expected (%g)(   s   10.0.0.0i90  (
   R   R   t   timeR   R   t   errort   connectt   abst
   assertTruet   fuzz(   R   t   addrt   _timeoutt   _t1t   _t2t   _delta(    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testConnectTimeoutm   s    c      
   C   s»   d } t  j |  j d   |  j j |  j  |  j j |  t j   } |  j t j	 |  j j
 d  t j   } t | |  } |  j | | |  j k  d | |  j | f  Wd  QXd  S(   Ng{®Gįz?i    i   s2   timeout (%g) is %g seconds more than expected (%g)(   R    t   transient_internetR    R   R$   R   R"   R   R   t   timeoutt   recvR%   R&   R'   (   R   R)   R*   R+   R,   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testRecvTimeout   s    c         C   s®   d } |  j  j |  t j |  j  |  j  |  j  j d  t j   } |  j t j	 |  j  j
  t j   } t | |  } |  j | | |  j k  d | |  j | f  d  S(   Ni   i   s2   timeout (%g) is %g seconds more than expected (%g)(   R   R   R    t	   bind_portR!   t   listenR"   R   R   R#   t   acceptR%   R&   R'   (   R   R)   R*   R+   R,   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testAcceptTimeout   s    c         C   s¼   d } t  j  t  j t  j  |  _ |  j j |  t j |  j |  j  t j   } |  j	 t  j
 |  j j d  t j   } t | |  } |  j | | |  j k  d | |  j | f  d  S(   Ni   i    s2   timeout (%g) is %g seconds more than expected (%g)(   R   R   t
   SOCK_DGRAMR   R   R    R2   R!   R"   R   R#   t   recvfromR%   R&   R'   (   R   R)   R*   R+   R,   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testRecvfromTimeout„   s    s   test not implementedc         C   s   d  S(   N(    (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testSend¶   s    c         C   s   d  S(   N(    (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt
   testSendto¼   s    c         C   s   d  S(   N(    (   R   (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   testSendallĀ   s    (   R   R   R   R'   R   R
   t   unittestt   skipIft   TrueR-   R1   R5   R8   t   skipR9   R:   R;   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyR   Z   s   					c           C   s!   t  j d  t  j t t  d  S(   NR   (   R    t   requirest   run_unittestR   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt	   test_mainÉ   s    t   __main__(   R   R<   t   testR    t   is_resource_enabledt   skip_expectedR"   R   t   TestCaseR   R   RB   R   (    (    (    s   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_timeout.pyt   <module>   s   Mo	