mς
­fIc           @   s   d  k  Z  d k l Z d  k Z d  k Z d  k Z d  k Z d  k Z d e  i f d     YZ	 d e  i f d     YZ
 d   Z e d j o e   n d  S(   N(   s   test_supportt   URLTimeoutTestc           B   s)   t  Z d Z d   Z d   Z d   Z RS(   Nf10.0c         C   s   t  i |  i  d  S(   N(   t   sockett   setdefaulttimeoutt   selft   TIMEOUT(   R   (    (    t1   /mit/python/lib/python2.4/test/test_urllib2net.pyt   setUp   s    c         C   s   t  i d   d  S(   N(   R   R   t   None(   R   (    (    R   t   tearDown   s    c         C   s   t  i d  } | i   } d  S(   Ns   http://www.python.org/(   t   urllib2t   urlopent   ft   readt   x(   R   R   R   (    (    R   t   testURLread   s    (   t   __name__t
   __module__R   R   R   R   (    (    (    R   R       s   		t   urlopenNetworkTestsc           B   s2   t  Z d  Z d   Z d   Z d   Z d   Z RS(   s6  Tests urllib2.urlopen using the network.

    These tests are not exhaustive.  Assuming that testing using files does a
    good job overall of some of the basic interface features.  There are no
    tests exercising the optional 'data' and 'proxies' arguments.  No tests
    for transparent redirection have been written.

    setUp is not used for always constructing a connection to
    http://www.python.org/ since there a few tests that don't use that address
    and making a connection is expensive enough to warrant minimizing unneeded
    connections.

    c         C   si   t  i d  } x+ d D]# } |  i t | |  d |  q Wz |  i | i   d  Wd  | i   Xd  S(	   Ns   http://www.python.org/R   t   closet   infot   geturls3   object returned from urlopen lacks the %s attributes   calling 'read' failed(   s   reads   closes   infoR   (	   R	   R
   t   open_urlt   attrR   t   assert_t   hasattrR   R   (   R   R   R   (    (    R   t
   test_basic)   s     ! c         C   sc   t  i d  } z | i   } Wd  | i   |  i t | t	 i
  d  |  i | i   d  Xd  S(   Ns   http://www.python.org/sA   object returned by 'info' is not an instance of mimetools.Messaget   html(   R	   R
   R   R   t   info_objR   R   R   t
   isinstancet	   mimetoolst   Messaget   assertEqualt
   getsubtype(   R   R   R   (    (    R   t	   test_info4   s     
c         C   sG   d } t i |  } z | i   } Wd  | i   X|  i | |  d  S(   Ns   http://www.python.org/(	   t   URLR	   R
   R   R   t
   gotten_urlR   R   R   (   R   R"   R#   R   (    (    R   t   test_geturl@   s     c         C   s   |  i t t i d  d  S(   Ns   http://www.python.invalid/(   R   t   assertRaisest   IOErrorR	   R
   (   R   (    (    R   t   test_bad_addressJ   s    	(   R   R   t   __doc__R   R!   R$   R'   (    (    (    R   R      s
    			
c           C   s!   t  i d  t  i t t  d  S(   Nt   network(   t   test_supportt   requirest   run_unittestR    R   (    (    (    R   t	   test_mainW   s    t   __main__(   t   unittestt   testR*   R   R	   t   syst   osR   t   TestCaseR    R   R-   R   (
   R*   R   R   R    R/   R	   R   R1   R-   R2   (    (    R   t   ?   s   						=	