Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_urllib.cpython-310.pyc
o

�9j��@sbdZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZddlmZddlZzddlZWneyQdZYnwddlZddlZddlmZmZdd	lmZddlZd
d�Zdad8dd
�Z dd�Z!d9dd�Z"Gdd�de#�Z$Gdd�de#�Z%Gdd�de
j&�Z'Gdd�de
j&�Z(Gdd�de
j&�Z)Gdd�de
j&e$e%�Z*Gdd �d e
j&�Z+Gd!d"�d"e
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&�Z0Gd+d,�d,e
j&�Z1Gd-d.�d.e
j&�Z2Gd/d0�d0e$e
j&�Z3Gd1d2�d2e
j&�Z4Gd3d4�d4e
j&�Z5Gd5d6�d6e
j&�Z6e7d7k�r/e
�8�dSdS):z;Regression tests for what was in Python 2's "urllib" module�N)�patch)�support)�	os_helper)�control_characters_c0)�warnings_helper)�url2pathname�pathname2url)�	b64encodecCs4tt|��dd���}t|�dkrd|}d|S)z!Escape char as RFC 2396 specifies�N�z0%s�%)�hex�ord�upper�len)�char�hex_repr�r�'/usr/lib/python3.10/test/test_urllib.py�	hexescapesrcCsJ|durtjj|d�}n
tst�}|ant}|dur|�|�S|�||�S)z.urlopen(url [, data]) -> open file-like objectN)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datar�openerrrr�urlopen's
rcCs<t�dtf��
tj��Wd�S1swYdS)Nz8FancyURLopener style of invoking requests is deprecated.)r�check_warnings�DeprecationWarningrrrrrrrr7s��$�rFcs:G�fdd�dtj��G��fdd�dtjj��|�_�S)Ncs@eZdZdZ�fdd�Zdd�Zd
dd�Zd
d	d
�Zdd�ZdS)zfakehttp.<locals>.FakeSocketrcs
|�_dS�N)�buf��selfr��FakeHTTPConnectionrr�sendallBs
z$fakehttp.<locals>.FakeSocket.sendallc_s|jd7_|S)Nr)�io_refs)r%�args�kwdsrrr�makefileEsz%fakehttp.<locals>.FakeSocket.makefileNcS�|jrdStj�||�S�N�)�closed�io�BytesIO�read)r%�amtrrrr3I�z!fakehttp.<locals>.FakeSocket.readcSr-r.)r0r1r2�readline)r%�lengthrrrr6Nr5z%fakehttp.<locals>.FakeSocket.readlinecSs,|jd8_|jdkrtj�|�dSdS)Nrr)r)r1r2�close�r%rrrr8Ss
�z"fakehttp.<locals>.FakeSocket.closer")	�__name__�
__module__�__qualname__r)r(r,r3r6r8rr&rr�
FakeSocket?s

r=cs,eZdZdZ�fdd�Z�rdd�ZdSdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs�|j�|_|jt|�_dSr")�fakedata�sock�type�fakesockr9)r=rr�connect]sz,fakehttp.<locals>.FakeHTTPConnection.connectcS�dSr"rr9rrrr8f�z*fakehttp.<locals>.FakeHTTPConnection.close)r:r;r<r#rBr8r)r=�
mock_closerrr'Xs�r')r1r2�http�client�HTTPConnectionr>)r>rEr)r'r=rEr�fakehttp>srIc@seZdZddd�Zdd�ZdS)�
FakeHTTPMixinFcCs"t||d�}tjj|_|tj_dS)N�rE)rIrFrGrH�_connection_class)r%r>rE�fake_http_classrrrrIns
zFakeHTTPMixin.fakehttpcC�|jtj_dSr")rLrFrGrHr9rrr�
unfakehttps�zFakeHTTPMixin.unfakehttpN�F)r:r;r<rIrOrrrrrJms
rJc@seZdZdd�Zdd�ZdS)�FakeFTPMixincCs&Gdd�dt�}tjj|_|tj_dS)Nc@s*eZdZ		d	dd�Zdd�Zdd�ZdS)
z,FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNTcSrCr"r)r%�user�passwd�host�port�dirs�timeout�
persistentrrr�__init__zsz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__cSst��dfS)Nr)r1r2)r%�filer@rrr�retrfile~�z5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSrCr"rr9rrrr8�rDz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)NT)r:r;r<rZr\r8rrrr�FakeFtpWrapperys
�r^)�objectrr�
ftpwrapper�_ftpwrapper_class)r%r^rrr�fakeftpxs
zFakeFTPMixin.fakeftpcCrNr")rarrr`r9rrr�	unfakeftp�rPzFakeFTPMixin.unfakeftpN)r:r;r<rbrcrrrrrRwsrRc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�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.

    cCsptd|jjd�|_ttjd�}z|�|j�W|��n|��wtj|_	t
j�|j	�|_
td|j
�|_dS)Nztest_urllib: %s
�ascii�wb�file:%s)�bytes�	__class__r:�textrr�TESTFN�writer8�pathnamer�parse�quote�quoted_pathnamer�returned_obj)r%�frrr�setUp�s�zurlopen_FileTests.setUpcCs|j��t�tj�dS)zShut down the open objectN)rqr8�os�removerrkr9rrr�tearDown�s
zurlopen_FileTests.tearDowncC�&dD]}|�t|j|�d|�qdS)N)	r3r6�	readlines�filenor8�info�geturl�getcode�__iter__�/object returned by urlopen() lacks %s attribute)�
assertTrue�hasattrrq�r%�attrrrr�test_interface�����z urlopen_FileTests.test_interfacecCs|�|j|j���dSr")�assertEqualrjrqr3r9rrr�	test_read��zurlopen_FileTests.test_readcCs,|�|j|j���|�d|j��d�dS)Nr/zKcalling readline() after exhausting the file did not return an empty string)r�rjrqr6r9rrr�
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)rqrxr�rrj)r%�
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)	rqry�assertIsInstance�intr�rtr3rrj)r%�file_numrrr�test_fileno�s

�zurlopen_FileTests.test_filenocCs|j��dSr")rqr8r9rrr�
test_close��zurlopen_FileTests.test_closecCs|�|jjtjj�dSr")r�rq�headers�email�message�Messager9rrr�test_headers�r�zurlopen_FileTests.test_headerscCs|�|jj|j�dSr")r�rqrrpr9rrr�test_url��zurlopen_FileTests.test_urlcCs|�|jj�dSr")�assertIsNonerq�statusr9rrr�test_status��zurlopen_FileTests.test_statuscCs|�|j��tjj�dSr")r�rqrzr�r�r�r9rrr�	test_info�szurlopen_FileTests.test_infocC�|�|j��|j�dSr")r�rqr{rpr9rrr�test_geturl�r�zurlopen_FileTests.test_geturlcCs|�|j���dSr")r�rqr|r9rrr�test_getcode��zurlopen_FileTests.test_getcodecCs|jD]	}|�||j�qdSr")rqr�rj)r%�linerrr�	test_iter�s
�zurlopen_FileTests.test_itercCs|�ttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrrmr9rrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r:r;r<�__doc__rsrvr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrd�s$
	rdc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ProxyTestscCs6t��|_ttj�D]}d|��vr|j�|�q
dS)N�proxy)r�EnvironmentVarGuard�env�listrt�environ�lower�unset)r%�krrrrs�s
��zProxyTests.setUpcCs|j��|`dSr")r��__exit__r9rrrrv�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_environmentr�r�proxy_bypass_environment�r%rrrr�+test_getproxies_environment_keep_no_proxies�s
z6ProxyTests.test_getproxies_environment_keep_no_proxiesc	Cs�z5|j�dd�tj��}|�d|d�|j�dd�tj��}|�d|�W|j�d�|j�d�dS|j�d�|j�d�w)N�
HTTP_PROXY�http://somewhere:3128rF�REQUEST_METHOD�GET)r�r�rrr�r��assertNotInr�r�rrr�test_proxy_cgi_ignores

�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��	LocalHost�	LOCALHOSTz
.localhostr�z.newdomain.com:1234z	foo.d.o.tzd.o.tr�z.anotherdomain.com:8888zwww.newdomain.com:1234�prelocalhost�
newdomain.comznewdomain.com:1235�rrr�r�r�r�assertFalse�r%�bypassrrr�(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_match!sz5ProxyTests.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)
r:r;r<rsrvr�r�r�r�r�rrrrr��s
r�c@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_t��t_dSr")rtr��
_saved_env�collections�OrderedDictr9rrrrs6szProxyTests_withOrderedEnv.setUpcCs|jt_dSr")r�rtr�r9rrrrv<r]z"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��no_proxyr��No_Proxy�	arbitrary�
http_proxyr�r�z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128�
Http_ProxyrF)	rtr�r�rrr�r�r�rr�rrr�,test_getproxies_environment_prefer_lowercase?s&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r:r;r<rsrvr�rrrrr�4sr�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.cCst|�d|d�z+td�}|�|��d�|�|��d�|�|��d�|�|��d�W|��dS|��w)NsHTTP/s 200 OK

Hello!�http://python.org/�Hello!r/���rIrr�r6r{r|rO)r%�ver�fprrr�
check_read[szurlopen_HttpTests.check_readcCsDd}|�d�ztj�|�}|�|��|�W|��dS|��w)Nz-http://docs.python.org/library/urllib.html#OK�HTTP/1.1 200 OK

Hello!)rIrrrr�r{rO)r%rr�rrr�test_url_fragmentfs
z#urlopen_HttpTests.test_url_fragmentcCs:|�d�ztd�}|�|jj�W|��dS|��w)Nr��http://www.python.org)rIrrr��
will_closerO)r%�resprrr�test_willcloseps

z urlopen_HttpTests.test_willclosezssl module requiredc	Csttdd��dgD]{}t|�}d|�d�}|�d�zet|��dd�}tjj}|�	|d	|����t
j�d
|���Wd�n1sEwY|�	|d	|����t
j�d|���Wd�n1sgwYtd
|���}|�
||���W|��q
|��wdS)Nr�!�z//localhost:7777/test�/�HTTP/1.1 200 OK

Hello.�\�\\�contain control.*�http:�https:)r��range�chrrI�repr�replacerFrG�
InvalidURL�assertRaisesRegexrrrr�r{rO)r%�char_nor�schemeless_url�escaped_char_reprr�r�rrr�(test_url_path_with_control_char_rejectedxs*

��
���z:urlopen_HttpTests.test_url_path_with_control_char_rejectedcCs�|�d�d}d|d}zhtjj}|�|d��tj�d|���Wd�n1s,wY|�|d��tj�d|���Wd�n1sKwYtd|���}|�d	|�	��|�d
|�	��|�d|�	��W|�
�dS|�
�w)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�� �
�
)rIrFrGr�r�rrrr�r{rO)r%rUr�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]h}t|�}d|�d�}|�d�zRt|��dd�}tjj}|�	|d	|����t
d
|���Wd�n1sCwY|�	|d	|����t
d|���Wd�n1scwYW|��q
|��wdS)Nrr�r�z//localhostz/test/r�r�r�r�r�r�)r�r�r�rIr�r�rFrGr�r�rrO)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}zLtjj}|�|d��td|���Wd�n1s*wY|�|d��td|���Wd�n1sGwYW|��dSW|��dS|��w)	Nr�zlocalhost
X-injected: header
r�r�zcontain control.*\\rr�r�r�)rIrFrGr�r�rrO)r%rUr�r�rrr�4test_url_host_with_newline_header_injection_rejected�s 
����zFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejectedcC�|�d�dS)Ns0.9�r�r9rrr�
test_read_0_9�r�zurlopen_HttpTests.test_read_0_9cCr)Ns1.0rr9rrr�
test_read_1_0�rPzurlopen_HttpTests.test_read_1_0cCr)Ns1.1rr9rrr�
test_read_1_1�rPzurlopen_HttpTests.test_read_1_1cCs6|jddd�z|�ttd�W|��dS|��w)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
TrKr��rIr��OSErrorrrOr9rrr�test_read_bogus�s�z!urlopen_HttpTests.test_read_boguscCsr|jddd�z,d}|�tjj|��td�Wd�n1s!wYW|��dSW|��dS|��w)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
TrKzRedirection to url 'file:r�)rIr�r�error�	HTTPErrorrrO)r%�msgrrr�test_invalid_redirect�s�
��z'urlopen_HttpTests.test_invalid_redirectc	CsLtt�j�D]}|jddd�z|�tjjtd�W|�	�q|�	�wdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
TrK�http://something)
r�r�maxtriesrIr�rrr
rrO)r%�irrr�test_redirect_limit_independent�s���z1urlopen_HttpTests.test_redirect_limit_independentcCs2|�d�z|�ttd�W|��dS|��w)Nr/rr	r9rrr�test_empty_sockets
z#urlopen_HttpTests.test_empty_socketcCsV|�tjj��}td�Wd�n1swY|�|jj�|�|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	r�rr�URLErrorrr�	exception�filename�reason�r%�errr�test_missing_localfiles

�z(urlopen_HttpTests.test_missing_localfilec	Cs�t��\}}d|�tjjd�}z.|�tj�|��t|��
}|�|�Wd�n1s.wYWt�	|�t�
|�nt�	|�t�
|�w|�tj�|��|�t
jj��
t|�Wd�dS1sjwYdS)Nzfile://localhost/r�)�tempfile�mkstempr�rt�path�sepr�existsrr8�unlinkr�r�rrr)r%�fd�tmp_file�tmp_fileurl�fobjrrr�test_file_notexistss 
��

�
"�z%urlopen_HttpTests.test_file_notexistscCsZd}|�tjj��}t|�Wd�n1swY|�|jj�|�|jj	�dS)Nzftp:///path�
r�rrrrr�rrrr)r%�test_ftp_urlrrrr�test_ftp_nohost!s
�z!urlopen_HttpTests.test_ftp_nohostcCsV|�tjj��}td�Wd�n1swY|�|jj�|�|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.pyr'rrrr�test_ftp_nonexisting(s

�z&urlopen_HttpTests.test_ftp_nonexisting�MAXFTPCACHErcCsF|��ztj�ddddg�tjjd<td�W|��dS|��w)NrS�passr���testzftp://localhost)rbrrr`�ftpcacherrcr9rrr�test_ftp_cache_pruning.s

z(urlopen_HttpTests.test_ftp_cache_pruningcCsl|�d�z+td�}|�|��d�|�|��d�|�|��d�|�|��d�W|��dS|��w)N�HTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/r�r/r�r�)r%r�rrr�test_userpass_inurl7s
z%urlopen_HttpTests.test_userpass_inurlcCs�|�d�zLd}d�|�}tjj}dt|�d���d�}t|�}|�	||j
�d��|�|��d�|�|��d�|�
|��|�|�|��d	�W|��dS|��w)
Nr1za b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8r�r/r�)rI�formatrFrGrHr	�encode�decoder�assertInr#r�r6�assertNotEqualr{r|rO)r%�userpassr�fakehttp_wrapper�
authorizationr�rrr�test_userpass_inurl_w_spacesBs

�z.urlopen_HttpTests.test_userpass_inurl_w_spacescCs>t�dtf��tj��Wd�dS1swYdS�Nr�)rr r!rr�	URLopenerr9rrr�test_URLopener_deprecationUs"�z,urlopen_HttpTests.test_URLopener_deprecationc	Cs�t��}t�dtf��/|�t��tjj	dd|d�Wd�n1s%wYWd�dSWd�dS1s=wYdS)Nr�zhttps://localhostz/nonexistent/path)�cafile�context)
�ssl�create_default_contextrr r!r�r�rrr)r%rArrr�test_cafile_and_contextYs���"�z)urlopen_HttpTests.test_cafile_and_contextN)"r:r;r<r�r�r�r��unittest�
skipUnlessrBr�rrrrrrrrrrrr&r)r*rr_rrr0r2r<r?rDrrrrr�Xs>









	

r�c@s`eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�urlopen_DataTestsz"Test urlopen() opening a data URL.cCs`|�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�
urlcleanuprj�image�text_url�text_url_base64�	image_urlr�
text_url_resp�text_url_base64_resp�image_url_respr9rrrrsfs�����zurlopen_DataTests.setUpcCrw)N)r3r6rxr8rzr{r|r}r~)rr�rNr�rrrr��r�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:,)rQzUS-ASCII)r�rNrzr�r�r�r�rO�
get_paramsrP�strrrJrrrr9rrrr��s���zurlopen_DataTests.test_infocCs@|�|j��|j�|�|j��|j�|�|j��|j�dSr")r�rNr{rKrOrLrPrMr9rrrr��s
�zurlopen_DataTests.test_geturlcC�0|�|j���t|j�����d�|j�dS�NrQ)r�rNr3r6�dictrzrRrjr9rrr�test_read_text�s
��z urlopen_DataTests.test_read_textcCrTrU)r�rOr3r6rVrzrRrjr9rrr�test_read_text_base64�s
��z'urlopen_DataTests.test_read_text_base64cCr�r")r�rPr3rJr9rrr�test_read_image�r�z!urlopen_DataTests.test_read_imagecC�|�ttjjd�dS)Nzdata:text/plain�r�r�rrrr9rrr�test_missing_comma�r�z$urlopen_DataTests.test_missing_commacCrZ)Nzdata:;base64,Cg=r[r9rrr�test_invalid_base64_data��z*urlopen_DataTests.test_invalid_base64_datacCsPt�D]}|�ttjjd|�d��qt�D]}|�ttjjd|�d��qdS)Nzdata:text/html;z,datazdata:text/htmlz;base64,ZGF0YQ==)rr�r�rrr)r%�c0rrr�test_invalid_mediatype�s

�

��z(urlopen_DataTests.test_invalid_mediatypeN)r:r;r<r�rsr�r�r�rWrXrYr\r]r`rrrrrGcs	rGc@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~|�tjj�g|_|�tj�d|_zt	tjd�}|�
|j�|��Wz|��WdSYdSz|��WwYw)Nstesting urllib.urlretrieverf)rHrrrI�	tempFiles�registerFileForCleanUprrkrjrrlr8)r%�FILErrrrs�s	
�
zurlretrieve_FileTests.setUpcCs(|jD]}zt�|�WqYqdSr")rbrtru)r%�eachrrrrv�s

�zurlretrieve_FileTests.tearDowncCsDtj�|�}z|�d�Wntyt�d��wdtj�	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rtr�abspathr5�UnicodeEncodeErrorrE�SkipTestrrr)r%�filePathrrr�constructLocalFileUrl�s
�z+urlretrieve_FileTests.constructLocalFileUrlr/cCslt��\}}z#|�|�t�|d�}|�|�|��Wz|��W|SY|Sz|��WwYw)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.rf)rrrcrt�fdopenrlr8)r%r�newFd�newFilePath�newFilerrr�createNewTempFile�s


��
z'urlretrieve_FileTests.createNewTempFilecCs|j�|�dSr")rb�append)r%�fileNamerrrrc�sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj�dtj�}|�|dtj�|�|dtjj	d�dS)NrgrrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrkr�r�r�r�r�)r%�resultrrr�
test_basic�s
�z urlretrieve_FileTests.test_basiccCs�dtj}|�|�tj�|�tj�|�}|�||d�|�t	j
�|�d�t|d�}z|�
�}|��Wz|��WnYnz|��WwYw|�|j|�dS)N�%s.2rzcopy of the file was not made�rb)rrkrcrrrrrjr�rrtrr rr3r8rj)r%�second_temprsrdrjrrr�	test_copy�s$


��


�
zurlretrieve_FileTests.test_copycsBdgf�fdd�	}dtj}��|�tj���tj�||�dS)NrcsH��|t���|t���|t���||d�|dd|d<dS)Nrr)r�r�r�)�block_count�block_read_size�	file_size�count_holderr9rr�
hooktesters
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterru)rrkrcrrrrrj)r%r}rwrr9r�test_reporthooks


�z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|��}tj�|�|�tj|�|�t|�d�|�|ddd�dS)NcS�|�|||f�dSr"�rp�ryrzr{�_reportrrrr}r�zAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr
�	rorrrrrjrrkr�r�r%�reportr}�srcFileNamerrr�test_reporthook_0_bytess�z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|�d�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd�dS)NcSrr"r�r�rrrr},r�zAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktestersxxxxxr
r�rr�r�rrr�test_reporthook_5_bytes's
�z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|fdd�}|�dd�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd	�|�|ddd	�|�|ddd	�dS)
NcSrr"r�r�rrrr}:r�zDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester�xi �rr
ri r�r�rrr�test_reporthook_8193_bytes5s�z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r/)r:r;r<r�rsrvrjrorcrtrxr~r�r�r�rrrrra�s
	rac@� eZdZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionsc	Cs~|�tjj�|�d�dd�}|�tjj��ztjjt	j
|d�W|��n|��wWd�dS1s8wYdS)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
cSrCr"r)�par1�par2�par3rrr�_reporthookVrDzYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthook)�
reporthook�rHrrrIrIr�r�ContentTooShortErrorrrr�
TEST_HTTP_URLrO)r%r�rrr�.test_short_content_raises_ContentTooShortErrorIs


�"�zDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc	Csr|�tjj�|�d�|�tjj��z
tj�t	j
�W|��n|��wWd�dS1s2wYdS)Nr�r�r9rrr�Atest_short_content_raises_ContentTooShortError_without_reporthook`s
	"�zWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r:r;r<r�r�r�rrrrr�Fsr�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

    cCsVd�gd��}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nr�)�ABCDEFGHIJKLMNOPQRSTUVWXYZ�abcdefghijklmnopqrstuvwxyz�
0123456789z_.-~�using quote(): %r != %r�using quote_plus(): %r != %r)�joinrrnror��
quote_plus)r%�do_not_quotersrrr�test_never_quote�s
�
�zQuotingTests.test_never_quotecCs|�tjjjdd�dS)Nrr�)r�rrnro�__defaults__r9rrr�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<>��safer�r�s<>uaüb�latin-1�ü)�encodingr�r���)rrnror�r�)r%�quote_by_defaultrs�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�q~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%5Dcdr�r�)
r�rpr�r�rrnror�rr�)r%�should_quoterrs�
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�r��+zusing quote_plus(): %r != +z
a b cd e fr�)rrnror�rr�r�)r%rs�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+gammar�zalpha+beta+gammasalpha+beta gamma�+)r�rrnr�r9rrr�test_quoting_plus�s����zQuotingTests.test_quoting_pluscCsfd}d}tj�|�}|�||d||f�|jttjj|dd�tj�|�}|�||d||f�dS)N���ab��%A2%D8ab%FFr�r��r�z"using quote_from_bytes(): %r != %r)rrnror�r��	TypeError�quote_from_bytes�r%r�r�rsrrr�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%BFr��r��errorsr�r�r��漢字�%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rrnror�r�rgr�rrr�test_quote_with_unicodesT
�
�
�
��
�
�
�
�z$QuotingTests.test_quote_with_unicodecCsbd}d}tjj|dd�}|�||d||f�d}d}tjj|ddd	�}|�||d||f�dS)
Nu¢Ø ÿz
%A2%D8+%FFr�r�r�uab漢字 cdzab%3F%3F+cdr�r�)rrnr�r�r�rrr�test_quote_plus_with_unicode0s
�
�
�z)QuotingTests.test_quote_plus_with_unicodeN)
r:r;r<r�r�r�r�r�r�r�r�r�r�rrrrr�ss
*r�c@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.

    cCs�g}td�D]3}tt|��}t|�}tj�|�}|�||d||f�tj�|�}|�||d||f�|�|�qd�	|�}~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�rrn�unquoter��unquote_plusrpr��countr�r��AttributeError)r%�escape_listr�r�r�rs�
escape_stringrrr�test_unquotingGs2
���
��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re�"using unquote_to_bytes(): %r != %rr)	rrnr�r�rh�unquote_to_bytesr�r�r�r�rrr�test_unquoting_badpercent^sL
�
�
�

�

�

�z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj�|�}|�||d||f�dS)Nz%Ab%eAs��r��rrnr�r�r�rrr�test_unquoting_mixed_case�s��z(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nzab%sd�c�abcdr�r�)rrrnr�r�r�r�rrr�test_unquoting_parts�s
�
�z#UnquotingTests.test_unquoting_partscCs\d}|}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nzare+there+spaces...r�r�r�r�)rrnr�r�r�r�r�rrr�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%FFr�s	%A2�ab%FFr�r�rrr�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�r�zbr%FCckner_sapporo_20050930.docr�r�r�r�z%F3%B1u�r�)r�r��ignorer�u漢üu漢%FC�rrnr�r�r�rrr�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blueberryjam�blueberryjamr�sblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjr�r�rrr�test_unquoting_with_bytes_input�s$
�
�
�z.UnquotingTests.test_unquoting_with_bytes_inputN)r:r;r<r�r�r�r�r�r�r�r�r�rrrrr�@s$	:r�c@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�gd�}tj�|�}|D]}|�||d|||f�q|�|�d�dd||�d�f�|�d�}||d}||d}|�|��oF|��d||f�|�t	|�dd	|t	|�df�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�&r
z#testing %s: expected 2 '&'s; got %srz1testing %s: '&' not located in proper place in %s�z5testing %s: unexpected number of characters: %s != %sN)
rrn�	urlencoder7r�r��indexr�isdigitr)	r%r��	test_type�expect_somewherersr��amp_location�on_amp_left�on_amp_rightrrr�help_inputtypes4����
����zurlencode_Tests.help_inputtypecCs|�dddd�d�dS)N�1�2�3)�1st�2nd�3rdzusing dict as input type�r�r9rrr�test_using_mapping6s�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�r9rrr�test_using_sequence;s
�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)rrrnr�r�r�rrr�test_quoting@szurlencode_Tests.test_quotingcCs�dgd�i}dtj�tgd���}tj�|�}|�||�tj�|d�}|dD]}d|}|�||�q)|�|�d�dd|�d��dS)N�sequence)r�r�r�zsequence=%sTr�r
zExpected 2 '&'s, got %s)rrnr�rSr�r�r7r�)r%r�r�rs�valuerrr�
test_doseqKs�zurlencode_Tests.test_doseqcCs,|�dtj�i��|�dtj�g��dSr=�r�rrnr�r9rrr�test_empty_sequenceXsz#urlencode_Tests.test_empty_sequencecCs4|�dtj�ddi��|�dtj�ddi��dS)Nza=1�arza=Nonerr9rrr�test_nonstring_values\sz%urlencode_Tests.test_nonstring_valuescCsh|�dtj�dddgid��|�dtj�dddgid��t�ddg�}|�d	tj�d|id��dS)
Nza=1&a=2rrr
Tz
a=None&a=a)rr)�brza=a&a=b)r�rrnr�r�r�r$rrr�test_nonstring_seq_values`s��z)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|�||�d}d}tj�|�}|�||�d}d}tjj|dd	�}|�||�dS)
N�)� �Á�%3F=%3Fr3r�r��
%C2%A0=%C3%81�%A0=%C1r�r��rrnr�r�r�rrr�test_urlencode_encodinghs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)Nrr	Tr3r�)�doseqr�r�))r)rrz
%3F=1&%3F=%3Fr�r
))r)�*rz%C2%A0=42&%C2%A0=%C3%81rr�r�z%A0=42&%A0=%C1rr�rrr�test_urlencode_encoding_doseq{s8
�
�z-urlencode_Tests.test_urlencode_encoding_doseqcCs`d}d}tj�|�}|�||�tj�|d�}|�||�d}d}tj�|d�}|�||�dS)N�)��$��$z
%A0%24=%C1%24T))r)rrz%A0%24=42&%A0%24=%C1%24rr�rrr�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)Nrz:$r�z	%A0$=%C1$T)rr�))r)r�
rz%A0$=%C1$&%A0$=13&%A0$=42r�)r�r�)rr�r�r)r%r�rsr�rrr�&test_urlencode_encoding_safe_parameter�s:
���z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r:r;r<r�r�r�r�r�r�rrrr
rrrrrrrr�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�parts�ofrrzparts/of/a/path�pathname2url() failed; %s != %szurl2pathame() failed; %s != %s)rtrr�rrrr�r)r%�
expected_path�expected_urlrsrrrrt�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)
N�needszquot=ing�herez
needs/%s/hererzurl2pathname() failed; %s != %sz	make sure�using_quotez%s/using_quotezmake+sure/using_unquotez	make+sure�
using_unquote)
rtrr�rrnrorrr�rr�rrrr��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:/dirrz\\?\unc\server\share\dirz/server/share/dir)rrrr�r�rrr�
test_prefixess ����zPathname_Tests.test_prefixesz.test specific to the urllib.url2path function.cCsbd}d}|D]}tj�|�}|�||d||f�qd}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)rrrr�)r%r�r�rrsrrr�test_ntpaths"����zPathname_Tests.test_ntpathN)r:r;r<r�rtr�rErF�sys�platformr"r$rrrrr�s
�
�rc@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)r�rr�thishost�tupler9rrr�
test_thishost'r^zUtility_Tests.test_thishostN)r:r;r<r�r*rrrrr'$sr'c@sTeZdZdZdd�Zejed�dd��Zejed�dd��Z	ejed�d	d
��Z
dS)�URLopener_Testsz4Testcase to test the open method of URLopener class.cCspGdd�dtjj�}t�dtf��|�|��d�d�|�|��d�d�Wd�dS1s1wYdS)Nc@�eZdZdd�ZdS)z8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenercS�|Sr"r�r%rrrr�	open_spam1rDzBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spamN)r:r;r<r/rrrr�DummyURLopener0�r0z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr>rr r!r�r)r%r0rrr�test_quoted_open/s"��
��
��"�z URLopener_Tests.test_quoted_open)�categorycCs�t���6}tj|d�\}}t�|�dtj�|�}tj�	��
|�\}}|�tj�
|�tj�
|��Wd�dS1s=wYdS)N)�dirzfile:)r�temp_dirrrrtr8rrrr>�retriever�r�normcase)r%�tmpdirr"�tmpfile�fileurlr�_rrr�test_urlopener_retrieve_file>s

"�z,URLopener_Tests.test_urlopener_retrieve_filecCsJd}|�d�|�|j�tj���|�\}}|�tj	�
|�dd�dS)Nzhttp://www.python.org/file.txtr�rz.txt)rIrHrOrrr>r6r�rtr�splitext)r%rrr;rrr�test_urlopener_retrieve_remoteHs

z.URLopener_Tests.test_urlopener_retrieve_remotecCs�Gdd�dtjj�}dD]3}|�ttjj|�|�ttj��j|�|�ttj��j|�|�t|�j|�|�t|�j|�qdS)Nc@r,)z<URLopener_Tests.test_local_file_open.<locals>.DummyURLopenercSr-r"rr.rrr�open_local_fileTrDzLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileN)r:r;r<r?rrrrr0Sr1r0)zlocal_file://examplezlocal-file://example)rrr>r�r
rrr6)r%r0rrrr�test_local_file_openPs�z$URLopener_Tests.test_local_file_openN)r:r;r<r�r2r�ignore_warningsr!r<r>r@rrrrr+,s


	

r+c@r�)�RequestTestsz&Unit tests for urllib.request.Request.cCs>tjj}|d�}|�|��d�|di�}|�|��d�dS)Nr�r��POST)rr�Requestr��
get_method�r%rDrrrr�test_default_valuesas

z RequestTests.test_default_valuescCs�tjj}|ddd�}|�|jd�|�|��d�|didd�}|�|jd�|�|��d�|ddd�}|�|��d�d|_|�|��d�dS)Nr��HEAD)�methodr�)rrrDr�rIrErFrrr�test_with_method_arghsz!RequestTests.test_with_method_argN)r:r;r<r�rGrJrrrrrB^srBc@�4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCs4|�td�d�|�td�d�|�td�d�dS)Nz///C|�C:�///C:z///C|/r#�r�rr9rrr�test_converting_drive_letterxsz.URL2PathNameTests.test_converting_drive_lettercCs$|�td�d�|�td�d�dS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\rOr9rrr�$test_converting_when_no_drive_letter}sz6URL2PathNameTests.test_converting_when_no_drive_lettercC�|�td�d�dS)Nz///C|/foo/bar/spam.foo�C:\foo\bar\spam.foorOr9rrr�test_simple_compare��
�z%URL2PathNameTests.test_simple_comparecC�|�ttd�dS)Nu///è|/)r��IOErrorrr9rrr�test_non_ascii_drive_letter�r�z-URL2PathNameTests.test_non_ascii_drive_lettercC�*gd�}|D]}|�tt|��|�qdS)N)rMz\\\C\test\\rS)r�rr�r%�
list_of_pathsrrrr�test_roundtrip_url2pathname�s�z-URL2PathNameTests.test_roundtrip_url2pathnameN)r:r;r<rPrQrTrXr\rrrrrLvsrLc@rK)�PathName2URLTestscCs$|�td�d�|�td�d�dS)NrMrNr#�r�rr9rrrrP�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^r9rrrrQ�s
�
�
�z6PathName2URLTests.test_converting_when_no_drive_lettercCrR)NrS�///C:/foo/bar/spam.foor^r9rrrrT�rUz%PathName2URLTests.test_simple_comparecCrV)NzXX:\)r�rWrr9rrr�test_long_drive_letter�r�z(PathName2URLTests.test_long_drive_lettercCrY)N)rNr_r`)r�rrrZrrr�test_roundtrip_pathname2url�s�z-PathName2URLTests.test_roundtrip_pathname2urlN)r:r;r<rPrQrTrarbrrrrr]�sr]�__main__)NNrQ)9r��urllib.parser�urllib.request�urllib.error�http.clientrF�
email.messager�r1rE�
unittest.mockrr.r�test.supportrrrrtrB�ImportErrorr%r�
nturl2pathrr�base64r	r�rrrrrIr_rJrR�TestCaserdr�r�r�rGrar�r�r�r�rr'r+rBrLr]r:�mainrrrr�<module>sp�

/
]L$
T-NTDN2
�

Youez - 2016 - github.com/yon3zu
LinuXploit