Your IP : 216.73.216.52


Current Path : /opt/alt/python39/lib64/python3.9/test/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/test/__pycache__/test_urllib.cpython-39.opt-2.pyc

a

XC?h��@s6ddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlZzddlZWneyzdZYn0ddlZddlZddlmZmZddlmZddlZdd�Zdad4dd	�Zd
d�Zd5d
d�ZGdd�de�ZGdd�de�Z Gdd�de	j!�Z"Gdd�de	j!�Z#Gdd�de	j!�Z$Gdd�de	j!ee �Z%Gdd�de	j!�Z&Gdd�de	j!�Z'Gdd �d e	j!e�Z(Gd!d"�d"e	j!�Z)Gd#d$�d$e	j!�Z*Gd%d&�d&e	j!�Z+Gd'd(�d(e	j!�Z,Gd)d*�d*e	j!�Z-Gd+d,�d,ee	j!�Z.Gd-d.�d.e	j!�Z/Gd/d0�d0e	j!�Z0Gd1d2�d2e	j!�Z1e2d3k�r2e	�3�dS)6�N)�patch)�support)�url2pathname�pathname2url)�	b64encodecCs4tt|��dd���}t|�dkr,d|}d|S)N��z0%s�%)�hex�ord�upper�len)�charZhex_repr�r�5/opt/alt/python39/lib64/python3.9/test/test_urllib.py�	hexescapesrcCsN|durtjj|d�}nts(t�}|ant}|dur>|�|�S|�||�SdS)N)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datarZopenerrrr�urlopen$s
rcCs<t�dtf��tj��Wd�S1s.0YdS)Nz8FancyURLopener style of invoking requests is deprecated.)r�check_warnings�DeprecationWarningrrrrrrrr4s��rFcs:G�fdd�dtj��G��fdd�dtjj��|�_�S)Ncs@eZdZdZ�fdd�Zdd�Zd
dd�Zdd	d
�Zdd�ZdS)zfakehttp.<locals>.FakeSocketrcs
|�_dS�N)�buf��selfr��FakeHTTPConnectionrr�sendall?sz$fakehttp.<locals>.FakeSocket.sendallc_s|jd7_|S)Nr)�io_refs)r �args�kwdsrrr�makefileBsz%fakehttp.<locals>.FakeSocket.makefileNcSs|jr
dStj�||�S�N�)�closed�io�BytesIO�read)r Zamtrrrr-Fsz!fakehttp.<locals>.FakeSocket.readcSs|jr
dStj�||�Sr()r*r+r,�readline)r Zlengthrrrr.Ksz%fakehttp.<locals>.FakeSocket.readlinecSs(|jd8_|jdkr$tj�|�dS)Nrr)r$r+r,�close�r rrrr/Ps
z"fakehttp.<locals>.FakeSocket.close)N)N)	�__name__�
__module__�__qualname__r$r#r'r-r.r/rr!rr�
FakeSocket<s

r4cs(eZdZdZ�fdd�Z�r$dd�ZdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs�|j�|_|jt|�_dSr)�fakedataZsock�typeZfakesockr0)r4rr�connectZsz,fakehttp.<locals>.FakeHTTPConnection.connectcSsdSrrr0rrrr/csz*fakehttp.<locals>.FakeHTTPConnection.close)r1r2r3rr7r/r)r4�
mock_closerrr"Usr")r+r,�http�client�HTTPConnectionr5)r5r8r)r"r4r8r�fakehttp;sr<c@seZdZddd�Zdd�ZdS)�
FakeHTTPMixinFcCs"t||d�}tjj|_|tj_dS)N�r8)r<r9r:r;�_connection_class)r r5r8Zfake_http_classrrrr<ks
zFakeHTTPMixin.fakehttpcCs|jtj_dSr)r?r9r:r;r0rrr�
unfakehttppszFakeHTTPMixin.unfakehttpN)F)r1r2r3r<r@rrrrr=js
r=c@seZdZdd�Zdd�ZdS)�FakeFTPMixincCs&Gdd�dt�}tjj|_|tj_dS)Nc@s&eZdZd	dd�Zdd�Zdd�ZdS)
z,FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNTcSsdSrr)r �userZpasswd�hostZport�dirsZtimeoutZ
persistentrrr�__init__wsz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__cSst��dfS)Nr)r+r,)r �filer6rrr�retrfile{sz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSsdSrrr0rrrr/~sz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)NT)r1r2r3rErGr/rrrr�FakeFtpWrappervs
�
rH)�objectrr�
ftpwrapper�_ftpwrapper_class)r rHrrr�fakeftpus
zFakeFTPMixin.fakeftpcCs|jtj_dSr)rKrrrJr0rrr�	unfakeftp�szFakeFTPMixin.unfakeftpN)r1r2r3rLrMrrrrrAtsrAc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!S)"�urlopen_FileTestscCsptd|jjd�|_ttjd�}z|�|j�W|��n
|��0tj|_	t
j�|j	�|_
td|j
�|_dS)Nztest_urllib: %s
�ascii�wb�file:%s)�bytes�	__class__r1�textrr�TESTFN�writer/�pathnamer�parse�quote�quoted_pathnamer�returned_obj)r �frrr�setUp�s�zurlopen_FileTests.setUpcCs|j��t�tj�dSr)r[r/�os�removerrUr0rrr�tearDown�s
zurlopen_FileTests.tearDowncCs&dD]}|�t|j|�d|�qdS)N)	r-r.�	readlines�filenor/�info�geturl�getcode�__iter__�/object returned by urlopen() lacks %s attribute)�
assertTrue�hasattrr[�r �attrrrr�test_interface�s��z urlopen_FileTests.test_interfacecCs|�|j|j���dSr)�assertEqualrTr[r-r0rrr�	test_read�szurlopen_FileTests.test_readcCs,|�|j|j���|�d|j��d�dS)Nr)zKcalling readline() after exhausting the file did not return an empty string)rmrTr[r.r0rrr�
test_readline�s�zurlopen_FileTests.test_readlinecCs4|j��}|�t|�dd�|�|d|jd�dS)Nrz.readlines() returned the wrong number of linesrz"readlines() returned improper text)r[rarmr
rT)r Z
lines_listrrr�test_readlines�s
��z urlopen_FileTests.test_readlinescCs:|j��}|�|td�|�t�|t|j��|jd�dS)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text)	r[rb�assertIsInstance�intrmr^r-r
rT)r Zfile_numrrr�test_fileno�s

�zurlopen_FileTests.test_filenocCs|j��dSr)r[r/r0rrr�
test_close�szurlopen_FileTests.test_closecCs|�|jjtjj�dSr)rqr[Zheaders�email�message�Messager0rrr�test_headers�szurlopen_FileTests.test_headerscCs|�|jj|j�dSr)rmr[rrZr0rrr�test_url�szurlopen_FileTests.test_urlcCs|�|jj�dSr)�assertIsNoner[Zstatusr0rrr�test_status�szurlopen_FileTests.test_statuscCs|�|j��tjj�dSr)rqr[rcrurvrwr0rrr�	test_info�szurlopen_FileTests.test_infocCs|�|j��|j�dSr)rmr[rdrZr0rrr�test_geturl�szurlopen_FileTests.test_geturlcCs|�|j���dSr)rzr[rer0rrr�test_getcode�szurlopen_FileTests.test_getcodecCs|jD]}|�||j�qdSr)r[rmrT)r �linerrr�	test_iter�s
zurlopen_FileTests.test_itercCs|�ttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrrWr0rrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r1r2r3r]r`rlrnrorprsrtrxryr{r|r}r~r�r�rrrrrN�s 
	rNc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ProxyTestscCs6t��|_ttj�D]}d|��vr|j�|�qdS)N�proxy)rZEnvironmentVarGuard�env�listr^�environ�lower�unset)r �krrrr]�s
zProxyTests.setUpcCs|j��|`dSr)r��__exit__r0rrrr`�s
zProxyTests.tearDowncCsp|j�dd�tj��}|�d|d�|j�dd�|�tj�d��|�tj�d��|�tj�d��dS)N�NO_PROXY�	localhostZno�0localhost, anotherdomain.com, newdomain.com:1234�anotherdomain.com�anotherdomain.com:8888�newdomain.com:1234)r��setrr�getproxies_environmentrmrh�proxy_bypass_environment�r rrrr�+test_getproxies_environment_keep_no_proxies�s
z6ProxyTests.test_getproxies_environment_keep_no_proxiesc	Cs�zh|j�dd�tj��}|�d|d�|j�dd�tj��}|�d|�W|j�d�|j�d�n|j�d�|j�d�0dS)N�
HTTP_PROXY�http://somewhere:3128r9ZREQUEST_METHOD�GET)r�r�rrr�rm�assertNotInr�r�rrr�test_proxy_cgi_ignore�s

�z ProxyTests.test_proxy_cgi_ignorecCs�tjj}|j�dd�|�|d��|�|d��|�|d��|�|d��|�|d��|�|d��|�|d	��|�|d
��|�|d��|�|d��|�|d
��|�|d��|�|d��|�|d��dS)Nr�z8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr�Z	LocalHostZ	LOCALHOSTz
.localhostr�z.newdomain.com:1234z	foo.d.o.tzd.o.tr�z.anotherdomain.com:8888zwww.newdomain.com:1234Zprelocalhost�
newdomain.comznewdomain.com:1235�rrr�r�r�rh�assertFalse�r Zbypassrrr�(test_proxy_bypass_environment_host_matchs$�z3ProxyTests.test_proxy_bypass_environment_host_matchcCsntjj}|j�dd�|�|d��|�|d��|j�dd�|�|d��|�|d��|�|d��dS)Nr��*r�r�z*, anotherdomain.comr�r�r�rrr�*test_proxy_bypass_environment_always_matchsz5ProxyTests.test_proxy_bypass_environment_always_matchcCsDtjj}|j�dd�|�|d��|�|d��|�|d��dS)Nr�r�z
localhost
zanotherdomain.com:8888
znewdomain.com:1234
)rrr�r�r�r�r�rrr�%test_proxy_bypass_environment_newline(s�z0ProxyTests.test_proxy_bypass_environment_newlineN)
r1r2r3r]r`r�r�r�r�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_t��t_dSr)r^r��
_saved_env�collections�OrderedDictr0rrrr]3szProxyTests_withOrderedEnv.setUpcCs|jt_dSr)r�r^r�r0rrrr`9sz"ProxyTests_withOrderedEnv.tearDowncCsdtjd<dtjd<|�tj�d��|�tj�d��dtjd<dtjd<tj��}|�i|�d	tjd<d
tjd<|�tj�d��|�tj�d��|�tj�d��|�tj�d
��|�tj�d��dtjd<dtjd<tj��}|�d|d�dS)N�Zno_proxyr�ZNo_ProxyZ	arbitraryZ
http_proxyr�r�z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128Z
Http_Proxyr9)	r^r�r�rrr�r�rmrhr�rrr�,test_getproxies_environment_prefer_lowercase<s&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r1r2r3r]r`r�rrrrr�1sr�c@seZdZdd�Zdd�Zdd�Ze�ed�dd	��Z	e�ed�d
d��Z
e�ed�dd
��Ze�ed�dd��Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Ze�ejd&d'�d(d)��Zd*d+�Zd,d-�Zd.d/�Ze�ed�d0d1��Z d2S)3�urlopen_HttpTestscCsv|�d|d�zTtd�}|�|��d�|�|��d�|�|��d�|�|��d�W|��n
|��0dS)NsHTTP/s 200 OK

Hello!�http://python.org/�Hello!r)���r<rrmr.rdrer@)r Zver�fprrr�
check_readXszurlopen_HttpTests.check_readcCsFd}|�d�z(tj�|�}|�|��|�W|��n
|��0dS)Nz-http://docs.python.org/library/urllib.html#OK�HTTP/1.1 200 OK

Hello!)r<rrrrmrdr@)r rr�rrr�test_url_fragmentcs
z#urlopen_HttpTests.test_url_fragmentcCs<|�d�z"td�}|�|jj�W|��n
|��0dS)Nr��http://www.python.org)r<rrhr�Z
will_closer@)r �resprrr�test_willclosems

z urlopen_HttpTests.test_willclosezssl module requiredc	Csttdd��dgD]�}t|�}d|�d�}|�d�z�t|��dd�}tjj}|�	|d	|����"t
j�d
|���Wd�n1s�0Y|�	|d	|����"t
j�d|���Wd�n1s�0Ytd
|���}|�
||���W|��q|��0qdS)Nr�!�z//localhost:7777/test�/�HTTP/1.1 200 OK

Hello.�\�\\�contain control.*�http:�https:)r��range�chrr<�repr�replacer9r:�
InvalidURL�assertRaisesRegexrrrr�rdr@)r �char_nor�schemeless_url�escaped_char_reprr�r�rrr�(test_url_path_with_control_char_rejectedus$

�0
�0z:urlopen_HttpTests.test_url_path_with_control_char_rejectedcCs�|�d�d}d|d}z�tjj}|�|d��"tj�d|���Wd�n1sX0Y|�|d��"tj�d|���Wd�n1s�0Ytd|���}|�d	|�	��|�d
|�	��|�d|�	��W|�
�n
|�
�0dS)Nr�z:localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123�//�:8080/test/?test=az*contain control.*\\r.*(found at least . .)r��contain control.*\\nr�� �
�
)r<r9r:r�r�rrrr�rdr@)r rCr�r�r�rrr�4test_url_path_with_newline_header_injection_rejected�s 
�00zFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejectedc	Cs�ttdd��dgD]�}t|�}d|�d�}|�d�z�t|��dd�}tjj}|�	|d	|����t
d
|���Wd�n1s�0Y|�	|d	|����t
d|���Wd�n1s�0YW|��q|��0qdS)Nrr�r�z//localhostz/test/r�r�r�r�r�r�)r�r�r�r<r�r�r9r:r�r�rr@)r r�rr�r�r�rrr�(test_url_host_with_control_char_rejected�s

�,.z:urlopen_HttpTests.test_url_host_with_control_char_rejectedcCs�|�d�d}d|d}z�tjj}|�|d��td|���Wd�n1sT0Y|�|d��td|���Wd�n1s�0YW|��n
|��0dS)	Nr�zlocalhost
X-injected: header
r�r�zcontain control.*\\rr�r�r�)r<r9r:r�r�rr@)r rCr�r�rrr�4test_url_host_with_newline_header_injection_rejected�s
�,.zFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejectedcCs|�d�dS)Ns0.9�r�r0rrr�
test_read_0_9�szurlopen_HttpTests.test_read_0_9cCs|�d�dS)Ns1.0r�r0rrr�
test_read_1_0�szurlopen_HttpTests.test_read_1_0cCs|�d�dS)Ns1.1r�r0rrr�
test_read_1_1�szurlopen_HttpTests.test_read_1_1cCs8|jddd�z|�ttd�W|��n
|��0dS)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
Tr>r��r<r��OSErrorrr@r0rrr�test_read_bogus�s�z!urlopen_HttpTests.test_read_boguscCsf|jddd�zHd}|�tjj|��td�Wd�n1sB0YW|��n
|��0dS)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://guidocomputer.athome.com:/python/license
Connection: close
Content-Type: text/html; charset=iso-8859-1
Tr>zRedirection to url 'file:r�)r<r�r�error�	HTTPErrorrr@)r �msgrrr�test_invalid_redirect�s�(z'urlopen_HttpTests.test_invalid_redirectc	CsNtt�j�D]<}|jddd�z|�tjjtd�W|�	�q|�	�0qdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
Tr>�http://something)
r�rZmaxtriesr<r�rr�r�rr@)r �irrr�test_redirect_limit_independent�s��z1urlopen_HttpTests.test_redirect_limit_independentcCs4|�d�z|�ttd�W|��n
|��0dS)Nr)r�r�r0rrr�test_empty_sockets
z#urlopen_HttpTests.test_empty_socketcCsV|�tjj��}td�Wd�n1s,0Y|�|jj�|�|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	r�rr��URLErrorrrh�	exception�filename�reason�r �errr�test_missing_localfile	s&z(urlopen_HttpTests.test_missing_localfilec	Cs�t��\}}d|�tjjd�}z\|�tj�|��t|��}|�|�Wd�n1s\0YWt�	|�t�
|�nt�	|�t�
|�0|�tj�|��|�t
jj��t|�Wd�n1s�0YdS)Nzfile://localhost/r�)�tempfile�mkstempr�r^�path�seprh�existsrr/�unlinkr�r�rr�r�)r �fdZtmp_fileZtmp_fileurlZfobjrrr�test_file_notexistss
*
�
z%urlopen_HttpTests.test_file_notexistscCsZd}|�tjj��}t|�Wd�n1s00Y|�|jj�|�|jj	�dS)Nzftp:///path�
r�rr�r�rr�r�r�rhr�)r Ztest_ftp_urlr�rrr�test_ftp_nohosts
&z!urlopen_HttpTests.test_ftp_nohostcCsV|�tjj��}td�Wd�n1s,0Y|�|jj�|�|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.pyr�r�rrr�test_ftp_nonexisting%s&z&urlopen_HttpTests.test_ftp_nonexistingZMAXFTPCACHErcCsH|��z0tj�ddddg�tjjd<td�W|��n
|��0dS)NrB�passr���testzftp://localhost)rLrrrJZftpcacherrMr0rrr�test_ftp_cache_pruning+s

z(urlopen_HttpTests.test_ftp_cache_pruningcCsn|�d�zTtd�}|�|��d�|�|��d�|�|��d�|�|��d�W|��n
|��0dS)N�HTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/r�r)r�r�)r r�rrr�test_userpass_inurl4s
z%urlopen_HttpTests.test_userpass_inurlcCs�|�d�z�d}d�|�}tjj}dt|�d���d�}t|�}|�	||j
�d��|�|��d�|�|��d�|�
|��|�|�|��d	�W|��n
|��0dS)
Nr�za b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8r�r)r�)r<�formatr9r:r;r�encode�decoder�assertInrrmr.ZassertNotEqualrdrer@)r ZuserpassrZfakehttp_wrapperZ
authorizationr�rrr�test_userpass_inurl_w_spaces?s

�z.urlopen_HttpTests.test_userpass_inurl_w_spacescCs<t�dtf��tj��Wd�n1s.0YdS�Nr�)rrrrr�	URLopenerr0rrr�test_URLopener_deprecationRsz,urlopen_HttpTests.test_URLopener_deprecationc	Csvt��}t�dtf��L|�t��"tjj	dd|d�Wd�n1sJ0YWd�n1sh0YdS)Nr�zhttps://localhostz/nonexistent/path)Zcafile�context)
�sslZcreate_default_contextrrrr�r�rrr)r rrrr�test_cafile_and_contextVs�z)urlopen_HttpTests.test_cafile_and_contextN)!r1r2r3r�r�r��unittest�
skipUnlessrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrIrrr�r�r�rrrrrrr�Us:









	

r�c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�urlopen_DataTestscCs`|�tjj�d|_d|_d|_d|_d|_tj�	|j�|_
tj�	|j�|_tj�	|j�|_dS)Nutest data URLs :;,%=& ö Ä sU�PNG


IHDR{@��sRGB���IDAT�c```���?�
o/IEND�B`�zZdata:text/plain;charset=UTF-8,test%20data%20URLs%20%3A%3B%2C%25%3D%26%20%C3%B6%20%C3%84%20zPdata:text/plain;charset=ISO-8859-1;base64,dGVzdCBkYXRhIFVSTHMgOjssJT0mIPYgxCA%3Dz�data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7
QOjdAAAAAXNSR0IArs4c6QAAAA9JREFUCNdj%0AYGBg%2BP//PwAGAQL%2BCm8 vHgAAAABJRU5ErkJggg%3D%3D%0A%20)
�
addCleanuprr�
urlcleanuprT�image�text_url�text_url_base64�	image_urlr�
text_url_resp�text_url_base64_resp�image_url_respr0rrrr]cs�����zurlopen_DataTests.setUpcCs&dD]}|�t|j|�d|�qdS)N)r-r.rar/rcrdrerfrg)rhrirrjrrrrl�s��z urlopen_DataTests.test_interfacecCst|�|j��tjj�|�|j����ddg�|�|j	��dt
t|j���|�t
j�d�����ddg�dS)N)z
text/plainr�)�charsetz
ISO-8859-1zcontent-lengthzdata:,)rzUS-ASCII)rqrrcrurvrwrmr�
get_paramsr�strr
rrrrr0rrrr|�s���zurlopen_DataTests.test_infocCs@|�|j��|j�|�|j��|j�|�|j��|j�dSr)rmrrdrrr
rrr0rrrr}�s
�zurlopen_DataTests.test_geturlcCs0|�|j���t|j�����d�|j�dS�Nr)rmrr-r��dictrcrrTr0rrr�test_read_text�s
��z urlopen_DataTests.test_read_textcCs0|�|j���t|j�����d�|j�dSr)rmrr-r�rrcrrTr0rrr�test_read_text_base64�s
��z'urlopen_DataTests.test_read_text_base64cCs|�|j��|j�dSr)rmrr-rr0rrr�test_read_image�sz!urlopen_DataTests.test_read_imagecCs|�ttjjd�dS)Nzdata:text/plain�r�r�rrrr0rrr�test_missing_comma�sz$urlopen_DataTests.test_missing_commacCs|�ttjjd�dS)Nzdata:;base64,Cg=rr0rrr�test_invalid_base64_data�sz*urlopen_DataTests.test_invalid_base64_dataN)r1r2r3r]rlr|r}rrrrrrrrrr`s	rc@sfeZdZdd�Zdd�Zdd�Zddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�urlretrieve_FileTestscCs�|�tjj�g|_|�tj�d|_z>t	tjd�}|�
|j�|��Wz|��Wq�Yq�0nz|��WnYn00dS)Nstesting urllib.urlretrieverP)r	rrr
�	tempFiles�registerFileForCleanUprrUrTrrVr/)r �FILErrrr]�s	
�zurlretrieve_FileTests.setUpcCs,|jD] }zt�|�WqYq0qdSr)rr^r_)r Zeachrrrr`�s
zurlretrieve_FileTests.tearDowncCsHtj�|�}z|�d�Wnty6t�d��Yn0dtj�	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
r^r��abspathr��UnicodeEncodeErrorrZSkipTestrrr)r ZfilePathrrr�constructLocalFileUrl�sz+urlretrieve_FileTests.constructLocalFileUrlr)cCstt��\}}zF|�|�t�|d�}|�|�|��Wz|��WqpYqp0nz|��WnYn00|S)NrP)r�r�rr^�fdopenrVr/)r rZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s


�z'urlretrieve_FileTests.createNewTempFilecCs|j�|�dSr)r�append)r ZfileNamerrrr�sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj�dtj�}|�|dtj�|�|dtjj	d�dS)NrQrrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrUrmrqrurvrw)r �resultrrr�
test_basic�s
�z urlretrieve_FileTests.test_basiccCs�dtj}|�|�tj�|�tj�|�}|�||d�|�t	j
�|�d�t|d�}z.|�
�}|��Wz|��Wq�Yq�0nz|��WnYn00|�|j|�dS)N�%s.2rzcopy of the file was not made�rb)rrUrrrr'r#rmrhr^r�r�rr-r/rT)r �second_tempr(r rTrrr�	test_copy�s$


��

�zurlretrieve_FileTests.test_copycsBdgf�fdd�	}dtj}��|�tj���tj�||�dS)NrcsH��|t���|t���|t���||d�|dd|d<dS)Nrr)rqrrrm)�block_count�block_read_size�	file_sizeZcount_holderr0rr�
hooktesters
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterr*)rrUrrrr'r#)r r1r,rr0r�test_reporthooks


�z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|��}tj�|�|�tj|�|�t|�d�|�|ddd�dS)NcSs|�|||f�dSr�r&�r.r/r0Z_reportrrrr1szAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr�	r%rrr'r#rrUrmr
�r Zreportr1ZsrcFileNamerrr�test_reporthook_0_bytess�z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|�d�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd�dS)NcSs|�|||f�dSrr3r4rrrr1"szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktestersxxxxxrr�rr5r6rrr�test_reporthook_5_bytess
�z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|fdd�}|�dd�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd	�|�|ddd	�|�|ddd	�dS)
NcSs|�|||f�dSrr3r4rrrr10szDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester�xi �rrri r5r6rrr�test_reporthook_8193_bytes+s�z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r))r1r2r3r]r`r#r%rr)r-r2r7r9r<rrrrr�s
	rc@seZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsc	Cs||�tjj�|�d�dd�}|�tjj��:ztjjt	j
|d�W|��n
|��0Wd�n1sn0YdS)N��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
cSsdSrr)Zpar1Zpar2Zpar3rrr�_reporthookLszYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthook)Z
reporthook�r	rrr
r<r�r�ZContentTooShortErrorr'rZ
TEST_HTTP_URLr@)r r?rrr�.test_short_content_raises_ContentTooShortError?s


�zDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc	Csp|�tjj�|�d�|�tjj��6ztj�t	j
�W|��n
|��0Wd�n1sb0YdS)Nr>r@r0rrr�Atest_short_content_raises_ContentTooShortError_without_reporthookVs
	zWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r1r2r3rArBrrrrr=<sr=c@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�QuotingTestscCsVd�gd��}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nr�)ZABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyz�
0123456789z_.-~�using quote(): %r != %r�using quote_plus(): %r != %r)�joinrrXrYrm�
quote_plus)r Zdo_not_quoter(rrr�test_never_quote�s
�
�zQuotingTests.test_never_quotecCs|�tjjjdd�dS)Nrr�)rmrrXrY�__defaults__r0rrr�test_default_safe�szQuotingTests.test_default_safecCs�d}tjj||d�}|�||d||f�tjj||d�}|�||d||f�tjj|dd�}|�||d||f�tjjdddd	�}tjjddd
d	�}|�||d||f�tjjdddd	�}tjjddd
d	�}|�||d||f�dS)Nz<>��saferErFs<>uaüb�latin-1�ü)�encodingrMr���)rrXrYrmrH)r Zquote_by_defaultr(�expectrrr�	test_safe�s>
����
�����zQuotingTests.test_safec	Cs�dd�td�D�}|�d�|�td��d�|�}|D]\}tj�|�}|�t|�|d|t|�|f�tj�	|�}|�t|�|d|t|�|f�q8~d	}d
}tj�|�}|�||d||f�tj�	|�}|�||d||f�dS)
NcSsg|]}t|��qSr)r�)�.0�numrrr�
<listcomp>�r)z5QuotingTests.test_default_quoting.<locals>.<listcomp>� z
<>#%"{}|\^[]`r�r�z1using quote(): %s should be escaped to %s, not %sz6using quote_plus(): %s should be escapes to %s, not %szab[]cdz
ab%5B%5DcdrErF)
r�r&r�rGrrXrYrmrrH)r Zshould_quoterr(Z
partial_quote�expectedrrr�test_default_quoting�s8

����
�
�z!QuotingTests.test_default_quotingcCs�tj�d�}|�|td�d|td�f�tj�d�}|�|dd|�d}|�dtd��}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nr�rE�+zusing quote_plus(): %r != +z
a b cd e frF)rrXrYrmrrHr�)r r(�givenrRrrr�test_quoting_space�s&��
�
�zQuotingTests.test_quoting_spacecCsX|�tj�d�d�|�tj�dd�d�|�tj�d�d�|�tj�dd�d�dS)Nzalpha+beta gammazalpha%2Bbeta+gammarZzalpha+beta+gammasalpha+beta gamma�+)rmrrXrHr0rrr�test_quoting_plus�s����zQuotingTests.test_quoting_pluscCsfd}d}tj�|�}|�||d||f�|jttjj|dd�tj�|�}|�||d||f�dS)N���ab��%A2%D8ab%FFrErN�rPz"using quote_from_bytes(): %r != %r)rrXrYrmr��	TypeErrorZquote_from_bytes�r r[rRr(rrr�test_quote_bytes�s
����zQuotingTests.test_quote_bytescCs(d}d}tj�|�}|�||d||f�tjj|ddd�}|�||d||f�d}d}tjj|dd�}|�||d||f�d}d	}tj�|�}|�||d||f�d}|jttjj|dd�d}d
}tjj|ddd�}|�||d||f�d}d}tjj|dd
d�}|�||d||f�dS)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFrE�rP�errorsr`rNra�漢字�%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rrXrYrmr�r"rcrrr�test_quote_with_unicode�sT
�
�
�
��
�
�
�
�z$QuotingTests.test_quote_with_unicodecCsbd}d}tjj|dd�}|�||d||f�d}d}tjj|ddd	�}|�||d||f�dS)
Nu¢Ø ÿz
%A2%D8+%FFrNrarFuab漢字 cdzab%3F%3F+cdr�re)rrXrHrmrcrrr�test_quote_plus_with_unicode&s
�
�
�z)QuotingTests.test_quote_plus_with_unicodeN)r1r2r3rIrKrSrYr\r^rdrjrkrrrrrCis
*rCc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�UnquotingTestscCs�g}td�D]f}tt|��}t|�}tj�|�}|�||d||f�tj�|�}|�||d||f�|�|�qd�	|�}~tj�|�}|�|�
d�dd|�|�tt
ftjjd�|�tt
ftjjd�dS)	N��using unquote(): %r != %r�using unquote_plus(): %r != %rr�r	rz/using unquote(): not all characters escaped: %sr)r�rr�rrX�unquoterm�unquote_plusr&rG�countr�rb�AttributeError)r Zescape_listrUr[rRr(Z
escape_stringrrr�test_unquoting=s2
���
��zUnquotingTests.test_unquotingcCs>d}|}tj�|�}|�||d||f�d}|}tj�|�}|�||d||f�d}|}tj�|�}|�||d||f�d}t|d�}tj�|�}|�||d||f�d}t|d�}tj�|�}|�||d||f�d}t|d�}tj�|�}|�||d||f�|�ttftjjd�|�ttftjjd�dS)Nz%xabrnz%xr	rO�"using unquote_to_bytes(): %r != %rr)	rrXrprmrR�unquote_to_bytesr�rbrsrcrrr�test_unquoting_badpercentTsL
�
�
�

�

�

�z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj�|�}|�||d||f�dS)Nz%Ab%eAs��ru�rrXrvrmrcrrr�test_unquoting_mixed_casexs��z(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nzab%sd�cZabcdrEro)rrrXrprmrqrcrrr�test_unquoting_parts�s
�
�z#UnquotingTests.test_unquoting_partscCs\d}|}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nzare+there+spaces...rnrZr�ro)rrXrprmr�rqrcrrr�test_unquoting_plus�s
�
�z"UnquotingTests.test_unquoting_pluscCs�d}d}tj�|�}|�||d||f�tj�d�}d}|�||d||f�d}d}tj�|�}|�||d||f�d}d}tj�|�}|�||d||f�dS)	N�"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docru�	漢%C3%BCs漢üs%A2%D8ab%FFr_s	%A2�ab%FFrxrcrrr�test_unquote_to_bytes�s>��������z$UnquotingTests.test_unquote_to_bytescCsxd}d}tj�|�}|�||d||f�tjj|ddd�}|�||d||f�tjjddd�}d}|�||d||f�d}d	}tj�|�}|�||d||f�d
}d}tj�|�}|�||d||f�tjj|dd
�}|�||d||f�d
}d}tjj|dd
�}|�||d||f�tj�d�}d}|�||d||f�tjjddd�}d}|�||d||f�dS)Nr}ubrückner_sapporo_20050930.docrnrezbr%FCckner_sapporo_20050930.docrNrarhrgz%F3%B1u�r�)rfr��ignorer~u漢üu漢%FC�rrXrprmrcrrr�test_unquote_with_unicode�sb
�
��
�
�
�
�
�
�
�z(UnquotingTests.test_unquote_with_unicodecCs�d}d}tj�|�}|�||d||f�d}d}tj�|�}|�||d||f�d}d}tj�|�}|�||d||f�dS)NsblueberryjamZblueberryjamrnsblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjr�rcrrr�test_unquoting_with_bytes_input�s$
�
�
�z.UnquotingTests.test_unquoting_with_bytes_inputN)r1r2r3rtrwryr{r|rr�r�rrrrrl6s$	:rlc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�urlencode_Testsc		Cs�gd�}tj�|�}|D]}|�||d|||f�q|�|�d�dd||�d�f�|�d�}||d}||d}|�|��o�|��d||f�|�t	|�dd	|t	|�df�dS)
N)z1st=1z2nd=2z3rd=3ztesting %s: %s not found in %s�&rz#testing %s: expected 2 '&'s; got %srz1testing %s: '&' not located in proper place in %s�z5testing %s: unexpected number of characters: %s != %s)
rrX�	urlencoder�rmrr�indexrh�isdigitr
)	r r[Z	test_typeZexpect_somewherer(rXZamp_locationZon_amp_leftZon_amp_rightrrr�help_inputtypes4����
����zurlencode_Tests.help_inputtypecCs|�dddd�d�dS)N�1�2�3)�1st�2nd�3rdzusing dict as input type�r�r0rrr�test_using_mapping,s�z"urlencode_Tests.test_using_mappingcCs|�gd�d�dS)N))r�r�)r�r�)r�r�z*using sequence of two-item tuples as inputr�r0rrr�test_using_sequence1s
�z#urlencode_Tests.test_using_sequencecCs\ddi}dtd�td�f}tj�|�}|�||�ddi}d}tj�|�}|�||�dS)Nr��=z%s=%szkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrXr�rmrcrrr�test_quoting6szurlencode_Tests.test_quotingcCs�dgd�i}dtj�tgd���}tj�|�}|�||�tj�|d�}|dD]}d|}|�||�qR|�|�d�dd|�d��dS)NZsequence)r�r�r�zsequence=%sTr�rzExpected 2 '&'s, got %s)rrXrHrr�rmr�rr)r r[rRr(�valuerrr�
test_doseqAs�zurlencode_Tests.test_doseqcCs,|�dtj�i��|�dtj�g��dSr�rmrrXr�r0rrr�test_empty_sequenceNsz#urlencode_Tests.test_empty_sequencecCs4|�dtj�ddi��|�dtj�ddi��dS)Nza=1�arza=Noner�r0rrr�test_nonstring_valuesRsz%urlencode_Tests.test_nonstring_valuescCsh|�dtj�dddgid��|�dtj�dddgid��t�ddg�}|�d	tj�d|id��dS)
Nza=1&a=2r�rrTz
a=None&a=a)r�r)�brza=a&a=b)rmrrXr�r�r�rrrr�test_nonstring_seq_valuesVs��z)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|�||�d}d}tj�|�}|�||�d}d}tjj|dd	�}|�||�dS)
N�)� �Á�%3F=%3Fr�r�re�
%C2%A0=%C3%81�%A0=%C1rNra�rrXr�rmrcrrr�test_urlencode_encoding^sz'urlencode_Tests.test_urlencode_encodingcCs�d}d}tjj|dddd�}|�||�d}d}tjj|dddd	�}|�||�d}d
}tj�|d�}|�||�d}d}tj�|d�}|�||�d}d
}tjj|ddd�}|�||�d}d}tjj|ddd�}|�||�dS)Nr�r�Tr�r�)�doseqrPrf))r�)rr�z
%3F=1&%3F=%3Frer�))r�)�*r�z%C2%A0=42&%C2%A0=%C3%81r�rNraz%A0=42&%A0=%C1r�rcrrr�test_urlencode_encoding_doseqqs8
�
�z-urlencode_Tests.test_urlencode_encoding_doseqcCs`d}d}tj�|�}|�||�tj�|d�}|�||�d}d}tj�|d�}|�||�dS)N�)��$��$z
%A0%24=%C1%24T))r�)r�r�z%A0%24=42&%A0%24=%C1%24r�rcrrr�test_urlencode_bytes�sz$urlencode_Tests.test_urlencode_bytescCs�d}tjj|dd�}d}|�||�d}tjj|ddd�}d}|�||�d}d}tjj|ddd�}|�||�d}tjj|dd	d
�}d}|�||�d}d}tjj|ddd	d�}d}d}tjj|ddd	d
�}|�||�dS)Nr�z:$rLz	%A0$=%C1$T)r�rM))r�)r��
r�z%A0$=%C1$&%A0$=13&%A0$=42rN)rMrP)r�rMrPr�)r r[r(rRrrr�&test_urlencode_encoding_safe_parameter�s:
���z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r1r2r3r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�	s 
%r�c@sPeZdZdd�Zdd�Ze�ejdkd�dd��Z	e�ejdkd	�d
d��Z
dS)
�Pathname_TestscCs^tj�dddd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)N�partsZofr�r�zparts/of/a/path�pathname2url() failed; %s != %szurl2pathame() failed; %s != %s)r^r�rGrrrrmr)r Z
expected_pathZexpected_urlr(rrrr)�s����zPathname_Tests.test_basiccCs�tj�ddd�}dtj�d�}tj�|�}|�||d||f�|}tj�	|�}|�||d||f�tj�dd�}d	tj�d�}tj�|�}|�||d||f�d
}tj�dd�}tj�	|�}|�||d||f�dS)
NZneedszquot=ing�herez
needs/%s/herer�zurl2pathname() failed; %s != %sz	make sureZusing_quotez%s/using_quotezmake+sure/using_unquotez	make+sureZ
using_unquote)
r^r�rGrrXrYrrrmrrcrrrr��s>��������zPathname_Tests.test_quotingZwin32z*test specific to the nturl2path functions.cCsXd}d}tj�|�}|�||d||f�d}d}tj�|�}|�||d||f�dS)Nz
\\?\C:\dirz	///C:/dirr�z\\?\unc\server\share\dirz/server/share/dir)rrrrmrcrrr�
test_prefixes�s ����zPathname_Tests.test_prefixesz.test specific to the urllib.url2path function.cCsbd}d}|D]&}tj�|�}|�||d||f�qd}d}tj�|�}|�||d||f�dS)N)z/C:/z///C:/z/C|//�C:\z/urllib.request..url2pathname() failed; %s != %sz
///C|/pathzC:\pathz.urllib.request.url2pathname() failed; %s != %s)rrrrm)r r[rRrr(rrr�test_ntpath	s"����zPathname_Tests.test_ntpathN)r1r2r3r)r�rr�sys�platformr�r�rrrrr��s
�
�r�c@seZdZdd�ZdS)�
Utility_TestscCs|�tj��t�dSr)rqrrZthishost�tupler0rrr�
test_thishostszUtility_Tests.test_thishostN)r1r2r3r�rrrrr�sr�c@sPeZdZdd�Zejed�dd��Zejed�dd��Zejed�dd	��Z	d
S)�URLopener_TestscCsnGdd�dtjj�}t�dtf��8|�|��d�d�|�|��d�d�Wd�n1s`0YdS)Nc@seZdZdd�ZdS)z8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenercSs|Srr�r rrrr�	open_spam'szBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spamN)r1r2r3r�rrrr�DummyURLopener&sr�z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrrrrrrmr)r r�rrr�test_quoted_open%s ��
��
��z URLopener_Tests.test_quoted_open)�categorycCs�t���j}tj|d�\}}t�|�dtj�|�}tj�	��
|�\}}|�tj�
|�tj�
|��Wd�n1sx0YdS)N)�dirzfile:)rZtemp_dirr�r�r^r/rrrr�retrievermr��normcase)r Ztmpdirr�ZtmpfileZfileurlr��_rrr�test_urlopener_retrieve_file4s

z,URLopener_Tests.test_urlopener_retrieve_filecCsJd}|�d�|�|j�tj���|�\}}|�tj	�
|�dd�dS)Nzhttp://www.python.org/file.txtr�rz.txt)r<r	r@rrrr�rmr^r��splitext)r rr�r�rrr�test_urlopener_retrieve_remote>s

z.URLopener_Tests.test_urlopener_retrieve_remotecCs�Gdd�dtjj�}dD]f}|�ttjj|�|�ttj��j|�|�ttj��j|�|�t|�j|�|�t|�j|�qdS)Nc@seZdZdd�ZdS)z<URLopener_Tests.test_local_file_open.<locals>.DummyURLopenercSs|Srrr�rrr�open_local_fileJszLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileN)r1r2r3r�rrrrr�Isr�)zlocal_file://examplezlocal-file://example)rrrr�r�rrr�)r r�rrrr�test_local_file_openFsz$URLopener_Tests.test_local_file_openN)
r1r2r3r�rZignore_warningsrr�r�r�rrrrr�"s

	


r�c@seZdZdd�Zdd�ZdS)�RequestTestscCs>tjj}|d�}|�|��d�|di�}|�|��d�dS)Nr�r�ZPOST)rr�Requestrm�
get_method�r r�rrrr�test_default_valuesWs

z RequestTests.test_default_valuescCs�tjj}|ddd�}|�|jd�|�|��d�|didd�}|�|jd�|�|��d�|ddd�}|�|��d�d|_|�|��d�dS)Nr�ZHEAD)�methodr�)rrr�rmr�r�r�rrr�test_with_method_arg^sz!RequestTests.test_with_method_argN)r1r2r3r�r�rrrrr�Tsr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCs4|�td�d�|�td�d�|�td�d�dS)Nz///C|�C:�///C:z///C|/r��rmrr0rrr�test_converting_drive_letternsz.URL2PathNameTests.test_converting_drive_lettercCs$|�td�d�|�td�d�dS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\r�r0rrr�$test_converting_when_no_drive_letterssz6URL2PathNameTests.test_converting_when_no_drive_lettercCs|�td�d�dS)Nz///C|/foo/bar/spam.foo�C:\foo\bar\spam.foor�r0rrr�test_simple_comparexs
�z%URL2PathNameTests.test_simple_comparecCs|�ttd�dS)Nu///è|/)r��IOErrorrr0rrr�test_non_ascii_drive_letter|sz-URL2PathNameTests.test_non_ascii_drive_lettercCs*gd�}|D]}|�tt|��|�qdS)N)r�z\\\C\test\\r�)rmrr�r Z
list_of_pathsr�rrr�test_roundtrip_url2pathnamesz-URL2PathNameTests.test_roundtrip_url2pathnameN)r1r2r3r�r�r�r�r�rrrrr�ls
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs$|�td�d�|�td�d�dS)Nr�r�r��rmrr0rrrr��sz.PathName2URLTests.test_converting_drive_lettercCs4|�td�d�|�td�d�|�td�d�dS)Nz\\\folder\test\�/////folder/test/z\\folder\test\z////folder/test/z
\folder\test\z
/folder/test/r�r0rrrr��s
�
�
�z6PathName2URLTests.test_converting_when_no_drive_lettercCs|�td�d�dS)Nr��///C:/foo/bar/spam.foor�r0rrrr��s
�z%PathName2URLTests.test_simple_comparecCs|�ttd�dS)NzXX:\)r�r�rr0rrr�test_long_drive_letter�sz(PathName2URLTests.test_long_drive_lettercCs*gd�}|D]}|�tt|��|�qdS)N)r�r�r�)rmrrr�rrr�test_roundtrip_pathname2url�sz-PathName2URLTests.test_roundtrip_pathname2urlN)r1r2r3r�r�r�r�r�rrrrr��s
r��__main__)NN)F)4Zurllib.parserZurllib.requestZurllib.errorZhttp.clientr9Z
email.messagerur+rZ
unittest.mockrr�rr^r�ImportErrorr�r�Z
nturl2pathrr�base64rr�rrrrr<rIr=rAZTestCaserNr�r�r�rrr=rCrlr�r�r�r�r�r�r�r1�mainrrrr�<module>sb


/
]L$
M-NTDN2