Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.9/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.9/test/__pycache__/test_urllib.cpython-39.opt-2.pyc

a

��g��@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�,/usr/local/lib/python3.9/test/test_urllib.py�	hexescapesrcCsN|durtjj|d�}nts(t�}|ant}|dur>|�|�S|�||�SdS)N)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datar�openerrrr�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!�lengthrrrr/Ksz%fakehttp.<locals>.FakeSocket.readlinecSs(|jd8_|jdkr$tj�|�dS)Nrr)r%r,r-�close�r!rrrr1Ps
z"fakehttp.<locals>.FakeSocket.close)N)N)	�__name__�
__module__�__qualname__r%r$r(r.r/r1rr"rr�
FakeSocket<s

r6cs(eZdZdZ�fdd�Z�r$dd�ZdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs�|j�|_|jt|�_dSr)�fakedata�sock�typeZfakesockr2)r6rr�connectZsz,fakehttp.<locals>.FakeHTTPConnection.connectcSsdSrrr2rrrr1csz*fakehttp.<locals>.FakeHTTPConnection.close)r3r4r5rr:r1r)r6�
mock_closerrr#Usr#)r,r-�http�client�HTTPConnectionr7)r7r;r)r#r6r;r�fakehttp;sr?c@seZdZddd�Zdd�ZdS)�
FakeHTTPMixinFcCs"t||d�}tjj|_|tj_dS)N�r;)r?r<r=r>�_connection_class)r!r7r;Zfake_http_classrrrr?ks
zFakeHTTPMixin.fakehttpcCs|jtj_dSr)rBr<r=r>r2rrr�
unfakehttppszFakeHTTPMixin.unfakehttpN)F)r3r4r5r?rCrrrrr@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!�user�passwd�host�port�dirs�timeoutZ
persistentrrr�__init__wsz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__cSst��dfS)Nr)r,r-)r!�filer9rrr�retrfile{sz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSsdSrrr2rrrr1~sz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)NT)r3r4r5rKrMr1rrrr�FakeFtpWrappervs
�
rN)�objectrr�
ftpwrapper�_ftpwrapper_class)r!rNrrr�fakeftpus
zFakeFTPMixin.fakeftpcCs|jtj_dSr)rQrrrPr2rrr�	unfakeftp�szFakeFTPMixin.unfakeftpN)r3r4r5rRrSrrrrrDtsrDc@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__r3�textrr�TESTFN�writer1�pathnamer�parse�quote�quoted_pathnamer�returned_obj)r!�frrr�setUp�s�zurlopen_FileTests.setUpcCs|j��t�tj�dSr)rar1�os�removerr[r2rrr�tearDown�s
zurlopen_FileTests.tearDowncCs&dD]}|�t|j|�d|�qdS)N)	r.r/�	readlines�filenor1�info�geturl�getcode�__iter__�/object returned by urlopen() lacks %s attribute)�
assertTrue�hasattrra�r!�attrrrr�test_interface�s��z urlopen_FileTests.test_interfacecCs|�|j|j���dSr)�assertEqualrZrar.r2rrr�	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)rsrZrar/r2rrr�
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)rargrsr
rZ)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)	rarh�assertIsInstance�intrsrdr.r
rZ)r!Zfile_numrrr�test_fileno�s

�zurlopen_FileTests.test_filenocCs|j��dSr)rar1r2rrr�
test_close�szurlopen_FileTests.test_closecCs|�|jjtjj�dSr)rwraZheaders�email�message�Messager2rrr�test_headers�szurlopen_FileTests.test_headerscCs|�|jj|j�dSr)rsrarr`r2rrr�test_url�szurlopen_FileTests.test_urlcCs|�|jj�dSr)�assertIsNonera�statusr2rrr�test_status�szurlopen_FileTests.test_statuscCs|�|j��tjj�dSr)rwrarir{r|r}r2rrr�	test_info�szurlopen_FileTests.test_infocCs|�|j��|j�dSr)rsrarjr`r2rrr�test_geturl�szurlopen_FileTests.test_geturlcCs|�|j���dSr)r�rarkr2rrr�test_getcode�szurlopen_FileTests.test_getcodecCs|jD]}|�||j�qdSr)rarsrZ)r!�linerrr�	test_iter�s
zurlopen_FileTests.test_itercCs|�ttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrr]r2rrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r3r4r5rcrfrrrtrurvryrzr~rr�r�r�r�r�r�rrrrrT�s 
	rTc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ProxyTestscCs6t��|_ttj�D]}d|��vr|j�|�qdS)N�proxy)rZEnvironmentVarGuard�env�listrd�environ�lower�unset)r!�krrrrc�s
zProxyTests.setUpcCs|j��|`dSr)r��__exit__r2rrrrf�s
zProxyTests.tearDowncCsp|j�dd�tj��}|�d|d�|j�dd�|�tj�d��|�tj�d��|�tj�d��dS)N�NO_PROXY�	localhost�no�0localhost, anotherdomain.com, newdomain.com:1234�anotherdomain.com�anotherdomain.com:8888�newdomain.com:1234)r��setrr�getproxies_environmentrsrn�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:3128r<ZREQUEST_METHOD�GET)r�r�rrr�rs�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�rn�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)
r3r4r5rcrfr�r�r�r�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_t��t_dSr)rdr��
_saved_env�collections�OrderedDictr2rrrrc3szProxyTests_withOrderedEnv.setUpcCs|jt_dSr)r�rdr�r2rrrrf9sz"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_Proxyr<)	rdr�r�rrr�r�rsrnr�rrr�,test_getproxies_environment_prefer_lowercase<s&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r3r4r5rcrfr�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?rrsr/rjrkrC)r!�ver�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?rrrrsrjrC)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?rrnr�Z
will_closerC)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�replacer<r=�
InvalidURL�assertRaisesRegexrrrr�rjrC)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?r<r=r�r�rrrr�rjrC)r!rGr�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�r<r=r�r�rrC)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?r<r=r�r�rrC)r!rGr�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�r2rrr�
test_read_0_9�szurlopen_HttpTests.test_read_0_9cCs|�d�dS)Ns1.0r�r2rrr�
test_read_1_0�szurlopen_HttpTests.test_read_1_0cCs|�d�dS)Ns1.1r�r2rrr�
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
TrAr��r?r��OSErrorrrCr2rrr�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
TrAzRedirection to url 'file:r�)r?r�r�error�	HTTPErrorrrC)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
TrA�http://something)
r�rZmaxtriesr?r�rr�r�rrC)r!�irrr�test_redirect_limit_independent�s��z1urlopen_HttpTests.test_redirect_limit_independentcCs4|�d�z|�ttd�W|��n
|��0dS)Nr*r�r�r2rrr�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��URLErrorrrn�	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�rd�path�seprn�existsrr1�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�rnr�)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)NrE�passr���testzftp://localhost)rRrrrPZftpcacherrSr2rrr�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)
Nrza b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8r�r*r�)r?�formatr<r=r>r�encode�decoder�assertInrrsr/ZassertNotEqualrjrkrC)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�	URLopenerr2rrr�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!rrrr�test_cafile_and_contextVs�z)urlopen_HttpTests.test_cafile_and_contextN)!r3r4r5r�r�r��unittest�
skipUnlessr
r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrOrrrrrrrrrrrr�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�
urlcleanuprZ�image�text_url�text_url_base64�	image_urlr�
text_url_resp�text_url_base64_resp�image_url_respr2rrrrccs�����zurlopen_DataTests.setUpcCs&dD]}|�t|j|�d|�qdS)N)r.r/rgr1rirjrkrlrm)rnrorrprrrrr�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)rwrrir{r|r}rsr�
get_paramsr�strr
rrrrr2rrrr��s���zurlopen_DataTests.test_infocCs@|�|j��|j�|�|j��|j�|�|j��|j�dSr)rsrrjrrrrrr2rrrr��s
�zurlopen_DataTests.test_geturlcCs0|�|j���t|j�����d�|j�dS�Nr)rsrr.r�dictrirrZr2rrr�test_read_text�s
��z urlopen_DataTests.test_read_textcCs0|�|j���t|j�����d�|j�dSr)rsrr.rrrirrZr2rrr�test_read_text_base64�s
��z'urlopen_DataTests.test_read_text_base64cCs|�|j��|j�dSr)rsrr.rr2rrr�test_read_image�sz!urlopen_DataTests.test_read_imagecCs|�ttjjd�dS)Nzdata:text/plain�r�r�rrrr2rrr�test_missing_comma�sz$urlopen_DataTests.test_missing_commacCs|�ttjjd�dS)Nzdata:;base64,Cg=r#r2rrr�test_invalid_base64_data�sz*urlopen_DataTests.test_invalid_base64_dataN)r3r4r5rcrrr�r�r r!r"r$r%rrrrr`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.urlretrieverV)rrrr�	tempFiles�registerFileForCleanUprr[rZrr\r1)r!�FILErrrrc�s	
�zurlretrieve_FileTests.setUpcCs,|jD] }zt�|�WqYq0qdSr)r'rdre)r!Zeachrrrrf�s
zurlretrieve_FileTests.tearDowncCsHtj�|�}z|�d�Wnty6t�d��Yn0dtj�	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rdr��abspathr�UnicodeEncodeErrorrZSkipTestrrr)r!ZfilePathrrr�constructLocalFileUrl�sz+urlretrieve_FileTests.constructLocalFileUrlr*cCstt��\}}zF|�|�t�|d�}|�|�|��Wz|��WqpYqp0nz|��WnYn00|S)NrV)r�r�r(rd�fdopenr\r1)r!rZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s


�z'urlretrieve_FileTests.createNewTempFilecCs|j�|�dSr)r'�append)r!ZfileNamerrrr(�sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj�dtj�}|�|dtj�|�|dtjj	d�dS)NrWrrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverr[rsrwr{r|r})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)rr[r(rrr0r,rsrnrdr�r�rr.r1rZ)r!�second_tempr1r)rZrrr�	test_copy�s$


��

�zurlretrieve_FileTests.test_copycsBdgf�fdd�	}dtj}��|�tj���tj�||�dS)NrcsH��|t���|t���|t���||d�|dd|d<dS)Nrr)rwrxrs)�block_count�block_read_size�	file_sizeZcount_holderr2rr�
hooktesters
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterr3)rr[r(rrr0r,)r!r:r5rr2r�test_reporthooks


�z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|��}tj�|�|�tj|�|�t|�d�|�|ddd�dS)NcSs|�|||f�dSr�r/�r7r8r9Z_reportrrrr:szAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr�	r.rrr0r,rr[rsr
�r!�reportr:ZsrcFileNamerrr�test_reporthook_0_bytess�z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|�d�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd�dS)NcSs|�|||f�dSrr<r=rrrr:"szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktestersxxxxxrr�rr>r?rrr�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�dSrr<r=rrrr:0szDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester�xi �rrri r>r?rrr�test_reporthook_8193_bytes+s�z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r*)r3r4r5rcrfr,r.r(r2r6r;rArCrFrrrrr&�s
	r&c@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�rrrrr?r�r��ContentTooShortErrorr0rZ
TEST_HTTP_URLrC)r!rIrrr�.test_short_content_raises_ContentTooShortError?s


�zDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc	Csp|�tjj�|�d�|�tjj��6ztj�t	j
�W|��n
|��0Wd�n1sb0YdS)NrHrJr2rrr�Atest_short_content_raises_ContentTooShortError_without_reporthookVs
	zWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r3r4r5rLrMrrrrrG<srGc@sTeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�ZdS)�QuotingTestscCsVd�gd��}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nr�)�ABCDEFGHIJKLMNOPQRSTUVWXYZ�abcdefghijklmnopqrstuvwxyz�
0123456789z_.-~�using quote(): %r != %r�using quote_plus(): %r != %r)�joinrr^r_rs�
quote_plus)r!Zdo_not_quoter1rrr�test_never_quote�s
�
�zQuotingTests.test_never_quotecCs|�tjjjdd�dS)Nrr�)rsrr^r_�__defaults__r2rrr�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<>��saferRrSs<>uaüb�latin-1�ü)�encodingrZr���)rr^r_rsrU)r!Zquote_by_defaultr1�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%5DcdrRrS)
r�r/r�rTrr^r_rsrrU)r!Zshould_quoterr1Z
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�rR�+zusing quote_plus(): %r != +z
a b cd e frS)rr^r_rsrrUr�)r!r1�givenr_rrr�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+gammargzalpha+beta+gammasalpha+beta gamma�+)rsrr^rUr2rrr�test_quoting_plus�s����zQuotingTests.test_quoting_pluscCsfd}d}tj�|�}|�||d||f�|jttjj|dd�tj�|�}|�||d||f�dS)N���ab��%A2%D8ab%FFrRr[�r]z"using quote_from_bytes(): %r != %r)rr^r_rsr��	TypeError�quote_from_bytes�r!rhr_r1rrr�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%BFrR�r]�errorsrmr[rn�漢字�%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rr^r_rsr�r+rqrrr�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+%FFr[rnrSuab漢字 cdzab%3F%3F+cdr�rs)rr^rUrsrqrrr�test_quote_plus_with_unicode&s
�
�
�z)QuotingTests.test_quote_plus_with_unicodeN)r3r4r5rVrXr`rfrirkrrrxryrrrrrNis
*rNc@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�rr^�unquoters�unquote_plusr/rT�countr�ro�AttributeError)r!Zescape_listrbrhr_r1Z
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%xabr|z%xr	rU�"using unquote_to_bytes(): %r != %rr)	rr^r~rsrX�unquote_to_bytesr�ror�rqrrr�test_unquoting_badpercentTsL
�
�
�

�

�

�z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj�|�}|�||d||f�dS)Nz%Ab%eAs��r��rr^r�rsrqrrr�test_unquoting_mixed_casexs��z(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nzab%sd�cZabcdrRr})rrr^r~rsrrqrrr�test_unquoting_parts�s
�
�z#UnquotingTests.test_unquoting_partscCs\d}|}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nzare+there+spaces...r|rgr�r})rr^r~rsr�rrqrrr�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.docr��	漢%C3%BCs漢üs%A2%D8ab%FFrls	%A2�ab%FFr�rqrrr�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.docr|rszbr%FCckner_sapporo_20050930.docr[rnrvruz%F3%B1u�r�)rtr��ignorer�u漢üu漢%FC�rr^r~rsrqrrr�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blueberryjamr|sblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjr�rqrrr�test_unquoting_with_bytes_input�s$
�
�
�z.UnquotingTests.test_unquoting_with_bytes_inputN)r3r4r5r�r�r�r�r�r�r�r�rrrrrz6s$	:rzc@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)
rr^�	urlencoderrsr��indexrn�isdigitr
)	r!rhZ	test_typeZexpect_somewherer1reZ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�r2rrr�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�r2rrr�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)rrr^r�rsrqrrr�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)rr^rUrr�rsrr�)r!rhr_r1�valuerrr�
test_doseqAs�zurlencode_Tests.test_doseqcCs,|�dtj�i��|�dtj�g��dSr	�rsrr^r�r2rrr�test_empty_sequenceNsz#urlencode_Tests.test_empty_sequencecCs4|�dtj�ddi��|�dtj�ddi��dS)Nza=1�arza=Noner�r2rrr�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)rsrr^r�r�r�r rrr�test_nonstring_seq_valuesVs��z)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|�||�d}d}tj�|�}|�||�d}d}tjj|dd	�}|�||�dS)
N�)� �Á�%3F=%3Frr�rs�
%C2%A0=%C3%81�%A0=%C1r[rn�rr^r�rsrqrrr�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�Trr�)�doseqr]rt))r�)rr�z
%3F=1&%3F=%3Frsr�))r�)�*r�z%C2%A0=42&%C2%A0=%C3%81r�r[rnz%A0=42&%A0=%C1r�rqrrr�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�rqrrr�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:$rYz	%A0$=%C1$T)r�rZ))r�)r��
r�z%A0$=%C1$&%A0$=13&%A0$=42r[)rZr])r�rZr]r�)r!rhr1r_rrr�&test_urlencode_encoding_safe_parameter�s:
���z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r3r4r5r�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)rdr�rTrrrrsr)r!Z
expected_pathZexpected_urlr1rrrr2�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)
rdr�rTrr^r_rrrsrrqrrrr��s>��������zPathname_Tests.test_quoting�win32z*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)rrrrsrqrrr�
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)rrrrs)r!rhr_rr1rrr�test_ntpath	s"����zPathname_Tests.test_ntpathN)r3r4r5r2r�rr�sys�platformr�r�rrrrr��s
�
�r�c@seZdZdd�ZdS)�
Utility_TestscCs|�tj��t�dSr)rwrrZthishost�tupler2rrr�
test_thishostszUtility_Tests.test_thishostN)r3r4r5r�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)r3r4r5r�rrrr�DummyURLopener&sr�z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr
rrrrsr)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�rdr1rrrr
�retrieversr��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?rrCrrr
r�rsrdr��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)r3r4r5r�rrrrr�Isr�)zlocal_file://examplezlocal-file://example)rrr
r�r�rrr�)r!r�rrrr�test_local_file_openFsz$URLopener_Tests.test_local_file_openN)
r3r4r5r�rZignore_warningsrr�r�r�rrrrr�"s

	


r�c@seZdZdd�Zdd�ZdS)�RequestTestscCs>tjj}|d�}|�|��d�|di�}|�|��d�dS)Nr�r�ZPOST)rr�Requestrs�
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�rsr�r�r�rrr�test_with_method_arg^sz!RequestTests.test_with_method_argN)r3r4r5r�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��rsrr2rrr�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�r2rrr�$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�r2rrr�test_simple_comparexs
�z%URL2PathNameTests.test_simple_comparecCs|�ttd�dS)Nu///è|/)r��IOErrorrr2rrr�test_non_ascii_drive_letter|sz-URL2PathNameTests.test_non_ascii_drive_lettercCs*gd�}|D]}|�tt|��|�qdS)N)r�z\\\C\test\\r�)rsrr�r!Z
list_of_pathsr�rrr�test_roundtrip_url2pathnamesz-URL2PathNameTests.test_roundtrip_url2pathnameN)r3r4r5r�r�r�r�r�rrrrr�ls
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs$|�td�d�|�td�d�dS)Nr�r�r��rsrr2rrrr��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�r2rrrr��s
�
�
�z6PathName2URLTests.test_converting_when_no_drive_lettercCs|�td�d�dS)Nr��///C:/foo/bar/spam.foor�r2rrrr��s
�z%PathName2URLTests.test_simple_comparecCs|�ttd�dS)NzXX:\)r�r�rr2rrr�test_long_drive_letter�sz(PathName2URLTests.test_long_drive_lettercCs*gd�}|D]}|�tt|��|�qdS)N)r�r�r�)rsrrr�rrr�test_roundtrip_pathname2url�sz-PathName2URLTests.test_roundtrip_pathname2urlN)r3r4r5r�r�r�r�r�rrrrr��s
r��__main__)NN)F)4�urllib.parserZurllib.requestZurllib.errorZhttp.clientr<Z
email.messager{r,rZ
unittest.mockrr�rrdr
�ImportErrorr�r�Z
nturl2pathrr�base64rr�rrrrr?rOr@rDZTestCaserTr�r�r�rr&rGrNrzr�r�r�r�r�r�r�r3�mainrrrr�<module>sb


/
]L$
M-NTDN2


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists