Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/test/__pycache__/test_urllib.cpython-38.pyc
U

>��g��@s<dZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlZzddlZWnek
r�dZYnXddlZddlZddlmZmZddlmZddlZdd�Zdad5d	d
�Zdd�Zd6dd�ZGdd�de�Z Gdd�de�Z!Gdd�de
j"�Z#Gdd�de
j"�Z$Gdd�de
j"�Z%Gdd�de
j"e e!�Z&Gdd�de
j"�Z'Gdd�de
j"�Z(Gd d!�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-e e
j"�Z/Gd.d/�d/e
j"�Z0Gd0d1�d1e
j"�Z1Gd2d3�d3e
j"�Z2e3d4k�r8e
�4�dS)7z;Regression tests for what was in Python 2's "urllib" module�N)�patch)�support)�url2pathname�pathname2url)�	b64encodecCs4tt|��dd���}t|�dkr,d|}d|S)z!Escape char as RFC 2396 specifies�N�z0%s�%)�hex�ord�upper�len)�charZhex_repr�r�//opt/cppython/lib/python3.8/test/test_urllib.py�	hexescapesrcCsN|dk	rtjj|d�}nts(t�}|ant}|dkr>|�|�S|�||�SdS)z.urlopen(url [, data]) -> open file-like objectN)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datar�openerrrr�urlopen$s
rc
Cs0t�dtf��tj��W5QR�SQRXdS)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!�userZpasswd�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)r3r4r5rJrLr1rrrr�FakeFtpWrappervs
�
rM)�objectrr�
ftpwrapper�_ftpwrapper_class)r!rMrrr�fakeftpus
zFakeFTPMixin.fakeftpcCs|jtj_dSr)rPrrrOr2rrr�	unfakeftp�szFakeFTPMixin.unfakeftpN)r3r4r5rQrRrrrrrDtsrDc@sxeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�urlopen_FileTestsz�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.

    cCsXtd|jjd�|_ttjd�}z|�|j�W5|��Xtj|_	t
d|j	�|_dS)Nztest_urllib: %s
�ascii�wb�file:%s)�bytes�	__class__r3�textrr�TESTFNr1�write�pathnamer�returned_obj)r!�frrr�setUp�s�
zurlopen_FileTests.setUpcCs|j��t�tj�dS)zShut down the open objectN)r]r1�os�removerrZr2rrr�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�hasattrr]�r!�attrrrr�test_interface�s��z urlopen_FileTests.test_interfacecCs|�|j|j���dSr)�assertEqualrYr]r.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)rorYr]r/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)r]rcror
rY)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]rd�assertIsInstance�intror`r.r
rY)r!Zfile_numrrr�test_fileno�s

�zurlopen_FileTests.test_filenocCs|j��dSr)r]r1r2rrr�
test_close�szurlopen_FileTests.test_closecCs|�|j��tjj�dSr)rsr]re�email�message�Messager2rrr�	test_info�szurlopen_FileTests.test_infocCs|�|j��|j�dSr)ror]rfr\r2rrr�test_geturl�szurlopen_FileTests.test_geturlcCs|�|j���dSr)ZassertIsNoner]rgr2rrr�test_getcode�szurlopen_FileTests.test_getcodecCs|jD]}|�||j�qdSr)r]rorY)r!�linerrr�	test_iter�s
zurlopen_FileTests.test_itercCs|�ttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrr\r2rrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r3r4r5�__doc__r_rbrnrprqrrrurvrzr{r|r~r�rrrrrS�s	rSc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ProxyTestscCs6t��|_ttj�D]}d|��kr|j�|�qdS)N�proxy)rZEnvironmentVarGuard�env�listr`�environ�lower�unset)r!�krrrr_�s
zProxyTests.setUpcCs|j��|`dSr)r��__exit__r2rrrrb�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_environmentrorj�proxy_bypass_environment�r!rrrr�+test_getproxies_environment_keep_no_proxies�s
z6ProxyTests.test_getproxies_environment_keep_no_proxiesc	CspzP|j�dd�tj��}|�d|d�|j�dd�tj��}|�d|�W5|j�d�|j�d�XdS)NZREQUEST_METHOD�
HTTP_PROXY�http://somewhere:3128r<�GET)r�r�r�rrr�ro�assertNotInr�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�rj�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_newlines�z0ProxyTests.test_proxy_bypass_environment_newlineN)
r3r4r5r_rbr�r�r�r�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_t��t_dSr)r`r��
_saved_env�collections�OrderedDictr2rrrr_)szProxyTests_withOrderedEnv.setUpcCs|jt_dSr)r�r`r�r2rrrrb/sz"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<)	r`r�r�rrr�r�rorjr�rrr�,test_getproxies_environment_prefer_lowercase2s&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r3r4r5r_rbr�rrrrr�'sr�c@seZdZdZdd�Zdd�Zdd�Ze�e	d�d	d
��Z
e�e	d�dd��Ze�e	d�d
d��Ze�e	d�dd��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Ze�ejd'd(�d)d*��Zd+d,�Zd-d.�Zd/d0�Z e�e	d�d1d2��Z!d3S)4�urlopen_HttpTestsz.Test urlopen() opening a fake http connection.cCsn|�d|d�zLtd�}|�|��d�|�|��d�|�|��d�|�|��d�W5|��XdS)NsHTTP/s 200 OK

Hello!�http://python.org/�Hello!r*���r?rCrror/rfrg)r!�ver�fprrr�
check_readNszurlopen_HttpTests.check_readcCs>d}|�d�z tj�|�}|�|��|�W5|��XdS)Nz-http://docs.python.org/library/urllib.html#OK�HTTP/1.1 200 OK

Hello!)r?rCrrrrorf)r!rr�rrr�test_url_fragmentYs
z#urlopen_HttpTests.test_url_fragmentcCs4|�d�ztd�}|�|jj�W5|��XdS)Nr��http://www.python.org)r?rCrrjr�Z
will_close)r!�resprrr�test_willclosecs

z urlopen_HttpTests.test_willclosezssl module requiredc
Cs�ttdd��dgD]�}t|�}d|�d�}|�d�z�t|��dd�}tjj	}|�
|d	|����tj�
d
|���W5QRX|�
|d	|����tj�
d|���W5QRXt
d
|���}|�||���W5|��XqdS)Nr�!�z//localhost:7777/test�/�HTTP/1.1 200 OK

Hello.�\�\\�contain control.*�http:�https:)r��range�chrr?rC�repr�replacer<r=�
InvalidURL�assertRaisesRegexrrrr�rf)r!�char_nor�schemeless_url�escaped_char_reprr�r�rrr�(test_url_path_with_control_char_rejectedks(
��z:urlopen_HttpTests.test_url_path_with_control_char_rejectedc	Cs�|�d�d}d|d}z�tjj}|�|d��tj�d|���W5QRX|�|d��tj�d|���W5QRXtd|���}|�	d	|�
��|�	d
|�
��|�	d|�
��W5|��XdS)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?rCr<r=r�r�rrrr�rf)r!rFr�r�r�rrr�4test_url_path_with_newline_header_injection_rejected�s"
�zFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejectedc
Cs�ttdd��dgD]�}t|�}d|�d�}|�d�ztt|��dd�}tjj	}|�
|d	|����td
|���W5QRX|�
|d	|����td|���W5QRXW5|��XqdS)Nrr�r�z//localhostz/test/r�r�r�r�r�r�)r�r�r�r?rCr�r�r<r=r�r�r)r!r�rr�r�r�rrr�(test_url_host_with_control_char_rejected�s
�z:urlopen_HttpTests.test_url_host_with_control_char_rejectedc	Cs�|�d�d}d|d}zXtjj}|�|d��td|���W5QRX|�|d��td|���W5QRXW5|��XdS)	Nr�zlocalhost
X-injected: header
r�r�zcontain control.*\\rr�r�r�)r?rCr<r=r�r�r)r!rFr�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_1cCs0|jddd�z|�ttd�W5|��XdS)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?rCr�OSErrorrr2rrr�test_read_bogus�s�z!urlopen_HttpTests.test_read_bogusc	CsJ|jddd�z,d}|�tjj|��td�W5QRXW5|��XdS)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?rCr�r�error�	HTTPErrorr)r!�msgrrr�test_invalid_redirect�s�z'urlopen_HttpTests.test_invalid_redirectc	CsFtt�j�D]4}|jddd�z|�tjjt	d�W5|��XqdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
TrA�http://something)
r�rZmaxtriesr?rCrrr�r�r)r!�irrr�test_redirect_limit_independent�s��z1urlopen_HttpTests.test_redirect_limit_independentcCs,|�d�z|�ttd�W5|��XdS)Nr*r�r�r2rrr�test_empty_socket�s
z#urlopen_HttpTests.test_empty_socketc	CsB|�tjj��}td�W5QRX|�|jj�|�|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	rrr��URLErrorrrj�	exception�filename�reason�r!�errr�test_missing_localfile�sz(urlopen_HttpTests.test_missing_localfilec	Cs�t��\}}d|�tjjd�}z4|�tj�	|��t
|��}|�|�W5QRXW5t�|�t�|�X|�tj�	|��|�t
jj��t
|�W5QRXdS)Nzfile://localhost/r�)�tempfile�mkstempr�r`�path�sepr1�unlinkrj�existsrr�rrr�r�)r!�fdZtmp_fileZtmp_fileurlZfobjrrr�test_file_notexistss

z%urlopen_HttpTests.test_file_notexistsc	CsFd}|�tjj��}t|�W5QRX|�|jj�|�|jj	�dS)Nzftp:///path�
rrr�r�rr�r�r�rjr�)r!Ztest_ftp_urlr�rrr�test_ftp_nohosts
z!urlopen_HttpTests.test_ftp_nohostc	CsB|�tjj��}td�W5QRX|�|jj�|�|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.pyr�r�rrr�test_ftp_nonexistingsz&urlopen_HttpTests.test_ftp_nonexistingZMAXFTPCACHErcCs@|��z(tj�ddddg�tjjd<td�W5|��XdS)NrE�passr���testzftp://localhost)rQrRrrrOZftpcacherr2rrr�test_ftp_cache_pruning!s
z(urlopen_HttpTests.test_ftp_cache_pruningcCsf|�d�zLtd�}|�|��d�|�|��d�|�|��d�|�|��d�W5|��XdS)N�HTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/r�r*r�r�)r!r�rrr�test_userpass_inurl*s
z%urlopen_HttpTests.test_userpass_inurlcCs�|�d�z�d}d�|�}tjj}dt|�d���d�}t	|�}|�
||j�d��|�|�
�d�|�|�
�d�|�|��|�|�|��d	�W5|��XdS)
Nr�za b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8r�r*r�)r?rC�formatr<r=r>r�encode�decoder�assertInrror/ZassertNotEqualrfrg)r!ZuserpassrZfakehttp_wrapperZ
authorizationr�rrr�test_userpass_inurl_w_spaces5s

�z.urlopen_HttpTests.test_userpass_inurl_w_spacesc	Cs(t�dtf��tj��W5QRXdS�Nr�)rrrrr�	URLopenerr2rrr�test_URLopener_deprecationHsz,urlopen_HttpTests.test_URLopener_deprecationc
CsNt��}t�dtf��.|�t��tjj	dd|d�W5QRXW5QRXdS)Nr�zhttps://localhostz/nonexistent/path)Zcafile�context)
�sslZcreate_default_contextrrrrr�rrr)r!rrrr�test_cafile_and_contextLs�z)urlopen_HttpTests.test_cafile_and_contextN)"r3r4r5r�r�r�r��unittest�
skipUnlessrr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrNrrr�r�rrrrrrrr�Ks<









	

r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�urlopen_DataTestsz"Test urlopen() opening a data URL.cCsRd|_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)rY�image�text_url�text_url_base64�	image_urlrrr�
text_url_resp�text_url_base64_resp�image_url_respr2rrrr_Ys�����zurlopen_DataTests.setUpcCs&dD]}|�t|j|�d|�qdS)N)r.r/rcr1rerfrgrhri)rjrkrrlrrrrnus��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)rsrrerwrxryror�
get_paramsr�strr
r
rrrr2rrrrz}s���zurlopen_DataTests.test_infocCs@|�|j��|j�|�|j��|j�|�|j��|j�dSr)rorrfrrrrr
r2rrrr{�s
�zurlopen_DataTests.test_geturlcCs0|�|j���t|j�����d�|j�dS�Nr)rorr.r��dictrerrYr2rrr�test_read_text�s
��z urlopen_DataTests.test_read_textcCs0|�|j���t|j�����d�|j�dSr)rorr.r�rrerrYr2rrr�test_read_text_base64�s
��z'urlopen_DataTests.test_read_text_base64cCs|�|j��|j�dSr)rorr.r
r2rrr�test_read_image�sz!urlopen_DataTests.test_read_imagecCs|�ttjjd�dS)Nzdata:text/plain�rr�rrrr2rrr�test_missing_comma�sz$urlopen_DataTests.test_missing_commacCs|�ttjjd�dS)Nzdata:;base64,Cg=rr2rrr�test_invalid_base64_data�sz*urlopen_DataTests.test_invalid_base64_dataN)
r3r4r5r�r_rnrzr{rrrrrrrrrr	Vs	r	c@sjeZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�urlretrieve_FileTestsz(Test urllib.urlretrieve() on local filescCs^g|_|�tj�d|_z$ttjd�}|�|j�|��W5z|��WnYnXXdS)Nstesting urllib.urlretrieverU)�	tempFiles�registerFileForCleanUprrZrYr1rr[)r!�FILErrrr_�szurlretrieve_FileTests.setUpcCs,|jD] }zt�|�WqYqXqdSr)rr`ra)r!Zeachrrrrb�s

zurlretrieve_FileTests.tearDowncCsJtj�|�}z|�d�Wntk
r8t�d��YnXdtj�	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
r`r��abspathr��UnicodeEncodeErrorrZSkipTestrrr)r!ZfilePathrrr�constructLocalFileUrl�sz+urlretrieve_FileTests.constructLocalFileUrlr*cCsZt��\}}z,|�|�t�|d�}|�|�|��W5z|��WnYnXX|S)z�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.rU)r�r�r1rr`�fdopenr[)r!rZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s

z'urlretrieve_FileTests.createNewTempFilecCs|j�|�dSr)r�append)r!ZfileNamerrrr�sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj�dtj�}|�|dtj�|�|dtjj	d�dS)NrVrrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrZrorsrwrxry)r!�resultrrr�
test_basic�s
�z urlretrieve_FileTests.test_basiccCs�dtj}|�|�tj�|�tj�|�}|�||d�|�t	j
�|�d�t|d�}z|��}|�
�W5z|�
�WnYnXX|�|j|�dS)N�%s.2rzcopy of the file was not made�rb)rrZrrrr&r"rorjr`r�r�rr1r.rY)r!�second_tempr'rrYrrr�	test_copy�s$


��
zurlretrieve_FileTests.test_copycsBdgf�fdd�	}dtj}��|�tj���tj�||�dS)NrcsH��|t���|t���|t���||d�|dd|d<dS)Nrr)rsrtro)�block_count�block_read_size�	file_sizeZcount_holderr2rr�
hooktester�s
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterr))rrZrrrr&r")r!r0r+rr2r�test_reporthook�s


�z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|��}tj�|�|�tj|�|�t|�d�|�|ddd�dS)NcSs|�|||f�dSr�r%�r-r.r/Z_reportrrrr0szAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr�	r$rrr&r"rrZror
�r!Zreportr0ZsrcFileNamerrr�test_reporthook_0_bytess�z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|�d�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd�dS)NcSs|�|||f�dSrr2r3rrrr0szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktestersxxxxxrr�rr4r5rrr�test_reporthook_5_bytes
s
�z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|fdd�}|�dd�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd	�|�|ddd	�|�|ddd	�dS)
NcSs|�|||f�dSrr2r3rrrr0 szDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester�xi �rrri r4r5rrr�test_reporthook_8193_bytess�z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r*)r3r4r5r�r_rbr"r$rr(r,r1r6r8r;rrrrr�s
	rc@s eZdZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionsc	CsR|�d�dd�}|�tjj��(ztjjtj	|d�W5|��XW5QRXdS)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�_reporthook:szYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthook)Z
reporthook�
r?rrr��ContentTooShortErrorrCrr&rZ
TEST_HTTP_URL)r!r>rrr�.test_short_content_raises_ContentTooShortError/s


�
zDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc	CsF|�d�|�tjj��$ztj�tj	�W5|��XW5QRXdS)Nr=r?r2rrr�Atest_short_content_raises_ContentTooShortError_without_reporthookDs

	zWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r3r4r5r�rArBrrrrr<,sr<c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�QuotingTestsauTests for urllib.quote() and urllib.quote_plus()

    According to RFC 3986 (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

    cCsZd�ddddg�}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nr��ABCDEFGHIJKLMNOPQRSTUVWXYZ�abcdefghijklmnopqrstuvwxyz�
0123456789z_.-~�using quote(): %r != %r�using quote_plus(): %r != %r)�joinr�parse�quotero�
quote_plus)r!Zdo_not_quoter'rrr�test_never_quoteos�
�
�zQuotingTests.test_never_quotecCs|�tjjjdd�dS)Nrr�)rorrJrK�__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<>��saferGrHs<>uaüb�latin-1�ü)�encodingrQr���)rrJrKrorL)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>�sz5QuotingTests.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%5DcdrGrH)
r�r%r�rIrrJrKrorrL)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�rG�+zusing quote_plus(): %r != +z
a b cd e frH)rrJrKrorrLr�)r!r'�givenrVrrr�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+gammar^zalpha+beta+gammasalpha+beta gamma�+)rorrJrLr2rrr�test_quoting_plus�s����zQuotingTests.test_quoting_pluscCsfd}d}tj�|�}|�||d||f�|jttjj|dd�tj�|�}|�||d||f�dS)N���ab��%A2%D8ab%FFrGrR�rTz"using quote_from_bytes(): %r != %r)rrJrKror�	TypeErrorZquote_from_bytes�r!r_rVr'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%BFrG�rT�errorsrdrRre�漢字�%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rrJrKrorr!rgrrr�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+%FFrRrerHuab漢字 cdzab%3F%3F+cdr�ri)rrJrLrorgrrr�test_quote_plus_with_unicodes
�
�
�z)QuotingTests.test_quote_plus_with_unicodeN)
r3r4r5r�rMrOrWr]r`rbrhrnrorrrrrCUs
*rCc@sPeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�ZdS)�UnquotingTestszwTests for unquote() and unquote_plus()

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

    c	Csg}td�D]f}tt|��}t|�}tj�|�}|�||d||f�tj�|�}|�||d||f�|�|�qd�	|�}~tj�|�}|�|�
d�dd|�|�tt
ftjjd�|�tt
ftjjd�tjdtfd	d
��|�tt
ftjjd�W5QRXdS)N��using unquote(): %r != %r�using unquote_plus(): %r != %rr�r	rz/using unquote(): not all characters escaped: %srT)�quietr*)r�rr�rrJ�unquotero�unquote_plusr%rI�countrrf�AttributeErrorrr�BytesWarning)r!Zescape_listrYr_rVr'Z
escape_stringrrr�test_unquoting)s6
���
��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%xabrrz%xr	rT�"using unquote_to_bytes(): %r != %rr)	rrJrurorW�unquote_to_bytesrrfrxrgrrr�test_unquoting_badpercentBsL
�
�
�

�

�

�z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj�|�}|�||d||f�dS)Nz%Ab%eAs��r{�rrJr|rorgrrr�test_unquoting_mixed_casefs��z(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nzab%sd�cZabcdrGrs)rrrJrurorvrgrrr�test_unquoting_partsos
�
�z#UnquotingTests.test_unquoting_partscCs\d}|}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nzare+there+spaces...rrr^r�rs)rrJruror�rvrgrrr�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%FFrcs	%A2�ab%FFr~rgrrr�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.docrrrizbr%FCckner_sapporo_20050930.docrRrerlrkz%F3%B1u�r�)rjr��ignorer�u漢üu漢%FC)rrJrurorgrrr�test_unquote_with_unicode�sb
�
��
�
�
�
�
�
�
�z(UnquotingTests.test_unquote_with_unicodec	Cs,|�td��d}tj�|�W5QRXdS)NzExpected str, got bytessblåbærsyltetøy)r�rfrrJru)r!r_rrr�test_unquoting_with_bytes_input�sz.UnquotingTests.test_unquoting_with_bytes_inputN)r3r4r5r�rzr}rr�r�r�r�r�rrrrrp"s$	:rpc@speZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�urlencode_TestszTests for urlencode()c		Cs�dddg}tj�|�}|D]}|�||d|||f�q|�|�d�dd||�d�f�|�d�}||d}||d}|�|��o�|��d	||f�|�t	|�d
d|t	|�d
f�dS)
aHelper 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.

        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 != %sN)
rrJ�	urlencoder�rorw�indexrj�isdigitr
)	r!r_Z	test_typeZexpect_somewherer'r\Z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|�dddgd�dS)N)r�r�)r�r�)r�r�z*using sequence of two-item tuples as inputr�r2rrr�test_using_sequences�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)rrrJr�rorgrrr�test_quotingszurlencode_Tests.test_quotingcCs�ddddgi}dtj�tdddg��}tj�|�}|�||�tj�|d�}|dD]}d|}|�||�qV|�|�d�dd	|�d��dS)
NZsequencer�r�r�zsequence=%sTr�rzExpected 2 '&'s, got %s)rrJrLrr�ror�rw)r!r_rVr'�valuerrr�
test_doseqs�zurlencode_Tests.test_doseqcCs,|�dtj�i��|�dtj�g��dSr�rorrJr�r2rrr�test_empty_sequence+sz#urlencode_Tests.test_empty_sequencecCs4|�dtj�ddi��|�dtj�ddi��dS)Nza=1�arza=Noner�r2rrr�test_nonstring_values/sz%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)rorrJr�r�r�r rrr�test_nonstring_seq_values3s��z)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|�||�d}d}tj�|�}|�||�d}d}tjj|dd	�}|�||�dS)
N�)� �Á�%3F=%3Fr�r�ri�
%C2%A0=%C3%81�%A0=%C1rRre�rrJr�rorgrrr�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�)�doseqrTrj))r�)rr�z
%3F=1&%3F=%3Frir�))r�)�*r�z%C2%A0=42&%C2%A0=%C3%81r�rRrez%A0=42&%A0=%C1r�rgrrr�test_urlencode_encoding_doseqNs<
�
�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�rgrrr�test_urlencode_bytesss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:$rPz	%A0$=%C1$T)r�rQ))r�)r��
r�z%A0$=%C1$&%A0$=13&%A0$=42rR)rQrT)r�rQrTr�)r!r_r'rVrrr�&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�r�rrrrr��s 
%r�c@sTeZdZdZdd�Zdd�Ze�ej	dkd�dd	��Z
e�ej	dkd
�dd��Zd
S)�Pathname_Testsz&Test pathname2url() and url2pathname()cCs^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�rIrrrror)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�rIrrJrKrrrorrgrrrr��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)rrrrorgrrr�
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)rrrro)r!r_rVrr'rrr�test_ntpath�s"����zPathname_Tests.test_ntpathN)r3r4r5r�r(r�rr�sys�platformr�r�rrrrr��s
�
�r�c@seZdZdZdd�ZdS)�
Utility_Testsz=Testcase to test the various utility functions in the urllib.cCs|�tj��t�dS)zATest the urllib.request.thishost utility function returns a tupleN)rsrrZthishost�tupler2rrr�
test_thishost�szUtility_Tests.test_thishostN)r3r4r5r�r�rrrrr��sr�c@sTeZdZdZdd�Zejed�dd��Zejed�dd��Z	ejed�d	d
��Z
dS)�URLopener_Testsz4Testcase to test the open method of URLopener class.c	CsZGdd�dtjj�}t�dtf��.|�|��d�d�|�|��d�d�W5QRXdS)Nc@seZdZdd�ZdS)z8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenercSs|Srr�r!rrrr�	open_spamszBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spamN)r3r4r5r�rrrr�DummyURLopenersr�z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrrrrrror)r!r�rrr�test_quoted_opens ��
��
��z URLopener_Tests.test_quoted_open)�categoryc	Csrt���`}tj|d�\}}t�|�dtj�|�}tj�	��
|�\}}|�tj�
|�tj�
|��W5QRXdS)N)�dirzfile:)rZtemp_dirr�r�r`r1rrrr�retrieveror��normcase)r!Ztmpdirr�ZtmpfileZfileurlr��_rrr�test_urlopener_retrieve_files

z,URLopener_Tests.test_urlopener_retrieve_filecCsJd}|�d�|�|j�tj���|�\}}|�tj	�
|�dd�dS)Nzhttp://www.python.org/file.txtr�rz.txt)r?Z
addCleanuprCrrrr�ror`r��splitext)r!rr�r�rrr�test_urlopener_retrieve_remotes

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_file'szLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileN)r3r4r5r�rrrrr�&sr�)zlocal_file://examplezlocal-file://example)rrrrr�rrr�)r!r�rrrr�test_local_file_open#sz$URLopener_Tests.test_local_file_openN)r3r4r5r�r�rZignore_warningsrr�r�r�rrrrr��s

	


r�c@s eZdZdZdd�Zdd�ZdS)�RequestTestsz&Unit tests for urllib.request.Request.cCs>tjj}|d�}|�|��d�|di�}|�|��d�dS)Nr�r�ZPOST)rr�Requestro�
get_method�r!r�rrrr�test_default_values�s

z RequestTests.test_default_valuescCs�tjj}|ddd�}|�|jd�|�|��d�|didd�}|�|jd�|�|��d�|ddd�}|�|��d�d|_|�|��d�dS)Nr�ZHEAD)�methodr�)rrr�ror�r�r�rrr�test_with_method_arg�sz!RequestTests.test_with_method_argN)r3r4r5r�r�r�rrrrr��sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCs4|�td�d�|�td�d�|�td�d�dS)Nz///C|�C:�///C:z///C|/r��rorr2rrr�test_converting_drive_letter�sz.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_letter�sz6URL2PathNameTests.test_converting_when_no_drive_lettercCs|�td�d�dS)Nz///C|/foo/bar/spam.foo�C:\foo\bar\spam.foor�r2rrr�test_simple_compare�s
�z%URL2PathNameTests.test_simple_comparecCs|�ttd�dS)Nu///è|/)r�IOErrorrr2rrr�test_non_ascii_drive_letter�sz-URL2PathNameTests.test_non_ascii_drive_lettercCs,dddg}|D]}|�tt|��|�qdS)Nr�z\\\C\test\\r�)rorr�r!Z
list_of_pathsr�rrr�test_roundtrip_url2pathname�s�z-URL2PathNameTests.test_roundtrip_url2pathnameN)r3r4r5r�r�r�r�r�rrrrr��s
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs$|�td�d�|�td�d�dS)Nr�r�r��rorr2rrrr��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:\)rr�rr2rrr�test_long_drive_letter�sz(PathName2URLTests.test_long_drive_lettercCs,dddg}|D]}|�tt|��|�qdS)Nr�r�r�)rorrr�rrr�test_roundtrip_pathname2url�s�z-PathName2URLTests.test_roundtrip_pathname2urlN)r3r4r5r�r�r�r�r�rrrrr��s
r��__main__)NN)F)5r�Zurllib.parserZurllib.requestZurllib.errorZhttp.clientr<Z
email.messagerwr,rZ
unittest.mockrr�rr`r�ImportErrorr�r�Z
nturl2pathrr�base64rr�rrrrr?rNr@rDZTestCaserSr�r�r�r	rr<rCrpr�r�r�r�r�r�r�r3�mainrrrr�<module>sf


/
SL$
J
)NEDN


F1le Man4ger