
Y]c           @   s  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	 d d e
 Z e j	 d  Z y d  d l Z Wn e k
 r d Z n Xe  j j e  Z e  j j e d  Z e  j j e d  Z d e j f d	     YZ d
 e j f d     YZ d e j f d     YZ d d d     YZ d e j f d     YZ d e j f d     YZ  d e  f d     YZ! d e  f d     YZ" d   Z# d e  f d     YZ$ d   Z% e& d k re%   n  d S(   iN(   t   test_supportt	   mimetoolst
   deprecatedt	   threadings   keycert.pems   keycert2.pemt   LoopbackHttpServerc           B   s    e  Z d  Z d   Z d   Z RS(   s^   HTTP server w/ a few modifications that make it useful for
    loopback testing purposes.
    c         C   s*   t  j j |  | |  |  j j d  d  S(   Ng?(   t   BaseHTTPServert
   HTTPServert   __init__t   sockett
   settimeout(   t   selft   server_addresst   RequestHandlerClass(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR       s    c         C   s,   |  j  j   \ } } | j d  | | f S(   s"   BaseHTTPServer method, overridden.g      $@(   R   t   acceptR	   (   R
   t   requestt   client_address(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   get_request)   s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR      s   		t   LoopbackHttpServerThreadc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s2   Stoppable thread that runs a loopback http server.c         C   sV   t  j j |   t |  _ t  j   |  _ d | _ t d |  |  _	 |  j	 j
 |  _ d  S(   Ns   HTTP/1.0s	   127.0.0.1i    (   s	   127.0.0.1i    (   R   t   ThreadR   t   Falset   _stopt   Eventt   readyt   protocol_versionR   t   httpdt   server_portt   port(   R
   t   request_handler(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   8   s    		c         C   s   t  |  _ |  j   d S(   s.   Stops the webserver if it's currently running.N(   t   TrueR   t   join(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   stopC   s    	c         C   s.   |  j  j   x |  j s) |  j j   q Wd  S(   N(   R   t   setR   R   t   handle_request(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   runK   s    (   R   R   R   R   R!   R$   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   5   s   		t   BasicAuthHandlerc           B   sl   e  Z d  Z d Z d Z d Z d e e f Z e j e  Z	 d   Z
 d   Z d   Z d   Z d	   Z RS(
   s,   Handler for performing Basic Authentication.t   testUsert   testPasst   Tests   %s:%sc         O   s   t  j j |  | |  d  S(   N(   R   t   BaseHTTPRequestHandlerR   (   R
   t   argst   kwargs(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   \   s    c         G   s   d  S(   N(    (   R
   t   formatR*   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   log_message_   s    c         C   s+   |  j  d  |  j d d  |  j   d  S(   Ni   s   Content-types	   text/html(   t   send_responset   send_headert   end_headers(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   do_HEADc   s    c         C   sB   |  j  d  |  j d d |  j  |  j d d  |  j   d  S(   Ni  s   WWW-Authenticates   Basic realm="%s"s   Content-types	   text/html(   R.   R/   t   REALMR0   (   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   do_AUTHHEADh   s    c         C   su   |  j  j d  d  k r5 |  j   |  j j d  n< |  j  j d  d |  j k rg |  j j d  n
 |  j   d  S(   Nt   Authorizations   No Auth Header Receiveds   Basic s	   It works!(   t   headerst	   getheadert   NoneR3   t   wfilet   writet   ENCODED_AUTH(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   do_GETn   s    
	(   R   R   R   t   USERt   PASSWDR2   t   USER_PASSWDt   base64t	   b64encodeR:   R   R-   R1   R3   R;   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR%   S   s   				t   DigestAuthHandlerc           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(
   s-   Handler for performing digest authentication.c         C   s1   d |  _  g  |  _ i  |  _ d |  _ d |  _ d  S(   Ni    s
   Test Realmt   auth(   t   _request_numt   _noncest   _userst   _realm_namet   _qop(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   }   s
    				c         C   s   | |  _  d  S(   N(   RG   (   R
   t   qop(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   set_qop   s    c         C   s"   t  | t  s t  | |  _ d  S(   N(   t
   isinstancet   dictt   AssertionErrorRE   (   R
   t   users(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt	   set_users   s    c         C   s   | |  _  d  S(   N(   RF   (   R
   t   realm(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt	   set_realm   s    c         C   sA   |  j  d 7_  t j t |  j    j   } |  j j |  | S(   Ni   (   RC   t   hashlibt   md5t   strt	   hexdigestRD   t   append(   R
   t   nonce(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   _generate_nonce   s    c         C   s   | j  d  } | | d } | j d  } i  } xu | D]m } | j d  \ } } | j   } | d d k r | d d k r | d d !} n | j   } | | | <q9 W| S(   Nt    i   t   ,t   =i    t   "i(   t   findt   splitt   strip(   R
   t   auth_strt   first_space_indext   partst	   auth_dictt   partt   namet   value(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   _create_auth_dict   s     c         C   s   i  } | j  |  | | d <| | d <| | d <d | } t j |  j   } d | } t j |  j   }	 | | d <|	 | d <d | }
 t j |
  j   } | | d	 k S(
   Nt   passwordt   methodt   uris#   %(username)s:%(realm)s:%(password)ss   %(method)s:%(uri)st   HA1t   HA2s3   %(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)st   response(   t   updateRQ   RR   RT   (   R
   Rb   Rg   Rh   Ri   t
   final_dictt   HA1_strRj   t   HA2_strRk   t   response_strRl   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   _validate_auth   s    






c         C   sg   | j  d d  | j d d  | j d d |  j |  j |  j   f  | j   | j j d  t S(   Ni  s   Proxy Authentication Requireds   Content-Types	   text/htmls   Proxy-Authenticates(   Digest realm="%s", qop="%s",nonce="%s", s   Proxy Authentication Required.(	   R.   R/   RF   RG   RW   R0   R8   R9   R   (   R
   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   _return_auth_challenge   s    
c         C   s  t  |  j  d k r t Sd | j k r5 |  j |  S|  j | j d  } | d |  j k rr |  j | d } n |  j |  S| j d  |  j k r |  j |  S|  j j | d  t	 } x> | j
 | j g D]* } |  j | | | j |  r t } q q W| s|  j |  St Sd S(   s  Performs digest authentication on the given HTTP request
        handler.  Returns True if authentication was successful, False
        otherwise.

        If no users have been set, then digest auth is effectively
        disabled and this method will always return True.
        i    s   Proxy-Authorizationt   usernameRV   N(   t   lenRE   R   R5   Rs   Rf   t   getRD   t   removeR   t   patht
   short_pathRr   t   command(   R
   R   Rb   Rg   t   auth_validatedRx   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR#      s,    			(   R   R   R   R   RI   RN   RP   RW   Rf   Rr   Rs   R#   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyRA   z   s   								t   FakeProxyHandlerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s   This is a 'fake proxy' that makes it look like the entire
    internet has gone down due to a sudden zombie invasion.  It main
    utility is in providing us with authentication support for
    testing.
    c         O   s#   | |  _  t j j |  | |  d  S(   N(   t   digest_auth_handlerR   R)   R   (   R
   R}   R*   R+   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR      s    	c         G   s   d  S(   N(    (   R
   R,   R*   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR-     s    c         C   s   t  j  |  j d  \ } } } } } } | |  _ |  j j |   r |  j d d  |  j d d  |  j   |  j j	 d |  j  |  j j	 d  n  d  S(   Nt   httpi   t   OKs   Content-Types	   text/htmls   You've reached %s!<BR>sF   Our apologies, but our server is down due to a sudden zombie invasion.(
   t   urlparseRx   Ry   R}   R#   R.   R/   R0   R8   R9   (   R
   t   scmt   netlocRx   t   paramst   queryt   fragment(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR;     s    !	
(   R   R   R   R   R-   R;   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR|      s   		t   BaseTestCasec           B   s   e  Z d    Z d   Z RS(   c         C   s   t  j   |  _ d  S(   N(   R    t   threading_setupt   _threads(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   setUp  s    c         C   s   |  j    t j |  j   d  S(   N(   t
   doCleanupsR    t   threading_cleanupR   (   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   tearDown  s    
(   R   R   R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s   	t   BasicAuthTestsc           B   s;   e  Z d  Z d Z d Z d Z d   Z d   Z d   Z RS(   R&   R'   t	   IncorrectR(   c         C   sr   t  t |   j   d   } t |  |  _ d |  j j |  _ |  j j   |  j j j	   |  j
 |  j j  d  S(   Nc          _   s   t  |  |   S(   N(   R%   (   R*   R+   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt#   http_server_with_basic_auth_handler&  s    s   http://127.0.0.1:%s(   t   superR   R   R   t   serverR   t
   server_urlt   startR   t   waitt
   addCleanupR!   (   R
   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   #  s    	c         C   s   t  j   } | j |  j |  j |  j |  j  t  j t  j |   y |  j	 t  j
 |  j   Wn@ t  j k
 r |  j d |  j  n t k
 r } |  n Xd  S(   Ns   Basic Auth Failed for url: %s(   t   urllib2t   HTTPBasicAuthHandlert   add_passwordR2   R   R<   R=   t   install_openert   build_openert
   assertTruet   urlopent	   HTTPErrort   failt	   Exception(   R
   t   aht   e(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_basic_auth_success.  s    "c         C   sd   t  j   } | j |  j |  j |  j |  j  t  j t  j |   |  j	 t  j
 t  j |  j  d  S(   N(   R   R   R   R2   R   R<   t   INCORRECT_PASSWDR   R   t   assertRaisesR   R   (   R
   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_basic_auth_httperror9  s
    
(	   R   R   R<   R=   R   R2   R   R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s   		t   ProxyAuthTestsc           B   sM   e  Z d  Z d Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s   http://localhostt   testert   test123t	   TestRealmc            s*  t  t    j   d   }   j | t j j    d t j d <d t j d <t     _   j j	 i   j
   j 6   j j   j    f d   } t |    _   j j     j j j     j   j j  d   j j } t j i | d 6 } t j     _ t j |   j    _ d  S(   Nc         S   s!   t  j j   t  j j |   d  S(   N(   t   ost   environt   clearRm   (   t   old_environ(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   restore_environK  s    t    t   NO_PROXYt   no_proxyc             s   t    j |  |  S(   N(   R|   R}   (   R*   R+   (   R
   (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   create_fake_proxy_handlerV  s    s   http://127.0.0.1:%dR~   (   R   R   R   R   R   R   t   copyRA   R}   RN   R=   R<   RP   R2   R   R   R   R   R   R!   R   R   t   ProxyHandlert   ProxyDigestAuthHandlert   proxy_digest_handlerR   t   opener(   R
   R   R   t	   proxy_urlt   handler(    (   R
   s+   lib/python2.7/test/test_urllib2_localnet.pyR   H  s"    	c         C   s\   |  j  j |  j |  j |  j |  j d  |  j j d  |  j t	 j
 |  j j |  j  d  S(   Nt   badRB   (   R   R   R2   t   URLR<   R=   R}   RI   R   R   R   R   t   open(   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt-   test_proxy_with_bad_password_raises_httperrorb  s    	c         C   s3   |  j  j d  |  j t j |  j j |  j  d  S(   NRB   (   R}   RI   R   R   R   R   R   R   (   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt,   test_proxy_with_no_password_raises_httperrorj  s    	c         C   sk   |  j  j |  j |  j |  j |  j  |  j j d  |  j j	 |  j  } x | j
   r\ qM W| j   d  S(   NRB   (   R   R   R2   R   R<   R=   R}   RI   R   R   t   readt   close(   R
   t   result(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_proxy_qop_auth_worksp  s    c         C   s   |  j  j |  j |  j |  j |  j  |  j j d  y |  j j	 |  j  } Wn t
 j k
 rj d  } n X| r x | j   r qt W| j   n  d  S(   Ns   auth-int(   R   R   R2   R   R<   R=   R}   RI   R   R   R   t   URLErrorR7   R   R   (   R
   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt0   test_proxy_qop_auth_int_works_or_throws_urlerrory  s    
(   R   R   R   R<   R=   R2   R   R   R   R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR   A  s   					c            s&   d t  j f    f d     Y    S(   Nt   FakeHTTPRequestHandlerc              sM   e  Z d  Z g  Z g  Z d Z d   Z d   Z    f d   Z d   Z	 RS(   s	   TestHTTP/iP   c         S   s)   |  j    } | r% |  j j |  n  d  S(   N(   t	   send_headR8   R9   (   R
   t   body(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR;     s    c         S   sC   |  j  d } |  j j t |   } |  j   |  j j |  d  S(   Ns   Content-Length(   R5   t   rfileR   t   intR;   t   requestsRU   (   R
   t   content_lengtht	   post_data(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   do_POST  s    
c            s   |  j    _ |  j j |  j   j d  \ } } } |  j |  x+ | D]# \ } } |  j | | |  j  qK W| r |  j d d  |  j	   | S|  j	   d  S(   Ni    s   Content-types
   text/plain(
   R5   t   headers_receivedR   RU   Rx   t   popR.   R/   R   R0   (   R
   t   response_codeR5   R   t   headerRe   (   R   t	   responses(    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s    
c         W   s   d  S(   N(    (   R
   R*   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR-     s    (
   R   R   t   server_versionR   R   R   R;   R   R   R-   (    (   R   R   (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s   		(   R   R)   (   R   (    (   R   R   s+   lib/python2.7/test/test_urllib2_localnet.pyt   GetRequestHandler  s    "%t   TestUrlopenc           B   s   e  Z d  Z d   Z d d  Z d   Z d d  Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sG  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.
    c         C   sB   t  j i   } t  j |  } t  j |  t t |   j   d  S(   N(   R   R   R   R   R   R   R   (   R
   t   proxy_handlerR   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s    c         K   s   g  } t  j | | |  } zV | j | j d   | j | j    | j | j d   | j | j    Wd  | j   Xd j |  S(   Ni   i   R   (	   R   R   t   extendt	   readlinesRU   t   readlineR   R   R    (   R
   t   urlt   dataR+   t   lt   f(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s    c         C   sd   t  |  } t |  |  _ |  j j   |  j j j   |  j |  j j  |  j j } | | _ | S(   N(	   R   R   R   R   R   R   R   R!   R   (   R
   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   start_server  s    	c         K   s   t  t d  s |  j d  n  d d l m } | d  k rP d g  d f g } n  t |  } | |  d | | } | j | _ | S(   Nt   HTTPSHandlers   ssl support requiredi(   t   make_https_serveri   s   we care a bitt   handler_class(   t   hasattrR   t   skipTestt   test.ssl_serversR   R7   R   R   (   R
   R   R+   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   start_https_server  s    c         C   s   d } d d
 g d f d g  | f g } |  j  |  } t j d | j  } | j   } | j   |  j | |  |  j | j d d	 g  d  S(   Ns   We got here...i.  t   Locations"   http://localhost:%s/somewhere_elseR   i   s   http://localhost:%s/t   /s   /somewhere_else(   R   s"   http://localhost:%s/somewhere_else(   R   R   R   R   R   R   t   assertEqualR   (   R
   t   expected_responseR   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_redirection  s    
c         C   s   d } |  j  d g  | f g  } y t j d | j  Wn t j k
 rQ } n X|  j d  | j   } | j   |  j | |  |  j | j	 d g  d  S(   Ns   Bad bad bad...i  s   http://localhost:%s/weebles   404 should raise URLErrors   /weeble(
   R   R   R   R   R   R   R   R   R   R   (   R
   R   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_404  s    
c         C   sw   d } |  j  d g  | f g  } t j d | j  } | j   } | j   |  j | |  |  j | j d g  d  S(   Ns   pycon 2008...i   s   http://localhost:%s/bizarres   /bizarre(   R   R   R   R   R   R   R   R   (   R
   R   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_200	  s    
c         C   s}   d } |  j  d g  | f g  } t j d | j d  } | j   } | j   |  j | |  |  j | j d d g  d  S(   Ns   pycon 2008...i   s   http://localhost:%s/bizarres   get=with_feelings   /bizarre(   R   R   R   R   R   R   R   R   (   R
   R   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_200_with_parameters  s    
c         C   sN   |  j    } t j d t  } |  j d | j d | } |  j | d  d  S(   Nt   cafiles   https://localhost:%s/bizarret   contexts   we care a bit(   R   t   sslt   create_default_contextt   CERT_localhostR   R   R   (   R
   R   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt
   test_https  s    c      	   C   s   |  j  d t  } |  j d | j d t } |  j | d  |  j t j   |  j d | j d t Wd  QX|  j  d t  } |  j t	 j
   |  j d | j d t Wd  QXd  S(   Nt   certfiles   https://localhost:%s/bizarreR   s   we care a bit(   R   R   R   R   R   R   R   R   t   CERT_fakehostnameR   t   CertificateError(   R
   R   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_https_with_cafile%  s    	c         C   sI   |  j  d t  } |  j t j   |  j d | j d t Wd  QXd  S(   NR   s   https://localhost:%s/bizarret	   cadefault(   R   R   R   R   R   R   R   R   (   R
   R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_https_with_cadefault5  s    c            s   t  d  k r |  j d  n  t  j s5 |  j d  n  d  g     f d   } t  j t  j  } | j |  |  j d | d t  } t  j	 d t  } |  j
 d | j d | |  j   d d	  d  S(
   Ns   ssl module requireds   SNI support required in OpenSSLc            s   |   d <d  S(   Ni    (    (   t   ssl_sockt   server_namet   initial_context(   t   sni_name(    s+   lib/python2.7/test/test_urllib2_localnet.pyt   cb_sniB  s    R   R   R   s   https://localhost:%si    t	   localhost(   R   R7   R   t   HAS_SNIt
   SSLContextt   PROTOCOL_TLSt   set_servername_callbackR   R   R   R   R   R   (   R
   R   R   R   (    (   R   s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_https_sni<  s    		c         C   sf   |  j  d g  d f g  } t j d | j d i d d 6} t j |  |  j | j d d  d  S(   Ni   s   we don't cares   http://localhost:%s/R5   s   bytes=20-39t   Range(   R   R   t   RequestR   R   R   R   (   R
   R   t   req(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_sending_headersK  s
    c         C   s   |  j  d g  d f g  } t j d | j  } x+ d
 D]# } |  j t | |  d |  q8 Wz |  j | j   d	  Wd  | j   Xd  S(   Ni   s   we don't cares   http://localhost:%sR   R   t   infot   geturls3   object returned from urlopen lacks the %s attributes   calling 'read' failed(   R   R   R	  R
  (   R   R   R   R   R   R   R   R   (   R
   R   t   open_urlt   attr(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt
   test_basicS  s    c         C   sm   |  j  d g  d f g  } t j d | j  } | j   } |  j | t j d  |  j | j	   d  d  S(   Ni   s   we don't cares   http://localhost:%ssA   object returned by 'info' is not an instance of mimetools.Messaget   plain(
   R   R   R   R   R	  t   assertIsInstanceR   t   MessageR   t
   getsubtype(   R
   R   R  t   info_obj(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt	   test_info_  s    c         C   sX   |  j  d g  d f g  } t j d | j  } | j   } |  j | d | j  d  S(   Ni   s   we don't cares   http://localhost:%s(   R   R   R   R   R
  R   (   R
   R   R  R   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_geturli  s    c         C   s'   t  j d  |  j t t j d  d  S(   Nt   networks   http://sadflkjsasf.i.nvali.d./(   R    t   requiresR   t   IOErrorR   R   (   R
   (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_bad_addressr  s    	c         C   s\   d } |  j  d g  | f g  } t j d | j  } x | D] } |  j | |  q> Wd  S(   Ns   pycon 2008...i   s   http://localhost:%s(   R   R   R   R   R   (   R
   R   R   R   t   line(    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   test_iteration  s
    c      	   C   s   d d d d d d g } d j  |  } |  j d g  | f g  } t j d	 | j  } xN t |  D]@ \ } } |  j | | | d
 | t | |  t |  f  qg W|  j | d t |   d  S(   Ns   We
s   got
s   here
s	   verylong i    s   
R   i   s   http://localhost:%ssQ   Fetched line number %s doesn't match expected:
    Expected length was %s, got %si   (   R    R   R   R   R   t	   enumerateR   Ru   (   R
   t   linesR   R   R   t   indexR  (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   ztest_line_iteration  s    %N(   R   R   R   R   R7   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R  R  R  R  (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyR     s(   													
				c           C   s   t  j t t t  d  S(   N(   R    t   run_unittestR   R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt	   test_main  s    t   __main__(    ('   R   R?   R   R   R   t   unittestRQ   t   testR    t   import_moduleR   R   R   R   t   ImportErrorR7   Rx   t   dirnamet   __file__t   hereR    R   R   R   R   R   R   R)   R%   RA   R|   t   TestCaseR   R   R   R   R   R   R   (    (    (    s+   lib/python2.7/test/test_urllib2_localnet.pyt   <module>   s:   
'z 	$I	*		