ó
ŒwÛjc           @   s  d  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 Z d d l	 Z	 d d l
 m Z d d l m Z d „  Z d „  Z d e f d „  ƒ  YZ d	 e j f d
 „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j e f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d e j f d  „  ƒ  YZ d! „  Z e  d" k re ƒ  n  d S(#   s   Regression tests for urllibiÿÿÿÿN(   t   test_support(   t	   b64encodec         C   sC   t  t |  ƒ ƒ d j ƒ  } t | ƒ d k r; d | } n  d | S(   s!   Escape char as RFC 2396 specifiesi   i   s   0%st   %(   t   hext   ordt   uppert   len(   t   chart   hex_repr(    (    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_urllib.pyt	   hexescape   s    c            sK   d t  j f ‡  f d †  ƒ  Y‰ d t j f ‡ f d †  ƒ  Y‰  |  ˆ  _ ˆ  S(   Nt
   FakeSocketc              s8   e  Z ‡  f d  †  Z d „  Z d d „ Z d d „ Z RS(   c            s   | ˆ  _  d  S(   N(   t   buf(   t   selft   data(   t   FakeHTTPConnection(    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_urllib.pyt   sendall   s    c         _   s   |  S(   N(    (   R   t   argst   kwds(    (    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_urllib.pyt   makefile   s    c         S   s    |  j  r d St j j |  | ƒ S(   Nt    (   t   closedt   iot   BytesIOt   read(   R   t   amt(    (    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_urllib.pyR   "   s    	c         S   s    |  j  r d St j j |  | ƒ S(   NR   (   R   R   R   t   readline(   R   t   length(    (    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_urllib.pyR   '   s    	N(   t   __name__t
   __module__R   R   t   NoneR   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_urllib.pyR
      s   	R   c              s   e  Z d  Z ‡  f d †  Z RS(   R   c            s%   ˆ  |  j  ƒ |  _ |  j |  j _ d  S(   N(   t   fakedatat   sockt	   __class__t   fakesock(   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_urllib.pyt   connect1   s    (   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_urllib.pyR   ,   s   (   R   R   t   httplibt   HTTPConnectionR   (   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_urllib.pyt   fakehttp   s    	t   FakeHTTPMixinc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   t  | ƒ t j _ d  S(   N(   R%   R#   t   HTTPt   _connection_class(   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_urllib.pyR%   :   s    c         C   s   t  j t  j _ d  S(   N(   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_urllib.pyt
   unfakehttp?   s    (   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_urllib.pyR&   9   s   	t   urlopen_FileTestsc           B   sƒ   e  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(   s©   Test urlopen() opening a temporary file.

    Try to test as much functionality as possible so as to cut down on reliance
    on connecting to the Net for testing.

    c         C   sp   d |  j  j |  _ t t j d ƒ } z | j |  j ƒ Wd | j ƒ  Xt j |  _ t	 j
 d |  j ƒ |  _ d S(   s'   Setup of a temp file to use for testings   test_urllib: %s
t   wbNs   file:%s(   R    R   t   textt   fileR    t   TESTFNt   writet   closet   pathnamet   urllibt   urlopent   returned_obj(   R   t   FILE(    (    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_urllib.pyt   setUpK   s    c         C   s!   |  j  j ƒ  t j t j ƒ d S(   s   Shut down the open objectN(   R4   R0   t   ost   removeR    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_urllib.pyt   tearDownV   s    c      	   C   s5   x. d D]& } |  j  t |  j | ƒ d
 | ƒ q Wd  S(   NR   R   t	   readlinest   filenoR0   t   infot   geturlt   getcodet   __iter__s/   object returned by urlopen() lacks %s attribute(	   R   R   R:   R;   R0   R<   R=   R>   R?   (   t
   assertTruet   hasattrR4   (   R   t   attr(    (    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_urllib.pyt   test_interface[   s
    
c         C   s    |  j  |  j |  j j ƒ  ƒ d  S(   N(   t   assertEqualR,   R4   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_urllib.pyt	   test_readc   s    c         C   s<   |  j  |  j |  j j ƒ  ƒ |  j  d |  j j ƒ  d ƒ d  S(   NR   sK   calling readline() after exhausting the file did not return an empty string(   RD   R,   R4   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_urllib.pyt   test_readlinef   s    c         C   sF   |  j  j ƒ  } |  j t | ƒ d d ƒ |  j | d |  j d ƒ d  S(   Ni   s.   readlines() returned the wrong number of linesi    s"   readlines() returned improper text(   R4   R:   RD   R   R,   (   R   t
   lines_list(    (    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_urllib.pyt   test_readlinesl   s
    c         C   sQ   |  j  j ƒ  } |  j | t d ƒ |  j t j | t |  j ƒ ƒ |  j d ƒ d  S(   Ns   fileno() did not return an intsT   Reading on the file descriptor returned by fileno() did not return the expected text(	   R4   R;   t   assertIsInstancet   intRD   R7   R   R   R,   (   R   t   file_num(    (    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_urllib.pyt   test_filenos   s    $c         C   s   |  j  j ƒ  d  S(   N(   R4   R0   (   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_urllib.pyt
   test_closez   s    c         C   s    |  j  |  j j ƒ  t j ƒ d  S(   N(   RI   R4   R<   t	   mimetoolst   Message(   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_urllib.pyt	   test_info   s    c         C   s    |  j  |  j j ƒ  |  j ƒ d  S(   N(   RD   R4   R=   R1   (   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_urllib.pyt   test_geturl‚   s    c         C   s   |  j  |  j j ƒ  d  ƒ d  S(   N(   RD   R4   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_urllib.pyt   test_getcode…   s    c         C   s1   x* |  j  j ƒ  D] } |  j | |  j ƒ q Wd  S(   N(   R4   R?   RD   R,   (   R   t   line(    (    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_urllib.pyt	   test_iterˆ   s    c         C   s!   |  j  t t j d |  j ƒ d  S(   Ns   ./(   t   assertRaisest
   ValueErrorR2   R3   R1   (   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_urllib.pyt   test_relativelocalfile�   s    (   R   R   t   __doc__R6   R9   RC   RE   RF   RH   RL   RM   RP   RQ   RR   RT   RW   (    (    (    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_urllib.pyR*   C   s   												t
   ProxyTestsc           B   s5   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   sR   t  j ƒ  |  _ x< t j j ƒ  D]+ } d | j ƒ  k r |  j j | ƒ q q Wd  S(   Nt   proxy(   R    t   EnvironmentVarGuardt   envR7   t   environt   keyst   lowert   unset(   R   t   k(    (    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_urllib.pyR6   •   s    c         C   s   |  j  j ƒ  |  `  d  S(   N(   R\   t   __exit__(   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_urllib.pyR9   �   s    c         C   sŒ   |  j  j d d ƒ t j ƒ  } |  j d | d ƒ |  j  j d d ƒ |  j t j d ƒ ƒ |  j t j d ƒ ƒ |  j t j d ƒ ƒ d  S(   Nt   NO_PROXYt	   localhostt   nos0   localhost, anotherdomain.com, newdomain.com:1234s   anotherdomain.coms   anotherdomain.com:8888s   newdomain.com:1234(   R\   t   setR2   t   getproxies_environmentRD   R@   t   proxy_bypass_environment(   R   t   proxies(    (    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_urllib.pyt+   test_getproxies_environment_keep_no_proxies¢   s    c         C   sŽ   zf |  j  j d d ƒ t j ƒ  } |  j d | d ƒ |  j  j d d ƒ t j ƒ  } |  j d | ƒ Wd  |  j  j d ƒ |  j  j d ƒ Xd  S(   Nt
   HTTP_PROXYs   http://somewhere:3128t   httpt   REQUEST_METHODt   GET(   R\   Rf   R2   Rg   RD   t   assertNotInR`   (   R   Ri   (    (    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_urllib.pyt   test_proxy_cgi_ignore­   s    c         C   sÞ   t  j } |  j j d d ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ |  j | d	 ƒ ƒ |  j | d
 ƒ ƒ |  j | d ƒ ƒ |  j | d ƒ ƒ d  S(   NRc   s8   localhost, anotherdomain.com, newdomain.com:1234, .d.o.tRd   t	   LocalHostt	   LOCALHOSTs   newdomain.com:1234s	   foo.d.o.ts   anotherdomain.com:8888s   www.newdomain.com:1234t   prelocalhosts   newdomain.coms   newdomain.com:1235(   R2   Rh   R\   Rf   R@   t   assertFalse(   R   t   bypass(    (    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_urllib.pyt(   test_proxy_bypass_environment_host_match¹   s    	(   R   R   R6   R9   Rj   Rp   Rv   (    (    (    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_urllib.pyRY   “   s
   				t   ProxyTests_withOrderedEnvc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s   t  j |  _ t j ƒ  t  _ d  S(   N(   R7   R]   t
   _saved_envt   collectionst   OrderedDict(   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_urllib.pyR6   Ê   s    c         C   s   |  j  t _ d  S(   N(   Rx   R7   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_urllib.pyR9   Ð   s    c         C   sB  d t  j d <d t  j d <|  j t j d ƒ ƒ |  j t j d ƒ ƒ d t  j d <d t  j d <t j ƒ  } |  j i  | ƒ d	 t  j d <d
 t  j d <|  j t j d ƒ ƒ |  j t j d ƒ ƒ |  j t j d ƒ ƒ |  j t j d ƒ ƒ |  j t j d ƒ ƒ d t  j d <d t  j d <t j ƒ  } |  j d | d ƒ d  S(   NR   t   no_proxyRd   t   No_Proxyt	   arbitraryt
   http_proxys   http://somewhere:3128Rk   s%   localhost, noproxy.com, my.proxy:1234s   xyz.coms   noproxy.com:5678s   my.proxy:1234s   my.proxys   http://somewhereelse:3128t
   Http_ProxyRl   (   R7   R]   Rt   R2   Rh   Rg   RD   R@   (   R   Ri   (    (    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_urllib.pyt,   test_getproxies_environment_prefer_lowercaseÓ   s&    (   R   R   R6   R9   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_urllib.pyRw   È   s   		t   urlopen_HttpTestsc           B   sz   e  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(   s.   Test urlopen() opening a fake http connection.c         C   sŠ   |  j  d ƒ zk t j d ƒ } |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ |  j | j ƒ  d ƒ Wd  |  j ƒ  Xd  S(   Ns   Hello!s   http://python.org/R   iÈ   (   R%   R2   R3   RD   R   R=   R>   R)   (   R   t   fp(    (    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_urllib.pyRE   ï   s    c         C   sN   d } |  j  d ƒ z) t j | ƒ } |  j | j ƒ  | ƒ Wd  |  j ƒ  Xd  S(   Ns-   http://docs.python.org/library/urllib.html#OKs   Hello!(   R%   R2   R3   RD   R=   R)   (   R   t   urlR‚   (    (    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_urllib.pyt   test_url_fragmentú   s    c         C   s‰   x‚ t  d d ƒ t  d d ƒ D]d } t | ƒ } d | } |  j d ƒ z- t j d | ƒ } |  j | | j ƒ  ƒ Wd  |  j ƒ  Xq Wd  S(   Ni    i!   i   i   s   //localhost:7777/test%s/s   HTTP/1.1 200 OK

Hello.s   http:(   t   ranget   chrR%   R2   R3   Ro   R=   R)   (   R   t   char_noR   t   schemeless_urlt   resp(    (    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_urllib.pyt#   test_url_with_control_char_rejected  s    #
c         C   sŒ   |  j  d ƒ d } d | d } zY t j d | ƒ } |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ |  j d | j ƒ  ƒ Wd  |  j ƒ  Xd  S(	   Ns   HTTP/1.1 200 OK

Hello.s:   localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123s   //s   :8080/test/?test=as   http:t    s   s   
(   R%   R2   R3   Ro   R=   R)   (   R   t   hostRˆ   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_urllib.pyt/   test_url_with_newline_header_injection_rejected  s    c         C   s9   |  j  d ƒ z |  j t t j d ƒ Wd  |  j ƒ  Xd  S(   NsÎ   HTTP/1.1 401 Authentication Required
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Type: text/html; charset=iso-8859-1
s   http://python.org/(   R%   RU   t   IOErrorR2   R3   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_urllib.pyt   test_read_bogus  s
    c         C   sO   |  j  d ƒ z0 d } |  j t | ƒ � t j d ƒ Wd  QXWd  |  j ƒ  Xd  S(   NsÒ   HTTP/1.1 302 Found
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Location: file:README
Connection: close
Content-Type: text/html; charset=iso-8859-1
s   Redirection to url 'file:s   http://python.org/(   R%   t   assertRaisesRegexpRŽ   R2   R3   R)   (   R   t   msg(    (    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_urllib.pyt   test_invalid_redirect*  s    c         C   sY   xR t  t j ƒ  j ƒ D]; } |  j d ƒ z |  j t t j d ƒ Wd  |  j ƒ  Xq Wd  S(   Ns_   HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
s   http://something(	   R…   R2   t   FancyURLopenert   maxtriesR%   RU   RŽ   R3   R)   (   R   t   i(    (    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_urllib.pyt   test_redirect_limit_independent:  s    c         C   s9   |  j  d ƒ z |  j t t j d ƒ Wd  |  j ƒ  Xd  S(   NR   s   http://something(   R%   RU   RŽ   R2   R3   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_urllib.pyt   test_empty_socketH  s    c         C   sË   |  j  t t j d ƒ t j ƒ  \ } } d | j t j j	 d ƒ } |  j
 t j j | ƒ ƒ z t j | ƒ } | j ƒ  Wd  t j | ƒ t j | ƒ X|  j t j j | ƒ ƒ |  j  t t j | ƒ d  S(   Ns"   file://localhost/a/missing/file.pys   file://localhost/t   /(   RU   RŽ   R2   R3   t   tempfilet   mkstempt   replaceR7   t   patht   sepR@   t   existsR0   t   unlinkRt   (   R   t   fdt   tmp_filet   tmp_fileurlR‚   (    (    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_urllib.pyt   test_missing_localfileQ  s    c         C   s   |  j  t t j d ƒ d  S(   Ns$   ftp://localhost/not/existing/file.py(   RU   RŽ   R2   R3   (   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_urllib.pyt   test_ftp_nonexistinga  s    c         C   s¹   |  j  d ƒ zš t j j } t j d ƒ } d t d ƒ } |  j | | j ƒ |  j	 | j
 ƒ  d ƒ |  j	 | j
 ƒ  d ƒ |  j	 | j ƒ  d ƒ |  j	 | j ƒ  d ƒ Wd  |  j ƒ  Xd  S(   Ns   Hello!s   http://user:pass@python.org/s   Authorization: Basic %s
s	   user:passR   iÈ   (   R%   R#   R'   R(   R2   R3   R   t   assertInR   RD   R   R=   R>   R)   (   R   t   fakehttp_wrapperR‚   t   authorization(    (    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_urllib.pyt   test_userpass_inurlf  s    c         C   s¿   |  j  d ƒ z  d } t j j } d t d ƒ } t j | ƒ } |  j | | j ƒ |  j	 | j
 ƒ  d ƒ |  j	 | j
 ƒ  d ƒ |  j | j ƒ  | ƒ |  j	 | j ƒ  d ƒ Wd  |  j ƒ  Xd  S(   Ns   Hello!s   http://a b:c d@python.org/s   Authorization: Basic %s
s   a b:c dR   iÈ   (   R%   R#   R'   R(   R   R2   R3   R¥   R   RD   R   t   assertNotEqualR=   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_urllib.pyt   test_userpass_with_spaces_inurlv  s    (   R   R   RX   RE   R„   RŠ   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_urllib.pyR�   ì   s   		
										t   urlretrieve_FileTestsc           B   st   e  Z d  Z d „  Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z RS(   s(   Test urllib.urlretrieve() on local filesc         C   sr   g  |  _  |  j t j ƒ d |  _ z0 t t j d ƒ } | j |  j ƒ | j ƒ  Wd  y | j ƒ  Wn n XXd  S(   Ns   testing urllib.urlretrieveR+   (   t	   tempFilest   registerFileForCleanUpR    R.   R,   R-   R/   R0   (   R   R5   (    (    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_urllib.pyR6   Œ  s    		  c         C   s3   x, |  j  D]! } y t j | ƒ Wq
 q
 Xq
 Wd  S(   N(   R¬   R7   R8   (   R   t   each(    (    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_urllib.pyR9   ¡  s
      c         C   s   d t  j t j j | ƒ ƒ S(   Ns	   file://%s(   R2   t   pathname2urlR7   Rœ   t   abspath(   R   t   filePath(    (    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_urllib.pyt   constructLocalFileUrl§  s    R   c         C   sl   t  j ƒ  \ } } z: |  j | ƒ t j | d ƒ } | j | ƒ | j ƒ  Wd y | j ƒ  Wn n XX| S(   s¹   Creates a new temporary file containing the specified data,
        registers the file for deletion during the test fixture tear down, and
        returns the absolute path of the file.R+   N(   R™   Rš   R­   R7   t   fdopenR/   R0   (   R   R   t   newFdt   newFilePatht   newFile(    (    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_urllib.pyt   createNewTempFileª  s      c         C   s   |  j  j | ƒ d  S(   N(   R¬   t   append(   R   t   fileName(    (    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_urllib.pyR­   º  s    c         C   sK   t  j d t j ƒ } |  j | d t j ƒ |  j | d t j d ƒ d  S(   Ns   file:%si    i   sA   did not get a mimetools.Message instance as second returned value(   R2   t   urlretrieveR    R.   RD   RI   RN   RO   (   R   t   result(    (    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_urllib.pyt
   test_basic½  s    c         C   sÄ   d t  j } |  j | ƒ t j |  j t  j ƒ | ƒ } |  j | | d ƒ |  j t j	 j
 | ƒ d ƒ t | d ƒ } z | j ƒ  } | j ƒ  Wd  y | j ƒ  Wn n XX|  j |  j | ƒ d  S(   Ns   %s.2i    s   copy of the file was not madet   rb(   R    R.   R­   R2   Rº   R²   RD   R@   R7   Rœ   Rž   R-   R   R0   R,   (   R   t   second_tempR»   R5   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_urllib.pyt	   test_copyÆ  s      c            sR   d g ‡  f d † } d t  j } ˆ  j | ƒ t j ˆ  j t  j ƒ | | ƒ d  S(   Ni    c            sZ   ˆ  j  |  t ƒ ˆ  j  | t ƒ ˆ  j  | t ƒ ˆ  j |  | d ƒ | d d | d <d  S(   Ni    i   (   RI   RJ   RD   (   t   countt
   block_sizet
   total_sizet   count_holder(   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_urllib.pyt
   hooktesterÚ  s
    s   %s.2(   R    R.   R­   R2   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_urllib.pyt   test_reporthookØ  s
    c         C   so   g  } | d „ } |  j  ƒ  } t j |  j | ƒ t j | ƒ |  j t | ƒ d ƒ |  j | d d d ƒ d  S(   Nc         S   s   | j  |  | | f ƒ d  S(   N(   R¸   (   RÀ   RÁ   RÂ   t   _report(    (    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_urllib.pyRÄ   è  s    i   i    i   (   R·   R2   Rº   R²   R    R.   RD   R   (   R   t   reportRÄ   t   srcFileName(    (    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_urllib.pyt   test_reporthook_0_byteså  s    c         C   sŠ   g  } | d „ } |  j  d ƒ } t j |  j | ƒ t j | ƒ |  j t | ƒ d ƒ |  j | d d d ƒ |  j | d d d ƒ d  S(	   Nc         S   s   | j  |  | | f ƒ d  S(   N(   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_urllib.pyRÄ   ö  s    t   xi   i   i    i   i    t   xxxxx(   R·   R2   Rº   R²   R    R.   RD   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_urllib.pyt   test_reporthook_5_bytesð  s    c         C   sŽ   g  } | d „ } |  j  d d ƒ } t j |  j | ƒ t j | ƒ |  j t | ƒ d ƒ |  j | d d d ƒ |  j | d d d ƒ d  S(	   Nc         S   s   | j  |  | | f ƒ d  S(   N(   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_urllib.pyRÄ     s    RÊ   i   i   i    i   i    i   (   R·   R2   Rº   R²   R    R.   RD   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_urllib.pyt   test_reporthook_8193_bytesÿ  s    (   R   R   RX   R6   R9   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_urllib.pyR«   ‰  s   										t   urlretrieve_HttpTestsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s5   Test urllib.urlretrieve() using fake http connectionsc         C   sK   |  j  d ƒ d „  } z# |  j t j t j d d | ƒWd  |  j ƒ  Xd  S(   NsÑ   HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Length: 100
Content-Type: text/html; charset=iso-8859-1

FF
c         S   s   d  S(   N(    (   t   par1t   par2t   par3(    (    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_urllib.pyt   _reporthook  s    s   http://example.comt
   reporthook(   R%   RU   R2   t   ContentTooShortErrorRº   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_urllib.pyt.   test_short_content_raises_ContentTooShortError  s    	c         C   s<   |  j  d ƒ z |  j t j t j d ƒ Wd  |  j ƒ  Xd  S(   NsÑ   HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Length: 100
Content-Type: text/html; charset=iso-8859-1

FF
s   http://example.com/(   R%   RU   R2   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_urllib.pytA   test_short_content_raises_ContentTooShortError_without_reporthook%  s
    (   R   R   RX   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_urllib.pyRÎ     s   	t   QuotingTestsc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sw  Tests for urllib.quote() and urllib.quote_plus()

    According to RFC 2396 ("Uniform Resource Identifiers), to escape a
    character you write it as '%' + <2 character US-ASCII hex value>.  The Python
    code of ``'%' + hex(ord(<character>))[2:]`` escapes a character properly.
    Case does not matter on the hex letters.

    The various character sets specified are:

    Reserved characters : ";/?:@&=+$,"
        Have special meaning in URIs and must be escaped if not being used for
        their special meaning
    Data characters : letters, digits, and "-_.!~*'()"
        Unreserved and do not need to be escaped; can be, though, if desired
    Control characters : 0x00 - 0x1F, 0x7F
        Have no use in URIs so must be escaped
    space : 0x20
        Must be escaped
    Delimiters : '<>#%"'
        Must be escaped
    Unwise : "{}|\^[]`"
        Must be escaped

    c         C   sw   d j  d d d d g ƒ } t j | ƒ } |  j | | d | | f ƒ t j | ƒ } |  j | | d | | f ƒ d  S(   NR   t   ABCDEFGHIJKLMNOPQRSTUVWXYZt   abcdefghijklmnopqrstuvwxyzt
   0123456789s   _.-s   using quote(): %s != %ss   using quote_plus(): %s != %s(   t   joinR2   t   quoteRD   t
   quote_plus(   R   t   do_not_quoteR»   (    (    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_urllib.pyt   test_never_quoteN  s    	c         C   s   |  j  t j j d d ƒ d  S(   Ni    R˜   (   RD   R2   RÜ   t   func_defaults(   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_urllib.pyt   test_default_safe[  s    c         C   sn   d } t  j | d | ƒ} |  j | | d | | f ƒ t  j | d | ƒ} |  j | | d | | f ƒ d  S(   Ns   <>t   safes   using quote(): %s != %ss   using quote_plus(): %s != %s(   R2   RÜ   RD   RÝ   (   R   t   quote_by_defaultR»   (    (    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_urllib.pyt	   test_safe_  s    c         C   s\  g  t  d ƒ D] } t | ƒ ^ q } | j d ƒ | j t d ƒ ƒ d j | ƒ } x„ | D]| } t j | ƒ } |  j t | ƒ | d | t | ƒ | f ƒ t j | ƒ } |  j t | ƒ | d | t | ƒ | f ƒ q[ W~ d } d } t j | ƒ } |  j | | d	 | | f ƒ t j | ƒ } |  j | | d
 | | f ƒ |  j	 t
 t j d  ƒ d  S(   Ni    s   <>#%"{}|\^[]`i   R   s1   using quote(): %s should be escaped to %s, not %ss6   using quote_plus(): %s should be escapes to %s, not %ss   ab[]cds
   ab%5B%5Dcds   using quote(): %s != %ss   using quote_plus(): %s != %s(   R…   R†   R¸   RÛ   R2   RÜ   RD   R	   RÝ   RU   t	   TypeErrorR   (   R   t   numt   should_quoteR   R»   t   partial_quotet   expected(    (    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_urllib.pyt   test_default_quotingj  s.    %c         C   sê   t  j d ƒ } |  j | t d ƒ d | t d ƒ f ƒ t  j d ƒ } |  j | d d | ƒ d } | j d t d ƒ ƒ } t  j | ƒ } |  j | | d | | f ƒ | j d d ƒ } t  j | ƒ } |  j | | d | | f ƒ d  S(   NR‹   s   using quote(): %s != %st   +s   using quote_plus(): %s != +s
   a b cd e fs   using quote_plus(): %s != %s(   R2   RÜ   RD   R	   RÝ   R›   (   R   R»   t   givent   expect(    (    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_urllib.pyt   test_quoting_space†  s    c         C   s9   |  j  t j d ƒ d ƒ |  j  t j d d ƒ d ƒ d  S(   Ns   alpha+beta gammas   alpha%2Bbeta+gammaRë   s   alpha+beta+gamma(   RD   R2   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_urllib.pyt   test_quoting_plus™  s    (	   R   R   RX   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_urllib.pyR×   4  s   					t   UnquotingTestsc           B   sD   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sw   Tests for unquote() and unquote_plus()

    See the doc string for quoting_Tests for details on quoting and such.

    c         C   s  g  } x— t  d ƒ D]‰ } t t | ƒ ƒ } t | ƒ } t j | ƒ } |  j | | d | | f ƒ t j | ƒ } |  j | | d | | f ƒ | j | ƒ q Wd j | ƒ } ~ t j | ƒ } |  j | j	 d ƒ d d | ƒ t j | ƒ } |  j | j	 d ƒ d d | ƒ d  S(	   Ni€   s   using unquote(): %s != %ss   using unquote_plus(): %s != %sR   R   i   s-   using quote(): not all characters escaped; %ss/   using unquote(): not all characters escaped: %s(
   R…   R	   R†   R2   t   unquoteRD   t   unquote_plusR¸   RÛ   RÀ   (   R   t   escape_listRæ   Rì   Rí   R»   t   escape_string(    (    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_urllib.pyt   test_unquoting¦  s,    c         C   s¬   d } | } t  j | ƒ } |  j | | d | | f ƒ d } | } t  j | ƒ } |  j | | d | | f ƒ d } | } t  j | ƒ } |  j | | d | | f ƒ d  S(   Ns   %xabs   using unquote(): %r != %rs   %xR   (   R2   Rñ   RD   (   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_urllib.pyt   test_unquoting_badpercent¿  s    c         C   s<   d } d } t  j | ƒ } |  j | | d | | f ƒ d  S(   Ns   %Ab%eAs   «ês   using unquote(): %r != %r(   R2   Rñ   RD   (   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_urllib.pyt   test_unquoting_mixed_caseÑ  s
    c         C   sr   d t  d ƒ } d } t j | ƒ } |  j | | d | | f ƒ t j | ƒ } |  j | | d | | f ƒ d  S(   Ns   ab%sdt   ct   abcds   using quote(): %s != %ss   using unquote_plus(): %s != %s(   R	   R2   Rñ   RD   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_urllib.pyt   test_unquoting_partsÙ  s    c         C   sz   d } | } t  j | ƒ } |  j | | d | | f ƒ | j d d ƒ } t  j | ƒ } |  j | | d | | f ƒ d  S(   Ns   are+there+spaces...s   using unquote(): %s != %sRë   R‹   s   using unquote_plus(): %s != %s(   R2   Rñ   RD   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_urllib.pyt   test_unquoting_pluså  s    c         C   s#   t  j d ƒ } |  j | d ƒ d  S(   Nu"   br%C3%BCckner_sapporo_20050930.docu    brÃƒÂ¼ckner_sapporo_20050930.doc(   R2   Rñ   RD   (   R   t   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_urllib.pyt   test_unquote_with_unicodeñ  s    (	   R   R   RX   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_urllib.pyRð   Ÿ  s   					t   urlencode_Testsc           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Tests for urlencode()c   	      C   s  d d d g } t  j | ƒ } x. | D]& } |  j | | d | | | f ƒ q% W|  j | j d ƒ d d | | j d ƒ f ƒ | j d ƒ } | | d } | | d } |  j | j ƒ  oÄ | j ƒ  d	 | | f ƒ |  j t | ƒ d d | t | ƒ d f ƒ d S(   s  Helper method for testing different input types.

        'given' must lead to only the pairs:
            * 1st, 1
            * 2nd, 2
            * 3rd, 3

        Test cannot assume anything about order.  Docs make no guarantee and
        have possible dictionary input.

        s   1st=1s   2nd=2s   3rd=3s   testing %s: %s not found in %st   &i   s#   testing %s: expected 2 '&'s; got %si   s1   testing %s: '&' not located in proper place in %si   i   s5   testing %s: unexpected number of characters: %s != %sNi   i   i   i   (	   R2   t	   urlencodeR¥   RD   RÀ   t   indexR@   t   isdigitR   (	   R   Rì   t	   test_typet   expect_somewhereR»   Ré   t   amp_locationt   on_amp_leftt   on_amp_right(    (    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_urllib.pyt   help_inputtypeø  s$    c         C   s)   |  j  i d d 6d d 6d d 6d ƒ d  S(   Nt   1t   1stt   2t   2ndt   3t   3rds   using dict as input type(   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_urllib.pyt   test_using_mapping  s    c         C   s   |  j  d d	 d
 g d ƒ d  S(   NR
  R	  R  R  R  R  s*   using sequence of two-item tuples as input(   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_urllib.pyt   test_using_sequence  s    c         C   s~   i d d 6} d t  d ƒ t  d ƒ f } t j | ƒ } |  j | | ƒ i d d 6} d } t j | ƒ } |  j | | ƒ d  S(   Nt   =Rÿ   s   %s=%ss   A bunch of plusess   key names   key+name=A+bunch+of+pluses(   R	   R2   R   RD   (   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_urllib.pyt   test_quoting"  s    c         C   sÅ   i d d d g d 6} d t  j t d d d g ƒ ƒ } t  j | ƒ } |  j | | ƒ t  j | t ƒ } x, | d D]  } d | } |  j | | ƒ qt W|  j | j d ƒ d d | j d ƒ ƒ d  S(	   NR	  R  R  t   sequences   sequence=%sRÿ   i   s   Expected 2 '&'s, got %s(   R2   RÝ   t   strR   RD   t   TrueR¥   RÀ   (   R   Rì   Rí   R»   t   value(    (    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_urllib.pyt
   test_doseq-  s    "
(   R   R   RX   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_urllib.pyRþ   õ  s   	 			t   Pathname_Testsc           B   sD   e  Z d  Z d „  Z d „  Z e j e j d k d ƒ d „  ƒ Z	 RS(   s&   Test pathname2url() and url2pathname()c         C   s}   t  j j d d d d ƒ } d } t j | ƒ } |  j | | d | | f ƒ t j | ƒ } |  j | | d | | f ƒ d  S(   Nt   partst   oft   aRœ   s   parts/of/a/paths   pathname2url() failed; %s != %ss   url2pathame() failed; %s != %s(   R7   Rœ   RÛ   R2   R¯   RD   t   url2pathname(   R   t   expected_patht   expected_urlR»   (    (    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_urllib.pyR¼   =  s    c         C   s(  t  j j d d d ƒ } d t j d ƒ } t j | ƒ } |  j | | d | | f ƒ | } t j | ƒ } |  j | | d | | f ƒ t  j j d d ƒ } d	 t j d ƒ } t j | ƒ } |  j | | d | | f ƒ d
 } t  j j d d ƒ } t j | ƒ } |  j | | d | | f ƒ d  S(   Nt   needss   quot=ingt   heres   needs/%s/heres   pathname2url() failed; %s != %ss   url2pathname() failed; %s != %ss	   make suret   using_quotes   %s/using_quotes   make+sure/using_unquotes	   make+suret   using_unquote(   R7   Rœ   RÛ   R2   RÜ   R¯   RD   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_urllib.pyR  J  s.    t   win32s'   test specific to the nturl2path libraryc         C   s…   d } d } x: | D]2 } t  j | ƒ } |  j | | d | | f ƒ q Wd } d } t  j | ƒ } |  j | | d | | f ƒ d  S(	   Ns   /C:/s   ///C:/s   /C|//s   C:\s*   nturl2path.url2pathname() failed; %s != %ss
   ///C|/paths   C:\path(   s   /C:/s   ///C:/s   /C|//(   R2   R  RD   (   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_urllib.pyt   test_ntpathe  s    (
   R   R   RX   R¼   R  t   unittestt
   skipUnlesst   syst   platformR$  (    (    (    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_urllib.pyR  :  s
   		t   Utility_Testsc           B   sz   e  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(   s=   Testcase to test the various utility functions in the urllib.c         C   s{   t  j } |  j | d ƒ d	 ƒ |  j | d ƒ d
 ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ d  S(   Ns   type:opaquestringt   typet   opaquestrings   :opaquestrings   type:R   s   type:opaque:strings   opaque:string(   R*  R+  (   NR+  (   Ns   :opaquestring(   R*  R   (   R*  s   opaque:string(   R2   t	   splittypeRD   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_urllib.pyt   test_splittypez  s    	c         C   sé   t  j } |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d	 ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ d  S(    Ns%   //www.example.org:80/foo/bar/baz.htmls   www.example.org:80s   /foo/bar/baz.htmls   //www.example.org:80R   s   //127.0.0.1#@host.coms	   127.0.0.1s   /#@host.coms   //127.0.0.1#@host.com:80s   /#@host.com:80s   //127.0.0.1:80#@host.coms   127.0.0.1:80s   ///files   /files   //example.net/file;s   example.nets   /file;s   //example.net/file?s   /file?s   //example.net/file#s   /file#(   s   www.example.org:80s   /foo/bar/baz.html(   s   www.example.org:80R   (   Ns   /foo/bar/baz.html(   s	   127.0.0.1s   /#@host.com(   s	   127.0.0.1s   /#@host.com:80(   s   127.0.0.1:80s   /#@host.com(   R   s   /file(   s   example.nets   /file;(   s   example.nets   /file?(   s   example.nets   /file#(   R2   t	   splithostRD   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_urllib.pyt   test_splithost‚  s*    	c         C   s{   t  j } |  j | d ƒ d	 ƒ |  j | d ƒ d
 ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ d  S(   Ns   User:Pass@www.python.org:080s	   User:Passs   www.python.org:080s   @www.python.org:080R   s
   User:Pass@s(   User@example.com:Pass@www.python.org:080s   User@example.com:Pass(   s	   User:Passs   www.python.org:080(   R   s   www.python.org:080(   Ns   www.python.org:080(   s	   User:PassR   (   s   User@example.com:Passs   www.python.org:080(   R2   t	   splituserRD   R   (   R   R0  (    (    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_urllib.pyt   test_splituserŸ  s    	c         C   s+  t  j } |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d
 ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d  ƒ |  j | d ƒ d! ƒ |  j | d ƒ d" ƒ |  j | d ƒ d# ƒ |  j | d ƒ d$ ƒ |  j | d ƒ d% ƒ |  j | d ƒ d& ƒ d  S('   Ns   user:abt   usert   abs   user:a
bs   a
bs   user:a	bs   a	bs   user:abs   abs   user:abs   abs   user:abs   abs   user:a:bs   a:bs   user:a bs   a bs	   user 2:abs   user 2s
   user+1:a+bs   user+1s   a+bs   user:R   s   :ab(   R2  R3  (   R2  s   a
b(   R2  s   a	b(   R2  s   ab(   R2  s   ab(   R2  s   ab(   R2  s   a:b(   R2  s   a b(   s   user 2R3  (   s   user+1s   a+b(   R2  R   (   R2  N(   R   R3  (   R2   t   splitpasswdRD   R   (   R   R4  (    (    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_urllib.pyt   test_splitpasswd¬  s    	c         C   s½   t  j } |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d	 ƒ d ƒ d  S(   Ns	   parrot:88t   parrott   88s   parrot:s	   127.0.0.1s   parrot:cheeses   [::1]:88s   [::1]s   :88R   (   R6  R7  (   R6  N(   R6  N(   s	   127.0.0.1N(   s   parrot:cheeseN(   s   [::1]R7  (   s   [::1]N(   R   R7  (   R2   t	   splitportRD   R   (   R   R8  (    (    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_urllib.pyt   test_splitport¾  s    	c         C   sß   t  j } |  j | d ƒ d	 ƒ |  j | d ƒ d
 ƒ |  j | d d ƒ d ƒ |  j | d ƒ d ƒ |  j | d d ƒ d ƒ |  j | d ƒ d ƒ |  j | d d ƒ d ƒ |  j | d ƒ d ƒ |  j | d d ƒ d ƒ d  S(   Ns	   parrot:88R6  iX   iÿÿÿÿi7   s   parrot:s	   127.0.0.1s   parrot:cheese(   R6  iX   (   R6  iÿÿÿÿ(   R6  i7   (   R6  iÿÿÿÿ(   R6  i7   (   s	   127.0.0.1iÿÿÿÿ(   s	   127.0.0.1i7   (   R6  N(   R6  N(   R2   t
   splitnportRD   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_urllib.pyt   test_splitnportÉ  s    	c         C   se   t  j } |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d	 ƒ |  j | d ƒ d
 ƒ d  S(   Ns   http://python.org/fake?foo=bars   http://python.org/fakes   foo=bars   http://python.org/fake?foo=bar?R   s   ?foo=bar(   s   http://python.org/fakes   foo=bar(   s   http://python.org/fake?foo=barR   (   s   http://python.org/fakeN(   R   s   foo=bar(   R2   t
   splitqueryRD   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_urllib.pyt   test_splitqueryÕ  s    	c         C   s{   t  j } |  j | d ƒ d	 ƒ |  j | d ƒ d
 ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ d  S(   Ns   http://example.com?foo=bar#bazs   http://example.com?foo=bart   bazs   http://example.com?foo=bar#R   s   #bazs"   http://example.com?foo=bar#baz#boot   boo(   s   http://example.com?foo=barR>  (   s   http://example.com?foo=barR   (   R   R>  (   s   http://example.com?foo=barN(   s   http://example.com?foo=bar#bazR?  (   R2   t   splittagRD   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_urllib.pyt   test_splittagá  s    	c         C   sŒ   t  j } |  j | d ƒ d d d g f ƒ |  j | d ƒ d d g f ƒ |  j | d ƒ d d d g f ƒ |  j | d ƒ d g  f ƒ d  S(   Ns   /path;attr1=value1;attr2=value2s   /paths   attr1=value1s   attr2=value2s   /path;R   s   ;attr1=value1;attr2=value2(   R2   t	   splitattrRD   (   R   RB  (    (    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_urllib.pyt   test_splitattrí  s    	c         C   s{   t  j } |  j | d ƒ d
 ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ |  j | d ƒ d ƒ d  S(   Ns   foo=bart   foot   bars   foo=R   s   =bart   foobars   foo=bar=bazs   bar=baz(   RD  RE  (   RD  R   (   R   RE  (   RF  N(   RD  s   bar=baz(   R2   t
   splitvalueRD   R   (   R   RG  (    (    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_urllib.pyt   test_splitvalueö  s    	c         C   sB   t  j d ƒ } |  j | d ƒ |  j t t  j t j d ƒ ƒ d  S(   Nu   http://www.python.orgs   http://www.python.orgs#   http://www.python.org/medi\u00e6val(   R2   t   toBytesRD   RU   t   UnicodeErrorR    t   u(   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_urllib.pyt   test_toBytes   s    c         C   s#   t  j d ƒ } |  j | d ƒ d  S(   Ns   <URL:type://host/path>s   type://host/path(   R2   t   unwrapRD   (   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_urllib.pyt   test_unwrap  s    (   R   R   RX   R-  R/  R1  R5  R9  R;  R=  RA  RC  RH  RL  RN  (    (    (    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_urllib.pyR)  v  s   											
	t   URLopener_Testsc           B   s    e  Z d  Z d „  Z d „  Z RS(   s4   Testcase to test the open method of URLopener class.c         C   sU   d t  j f d „  ƒ  Y} |  j | ƒ  j d ƒ d ƒ |  j | ƒ  j d ƒ d ƒ d  S(   Nt   DummyURLopenerc           B   s   e  Z d  „  Z RS(   c         S   s   | S(   N(    (   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_urllib.pyt	   open_spam  s    (   R   R   RQ  (    (    (    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_urllib.pyRP    s   s   spam://example/ /s   //example/%20/s,   spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/s'   //c:|windows%/:=&?~#+!$,;'@()*[]|/path/(   R2   t	   URLopenerRD   t   open(   R   RP  (    (    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_urllib.pyt   test_quoted_open  s    c         C   s®   d t  j f d „  ƒ  Y} xŽ d D]† } |  j t t  j | ƒ |  j t t  j ƒ  j | ƒ |  j t t  j ƒ  j | ƒ |  j t | ƒ  j | ƒ |  j t | ƒ  j | ƒ q  Wd  S(   NRP  c           B   s   e  Z d  „  Z RS(   c         S   s   | S(   N(    (   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_urllib.pyt   open_local_file  s    (   R   R   RU  (    (    (    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_urllib.pyRP    s   s   local_file://examples   local-file://example(   s   local_file://examples   local-file://example(   R2   RR  RU   RŽ   R3   RS  t   retrieve(   R   RP  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_urllib.pyt   test_local_file_open  s    (   R   R   RX   RT  RW  (    (    (    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_urllib.pyRO    s   	c          C   sg   d d  l  }  |  j ƒ  �I |  j d d t ƒ t j t t t t	 t
 t t t t t t t
 t ƒ Wd  QXd  S(   Niÿÿÿÿt   ignores   .*urllib\.urlopen.*Python 3.0(   t   warningst   catch_warningst   filterwarningst   DeprecationWarningR    t   run_unittestR*   R�   R«   RÎ   RY   R×   Rð   Rþ   R  R)  RO  Rw   (   RY  (    (    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_urllib.pyt	   test_mainw  s$    t   __main__(!   RX   Ry   R2   R#   R   R%  R7   R'  RN   R™   t   testR    t   base64R   R	   R%   t   objectR&   t   TestCaseR*   RY   Rw   R�   R«   RÎ   R×   Rð   Rþ   R  R)  RO  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_urllib.pyt   <module>   s:   		 
P5$�…&kVE<•l	