403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_urllib.cpython-36.pyc
3

x2_��@s@dZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlZyddlZWnek
r�dZYnXddlZddlZddlZddlmZmZddlmZddlZdd�Zdad4d	d
�Zdd�Zd
d�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)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,e
j#�Z0Gd-d.�d.e
j#�Z1Gd/d0�d0e
j#�Z2Gd1d2�d2e
j#�Z3e4d3k�r<e
j5�dS)5z;Regression tests for what was in Python 2's "urllib" module�N)�patch)�support)�url2pathname�pathname2url)�	b64encodecCs4tt|��dd�j�}t|�dkr,d|}d|S)z!Escape char as RFC 2396 specifies�N�z0%s�%)�hex�ord�upper�len)�charZhex_repr�r�5/opt/alt/python36/lib64/python3.6/test/test_urllib.py�	hexescapesrcCsN|dk	rtjj|d�}nts(t�}|ant}|dkr>|j|�S|j||�SdS)z.urlopen(url [, data]) -> open file-like objectN)�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datar�openerrrr�urlopen%s
rc	Cs$tjdtf��tjj�SQRXdS)Nz8FancyURLopener style of invoking requests is deprecated.)r�check_warnings�DeprecationWarningrrrrrrrr5s
rcs8G�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�makefileCsz%fakehttp.<locals>.FakeSocket.makefileNcSs|jr
dStjj||�S)N�)�closed�io�BytesIO�read)rZamtrrrr*Gsz!fakehttp.<locals>.FakeSocket.readcSs|jr
dStjj||�S)Nr&)r'r(r)�readline)rZlengthrrrr+Lsz%fakehttp.<locals>.FakeSocket.readlinecSs(|jd8_|jdkr$tjj|�dS)Nrr)r"r(r)�close)rrrrr,Qs
z"fakehttp.<locals>.FakeSocket.close)N)N)	�__name__�
__module__�__qualname__r"r!r%r*r+r,r)r rr�
FakeSocket=s

r0cseZdZdZ�fdd�ZdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs�|j�|_|jt|�_dS)N)�fakedataZsock�typeZfakesock)r)r0rr�connect[sz,fakehttp.<locals>.FakeHTTPConnection.connect)r-r.r/rr3r)r0rrr Vsr )r(r)�http�client�HTTPConnectionr1)r1r)r r0r�fakehttp<sr7c@seZdZdd�Zdd�ZdS)�
FakeHTTPMixincCstjj|_t|�tj_dS)N)r4r5r6�_connection_classr7)rr1rrrr7ds
zFakeHTTPMixin.fakehttpcCs|jtj_dS)N)r9r4r5r6)rrrr�
unfakehttphszFakeHTTPMixin.unfakehttpN)r-r.r/r7r:rrrrr8csr8c@seZdZdd�Zdd�ZdS)�FakeFTPMixincCs&Gdd�dt�}tjj|_|tj_dS)Nc@s&eZdZd	dd�Zdd�Zdd�ZdS)
z,FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNTcSsdS)Nr)r�userZpasswd�hostZport�dirsZtimeoutZ
persistentrrr�__init__osz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__cSstj�dfS)Nr)r(r))r�filer2rrr�retrfilessz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSsdS)Nr)rrrrr,vsz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)NT)r-r.r/r?rAr,rrrr�FakeFtpWrapperns
rB)�objectrr�
ftpwrapper�_ftpwrapper_class)rrBrrr�fakeftpms
zFakeFTPMixin.fakeftpcCs|jtj_dS)N)rErrrD)rrrr�	unfakeftp|szFakeFTPMixin.unfakeftpN)r-r.r/rFrGrrrrr;lsr;c@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|j�Wd|j�Xtj|_	t
d|j	�|_dS)Nztest_urllib: %s
�ascii�wbzfile:%s)�bytes�	__class__r-�textrr�TESTFN�writer,�pathnamer�returned_obj)r�frrr�setUp�s
zurlopen_FileTests.setUpcCs|jj�tjtj�dS)zShut down the open objectN)rQr,�os�removerrN)rrrr�tearDown�s
zurlopen_FileTests.tearDownc	Cs*x$dD]}|jt|j|�d
|�qWdS)Nr*r+�	readlines�filenor,�info�geturl�getcode�__iter__z/object returned by urlopen() lacks %s attribute)	r*r+rWrXr,rYrZr[r\)�
assertTrue�hasattrrQ)r�attrrrr�test_interface�s
z urlopen_FileTests.test_interfacecCs|j|j|jj��dS)N)�assertEqualrMrQr*)rrrr�	test_read�szurlopen_FileTests.test_readcCs,|j|j|jj��|jd|jj�d�dS)Nr&zKcalling readline() after exhausting the file did not return an empty string)rarMrQr+)rrrr�
test_readline�szurlopen_FileTests.test_readlinecCs4|jj�}|jt|�dd�|j|d|jd�dS)Nrz.readlines() returned the wrong number of linesrz"readlines() returned improper text)rQrWrar
rM)rZ
lines_listrrr�test_readlines�s

z urlopen_FileTests.test_readlinescCs:|jj�}|j|td�|jtj|t|j��|jd�dS)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text)	rQrX�assertIsInstance�intrarTr*r
rM)rZfile_numrrr�test_fileno�s
zurlopen_FileTests.test_filenocCs|jj�dS)N)rQr,)rrrr�
test_close�szurlopen_FileTests.test_closecCs|j|jj�tjj�dS)N)rerQrY�email�message�Message)rrrr�	test_info�szurlopen_FileTests.test_infocCs|j|jj�|j�dS)N)rarQrZrP)rrrr�test_geturl�szurlopen_FileTests.test_geturlcCs|j|jj��dS)N)ZassertIsNonerQr[)rrrr�test_getcode�szurlopen_FileTests.test_getcodecCs"x|jD]}|j||j�qWdS)N)rQrarM)r�linerrr�	test_iter�szurlopen_FileTests.test_itercCs|jttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrrP)rrrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r-r.r/�__doc__rSrVr`rbrcrdrgrhrlrmrnrprsrrrrrH�s	rHc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
ProxyTestscCs:tj�|_x*ttj�D]}d|j�kr|jj|�qWdS)N�proxy)rZEnvironmentVarGuard�env�listrT�environ�lower�unset)r�krrrrS�s
zProxyTests.setUpcCs|jj�|`dS)N)rw�__exit__)rrrrrV�s
zProxyTests.tearDowncCsp|jjdd�tjj�}|jd|d�|jjdd�|jtjjd��|jtjjd��|jtjjd��dS)N�NO_PROXY�	localhost�noz0localhost, anotherdomain.com, newdomain.com:1234zanotherdomain.comzanotherdomain.com:8888znewdomain.com:1234)rw�setrr�getproxies_environmentrar]�proxy_bypass_environment)rrrrr�+test_getproxies_environment_keep_no_proxies�s
z6ProxyTests.test_getproxies_environment_keep_no_proxiescCspzP|jjdd�tjj�}|jd|d�|jjdd�tjj�}|jd|�Wd|jjd�|jjd�XdS)N�
HTTP_PROXYzhttp://somewhere:3128r4ZREQUEST_METHOD�GET)rwr�rrr�ra�assertNotInr{)rrrrr�test_proxy_cgi_ignore�s

z ProxyTests.test_proxy_cgi_ignorecCs�tjj}|jjdd�|j|d��|j|d��|j|d��|j|d��|j|d��|j|d��|j|d	��|j|d
��|j|d��|j|d��dS)
Nr~z8localhost, anotherdomain.com, newdomain.com:1234, .d.o.trZ	LocalHostZ	LOCALHOSTznewdomain.com:1234z	foo.d.o.tzanotherdomain.com:8888zwww.newdomain.com:1234Zprelocalhostz
newdomain.comznewdomain.com:1235)rrr�rwr�r]�assertFalse)rZbypassrrr�(test_proxy_bypass_environment_host_match�sz3ProxyTests.test_proxy_bypass_environment_host_matchN)r-r.r/rSrVr�r�r�rrrrru�s
ruc@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_tj�t_dS)N)rTry�
_saved_env�collections�OrderedDict)rrrrrSszProxyTests_withOrderedEnv.setUpcCs|jt_dS)N)r�rTry)rrrrrVsz"ProxyTests_withOrderedEnv.tearDowncCsdtjd<dtjd<|jtjjd��|jtjjd��dtjd<dtjd<tjj�}|ji|�d	tjd<d
tjd<|jtjjd��|jtjjd��|jtjjd��|jtjjd
��|jtjjd��dtjd<dtjd<tjj�}|jd|d�dS)N�Zno_proxyrZNo_ProxyZ	arbitraryZ
http_proxyzhttp://somewhere:3128r�z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128Z
Http_Proxyr4)	rTryr�rrr�r�rar])rrrrr�,test_getproxies_environment_prefer_lowercases&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r-r.r/rSrVr�rrrrr�	sr�c@seZdZdZdd�Zdd�Zdd�Zeje	d�d	d
��Z
eje	d�dd��Zeje	d�d
d��Zeje	d�dd��Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zejejd'd(�d)d*��Zd+d,�Zd-d.�Zd/d0�Z eje	d�d1d2��Z!d3S)4�urlopen_HttpTestsz.Test urlopen() opening a fake http connection.c
Csn|jd|d�zLtd�}|j|j�d�|j|j�d�|j|j�d�|j|j�d�Wd|j�XdS)NsHTTP/s 200 OK

Hello!zhttp://python.org/sHello!r&��)r7rrar+rZr[r:)rZver�fprrr�
check_read0szurlopen_HttpTests.check_readc
Cs>d}|jd�z tjj|�}|j|j�|�Wd|j�XdS)Nz-http://docs.python.org/library/urllib.html#OKsHTTP/1.1 200 OK

Hello!)r7rrrrarZr:)rrr�rrr�test_url_fragment;s
z#urlopen_HttpTests.test_url_fragmentc
Cs4|jd�ztd�}|j|jj�Wd|j�XdS)NsHTTP/1.1 200 OK

Hello!zhttp://www.python.org)r7rr]r�Z
will_closer:)r�resprrr�test_willcloseEs

z urlopen_HttpTests.test_willclosezssl module requiredcCs�x�ttdd��dgD]�}t|�}d|�d�}|jd�z�t|�jdd�}tjj}|j	|d	|����t
jjd
|���WdQRX|j	|d	|����t
jjd|���WdQRXtd
|���}|j
||j��Wd|j�XqWdS)Nr�!�z//localhost:7777/test�/sHTTP/1.1 200 OK

Hello.�\z\\zcontain control.*zhttp:zhttps:)rx�range�chrr7�repr�replacer4r5�
InvalidURL�assertRaisesRegexrrrr�rZr:)r�char_nor�schemeless_url�escaped_char_reprr�r�rrr�(test_url_path_with_control_char_rejectedMs 
z:urlopen_HttpTests.test_url_path_with_control_char_rejectedcCs�|jd�d}d|d}z�tjj}|j|d��tjjd|���WdQRX|j|d��tjjd|���WdQRXtd|���}|jd	|j	��|jd
|j	��|jd|j	��Wd|j
�XdS)NsHTTP/1.1 200 OK

Hello.z:localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123z//z:8080/test/?test=az*contain control.*\\r.*(found at least . .)zhttp:zcontain control.*\\nzhttps:� �
�
)r7r4r5r�r�rrrr�rZr:)rr=r�r�r�rrr�4test_url_path_with_newline_header_injection_rejectedhs

zFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejectedcCs�x�ttdd��dgD]�}t|�}d|�d�}|jd�ztt|�jdd�}tjj}|j	|d	|����t
d
|���WdQRX|j	|d	|����t
d|���WdQRXWd|j�XqWdS)Nrr�r�z//localhostz/test/sHTTP/1.1 200 OK

Hello.r�z\\zcontain control.*zhttp:zhttps:)rxr�r�r7r�r�r4r5r�r�rr:)rr�rr�r�r�rrr�(test_url_host_with_control_char_rejected�s
z:urlopen_HttpTests.test_url_host_with_control_char_rejectedcCs�|jd�d}d|d}zXtjj}|j|d��td|���WdQRX|j|d��td|���WdQRXWd|j�XdS)	NsHTTP/1.1 200 OK

Hello.zlocalhost
X-injected: header
z//z:8080/test/?test=azcontain control.*\\rzhttp:zcontain control.*\\nzhttps:)r7r4r5r�r�rr:)rr=r�r�rrr�4test_url_host_with_newline_header_injection_rejected�s

zFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejectedcCs|jd�dS)Ns0.9)r�)rrrr�
test_read_0_9�szurlopen_HttpTests.test_read_0_9cCs|jd�dS)Ns1.0)r�)rrrr�
test_read_1_0�szurlopen_HttpTests.test_read_1_0cCs|jd�dS)Ns1.1)r�)rrrr�
test_read_1_1�szurlopen_HttpTests.test_read_1_1c
Cs,|jd�z|jttd�Wd|j�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
zhttp://python.org/)r7rq�OSErrorrr:)rrrr�test_read_bogus�s
z!urlopen_HttpTests.test_read_boguscCsF|jd�z,d}|jtjj|��td�WdQRXWd|j�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
zRedirection to url 'file:zhttp://python.org/)r7r�r�error�	HTTPErrorrr:)r�msgrrr�test_invalid_redirect�sz'urlopen_HttpTests.test_invalid_redirectcCsFx@tt�j�D]0}|jd�z|jtjjtd�Wd|j	�XqWdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
zhttp://something)
r�rZmaxtriesr7rqrr�r�rr:)r�irrr�test_redirect_limit_independent�s
z1urlopen_HttpTests.test_redirect_limit_independentc
Cs,|jd�z|jttd�Wd|j�XdS)Nr&zhttp://something)r7rqr�rr:)rrrr�test_empty_socket�s
z#urlopen_HttpTests.test_empty_socketc	CsB|jtjj��}td�WdQRX|j|jj�|j|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	rqrr��URLErrorrr]�	exception�filename�reason)r�errr�test_missing_localfile�sz(urlopen_HttpTests.test_missing_localfilecCs�tj�\}}d|jtjjd�}z4|jtjj|��t|��}|j|�WdQRXWdtj	|�tj
|�X|jtjj|��|jt
jj��t|�WdQRXdS)Nzfile://localhost/r�)�tempfile�mkstempr�rT�path�sepr]�existsrr,�unlinkr�rqrr�r�)r�fdZtmp_fileZtmp_fileurlZfobjrrr�test_file_notexists�s

z%urlopen_HttpTests.test_file_notexistsc	CsFd}|jtjj��}t|�WdQRX|j|jj�|j|jj	�dS)Nzftp:///path)
rqrr�r�rr�r�r�r]r�)rZtest_ftp_urlr�rrr�test_ftp_nohost�s
z!urlopen_HttpTests.test_ftp_nohostc	CsB|jtjj��}td�WdQRX|j|jj�|j|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.py)
rqrr�r�rr�r�r�r]r�)rr�rrr�test_ftp_nonexisting�sz&urlopen_HttpTests.test_ftp_nonexistingZMAXFTPCACHErcCs@|j�z(tjjddddg�tjjd<td�Wd|j�XdS)Nr<�passr��testzftp://localhost)rFrrrDZftpcacherrG)rrrr�test_ftp_cache_prunings
z(urlopen_HttpTests.test_ftp_cache_pruningc
Csf|jd�zLtd�}|j|j�d�|j|j�d�|j|j�d�|j|j�d�Wd|j�XdS)NsHTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/sHello!r&r�)r7rrar+rZr[r:)rr�rrr�test_userpass_inurls
z%urlopen_HttpTests.test_userpass_inurlc
Cs�|jd�z�d}dj|�}tjj}dt|jd��jd�}t|�}|j	||j
jd��|j|j�d�|j|j�d�|j
|j�|�|j|j�d	�Wd|j�XdS)
NsHTTP/1.0 200 OK

Hello!za b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8sHello!r&r�)r7�formatr4r5r6r�encode�decoder�assertInrrar+ZassertNotEqualrZr[r:)rZuserpassrZfakehttp_wrapperZ
authorizationr�rrr�test_userpass_inurl_w_spacess

z.urlopen_HttpTests.test_userpass_inurl_w_spacesc	Cs(tjdtf��tjj�WdQRXdS)Nr�)rrrrr�	URLopener)rrrr�test_URLopener_deprecation*sz,urlopen_HttpTests.test_URLopener_deprecationcCsNtj�}tjdtf��.|jt��tjj	dd|d�WdQRXWdQRXdS)Nr�zhttps://localhostz/nonexistent/path)Zcafile�context)
�sslZcreate_default_contextrrrrqrrrrr)rr�rrr�test_cafile_and_context.s
z)urlopen_HttpTests.test_cafile_and_contextN)"r-r.r/rtr�r�r��unittest�
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrCrrr�r�r�r�r�rrrrr�-s0

		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|_tjj|j�|_tjj|j�|_	tjj|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)rM�image�text_url�text_url_base64�	image_urlrrr�
text_url_resp�text_url_base64_resp�image_url_resp)rrrrrS;s
zurlopen_DataTests.setUpcCs*x$d
D]}|jt|j|�d	|�qWdS)Nr*r+rWr,rYrZr[r\z/object returned by urlopen() lacks %s attribute)r*r+rWr,rYrZr[r\)r]r^r�)rr_rrrr`Ws
z urlopen_DataTests.test_interfacecCst|j|jj�tjj�|j|jj�j�dd	g�|j|j	j�dt
t|j���|jt
jjd�j�j�d
dg�dS)N�
text/plainr��charset�
ISO-8859-1zcontent-lengthzdata:,�US-ASCII)r�r�)r�r�)r�r�)r�r�)rer�rYrirjrkrar��
get_paramsr��strr
r�rrr)rrrrrl_s
zurlopen_DataTests.test_infocCs@|j|jj�|j�|j|jj�|j�|j|jj�|j�dS)N)rar�rZr�r�r�r�r�)rrrrrmhszurlopen_DataTests.test_geturlcCs0|j|jj�jt|jj�j��d�|j�dS)Nr�)rar�r*r��dictrYr�rM)rrrr�test_read_textnsz urlopen_DataTests.test_read_textcCs0|j|jj�jt|jj�j��d�|j�dS)Nr�)rar�r*r�r�rYr�rM)rrrr�test_read_text_base64rsz'urlopen_DataTests.test_read_text_base64cCs|j|jj�|j�dS)N)rar�r*r�)rrrr�test_read_imagewsz!urlopen_DataTests.test_read_imagecCs|jttjjd�dS)Nzdata:text/plain)rqrrrrr)rrrr�test_missing_commazsz$urlopen_DataTests.test_missing_commacCs|jttjjd�dS)Nzdata:;base64,Cg=)rqrrrrr)rrrr�test_invalid_base64_data}sz*urlopen_DataTests.test_invalid_base64_dataN)
r-r.r/rtrSr`rlrmr�r�r�r�r�rrrrr�8s	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 filescCs^g|_|jtj�d|_z$ttjd�}|j|j�|j�Wdy|j�WnYnXXdS)Nstesting urllib.urlretrieverJ)�	tempFiles�registerFileForCleanUprrNrMrrOr,)r�FILErrrrS�szurlretrieve_FileTests.setUpc
Cs0x*|jD] }ytj|�WqYqXqWdS)N)r�rTrU)rZeachrrrrV�s
zurlretrieve_FileTests.tearDowncCsJtjj|�}y|jd�Wntk
r8tjd��YnXdtjj	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rTr��abspathr��UnicodeEncodeErrorr�ZSkipTestrrr)rZfilePathrrr�constructLocalFileUrl�sz+urlretrieve_FileTests.constructLocalFileUrlr&cCsZtj�\}}z,|j|�tj|d�}|j|�|j�Wdy|j�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.rJN)r�r�r�rT�fdopenrOr,)rrZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s

z'urlretrieve_FileTests.createNewTempFilecCs|jj|�dS)N)r��append)rZfileNamerrrr��sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tjjdtj�}|j|dtj�|j|dtjj	d�dS)Nzfile:%srrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrNrarerirjrk)r�resultrrr�
test_basic�sz urlretrieve_FileTests.test_basiccCs�dtj}|j|�tjj|jtj�|�}|j||d�|jt	j
j|�d�t|d�}z|j
�}|j�Wdy|j�WnYnXX|j|j|�dS)Nz%s.2rzcopy of the file was not made�rb)rrNr�rrr�r�rar]rTr�r�rr*r,rM)r�second_tempr�r�rMrrr�	test_copy�s



zurlretrieve_FileTests.test_copycsBdgf�fdd�	}dtj}�j|�tjj�jtj�||�dS)NrcsH�j|t��j|t��j|t��j||d�|dd|d<dS)Nrr)rerfra)�block_count�block_read_size�	file_sizeZcount_holder)rrr�
hooktester�s
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterz%s.2)rrNr�rrr�r�)rrr�r)rr�test_reporthook�s


z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|j�}tjj|j|�tj|�|jt|�d�|j|ddd�dS)NcSs|j|||f�dS)N)r�)r�r�r�_reportrrrr�szAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr)	r�rrr�r�rrNrar
)r�reportr�srcFileNamerrr�test_reporthook_0_bytes�s
z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|jd�}tjj|j|�tj|�|jt|�d�|j|ddd�|j|ddd�dS)	NcSs|j|||f�dS)N)r�)r�r�rrrrrr�szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktester�x�rrrsxxxxx)	r�rrr�r�rrNrar
)rrrrrrr�test_reporthook_5_bytes�s

z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|fdd�}|jdd�}tjj|j|�tj|�|jt|�d�|j|ddd�|j|ddd	�|j|ddd	�|j|ddd	�dS)
NcSs|j|||f�dS)N)r�)r�r�rrrrrrszDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktesterri �rrri )	r�rrr�r�rrNrar
)rrrrrrr�test_reporthook_8193_bytes�s
z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r&)r-r.r/rtrSrVr�r�r�r�r�rrr	rrrrrr��s
	r�c@s eZdZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionscCsP|jd�dd�}|jtjj��&ztjjd|d�Wd|j�XWdQRXdS)Ns�HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Length: 100
Content-Type: text/html; charset=iso-8859-1

FF
cSsdS)Nr)Zpar1Zpar2Zpar3rrr�_reporthookszYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthookzhttp://example.com/)Z
reporthook)r7rqrr��ContentTooShortErrorrr�r:)rr
rrr�.test_short_content_raises_ContentTooShortErrorszDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorcCsD|jd�|jtjj��"ztjjd�Wd|j�XWdQRXdS)Ns�HTTP/1.1 200 OK
Date: Wed, 02 Jan 2008 03:03:54 GMT
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
Connection: close
Content-Length: 100
Content-Type: text/html; charset=iso-8859-1

FF
zhttp://example.com/)r7rqrr�rrr�r:)rrrr�Atest_short_content_raises_ContentTooShortError_without_reporthook&szWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r-r.r/rtrrrrrrr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 2396 (Uniform Resource Identifiers), to escape a
    character you write it as '%' + <2 character US-ASCII hex value>.
    The Python code of ``'%' + hex(ord(<character>))[2:]`` escapes a
    character properly. Case does not matter on the hex letters.

    The various character sets specified are:

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

    cCsZdjddddg�}tjj|�}|j||d||f�tjj|�}|j||d||f�dS)Nr�ZABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyz�
0123456789z_.-zusing quote(): %r != %rzusing quote_plus(): %r != %r)�joinr�parse�quotera�
quote_plus)rZdo_not_quoter�rrr�test_never_quoteQszQuotingTests.test_never_quotecCs|jtjjjdd�dS)Nrr�)rarrr�__defaults__)rrrr�test_default_safe^szQuotingTests.test_default_safecCs�d}tjj||d�}|j||d||f�tjj||d�}|j||d||f�tjj|dd�}|j||d||f�tjjdddd	�}tjjddd
d	�}|j||d||f�tjjdddd	�}tjjddd
d	�}|j||d||f�dS)Nz<>)�safezusing quote(): %r != %rzusing quote_plus(): %r != %rs<>uaübzlatin-1�ü)�encodingrr���)rrrrar)rZquote_by_defaultr��expectrrr�	test_safebs,zQuotingTests.test_safecCs�dd�td�D�}|jd�|jtd��dj|�}xd|D]\}tjj|�}|jt|�|d|t|�|f�tjj	|�}|jt|�|d|t|�|f�q:W~d	}d
}tjj|�}|j||d||f�tjj	|�}|j||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%5Dcdzusing quote(): %r != %rzusing quote_plus(): %r != %r)
r�r�r�rrrrrarr)rZshould_quoterr�Z
partial_quote�expectedrrr�test_default_quotings,


z!QuotingTests.test_default_quotingcCs�tjjd�}|j|td�d|td�f�tjjd�}|j|dd|�d}|jdtd��}tjj|�}|j||d||f�|jdd�}tjj|�}|j||d||f�dS)Nr�zusing quote(): %r != %r�+zusing quote_plus(): %r != +z
a b cd e fzusing quote_plus(): %r != %r)rrrrarrr�)rr��givenrrrr�test_quoting_space�s
zQuotingTests.test_quoting_spacecCsX|jtjjd�d�|jtjjdd�d�|jtjjd�d�|jtjjdd�d�dS)Nzalpha+beta gammazalpha%2Bbeta+gammar&zalpha+beta+gammasalpha+beta gamma�+)rarrr)rrrr�test_quoting_plus�szQuotingTests.test_quoting_pluscCsfd}d}tjj|�}|j||d||f�|jttjj|dd�tjj|�}|j||d||f�dS)Ns��ab�z%A2%D8ab%FFzusing quote(): %r != %rzlatin-1)rz"using quote_from_bytes(): %r != %r)rrrrarq�	TypeErrorZquote_from_bytes)rr'rr�rrr�test_quote_bytes�szQuotingTests.test_quote_bytescCs(d}d}tjj|�}|j||d||f�tjj|ddd�}|j||d||f�d}d}tjj|dd�}|j||d||f�d}d	}tjj|�}|j||d||f�d}|jttjj|dd�d}d
}tjj|ddd�}|j||d||f�d}d}tjj|dd
d�}|j||d||f�dS)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFzusing quote(): %r != %r)r�errorsz%A2%D8ab%FFzlatin-1)ru漢字z%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rrrrarqr�)rr'rr�rrr�test_quote_with_unicode�sB

z$QuotingTests.test_quote_with_unicodecCsbd}d}tjj|dd�}|j||d||f�d}d}tjj|ddd	�}|j||d||f�dS)
Nu¢Ø ÿz
%A2%D8+%FFzlatin-1)rzusing quote_plus(): %r != %ruab漢字 cdzab%3F%3F+cdr�)rr-)rrrra)rr'rr�rrr�test_quote_plus_with_unicode�s
z)QuotingTests.test_quote_plus_with_unicodeN)
r-r.r/rtrrrr%r(r*r,r/r0rrrrr7s
*rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�UnquotingTestszwTests for unquote() and unquote_plus()

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

    cCsg}xrtd�D]f}tt|��}t|�}tjj|�}|j||d||f�tjj|�}|j||d||f�|j|�qWdj	|�}~tjj|�}|j|j
d�dd|�|jtt
ftjjd�|jtt
ftjjf�tjdtfdd	��|jtt
ftjjd
�WdQRXdS)N�zusing unquote(): %r != %rzusing unquote_plus(): %r != %rr�r	rz/using unquote(): not all characters escaped: %sT)�quietr&)r�rr�rr�unquotera�unquote_plusr�r�countrqr+�AttributeErrorrr�BytesWarning)rZescape_listr!r'rr�Z
escape_stringrrr�test_unquotings,
zUnquotingTests.test_unquotingcCs>d}|}tjj|�}|j||d||f�d}|}tjj|�}|j||d||f�d}|}tjj|�}|j||d||f�d}t|d�}tjj|�}|j||d||f�d}t|d�}tjj|�}|j||d||f�d}t|d�}tjj|�}|j||d||f�|jttftjjd�|jttftjjf�dS)Nz%xabzusing unquote(): %r != %rz%xr	rIz"using unquote_to_bytes(): %r != %r)	rrr4rarK�unquote_to_bytesrqr+r7)rr'rr�rrr�test_unquoting_badpercent$s@








z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tjj|�}|j||d||f�dS)Nz%Ab%eAs��z"using unquote_to_bytes(): %r != %r)rrr:ra)rr'rr�rrr�test_unquoting_mixed_caseHsz(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tjj|�}|j||d||f�tjj|�}|j||d||f�dS)Nzab%sd�cZabcdzusing quote(): %r != %rzusing unquote_plus(): %r != %r)rrrr4rar5)rr'rr�rrr�test_unquoting_partsQsz#UnquotingTests.test_unquoting_partscCs\d}|}tjj|�}|j||d||f�|jdd�}tjj|�}|j||d||f�dS)Nzare+there+spaces...zusing unquote(): %r != %rr&r�zusing unquote_plus(): %r != %r)rrr4rar�r5)rr'rr�rrr�test_unquoting_plus]sz"UnquotingTests.test_unquoting_pluscCs�d}d}tjj|�}|j||d||f�tjjd�}d}|j||d||f�d}d}tjj|�}|j||d||f�d}d}tjj|�}|j||d||f�dS)	Nz"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docz"using unquote_to_bytes(): %r != %ru	漢%C3%BCs漢üs%A2%D8ab%FFs��ab�s	%A2�ab%FF)rrr:ra)rr'rr�rrr�test_unquote_to_bytesis.z$UnquotingTests.test_unquote_to_bytescCsxd}d}tjj|�}|j||d||f�tjj|ddd�}|j||d||f�tjjddd�}d}|j||d||f�d}d	}tjj|�}|j||d||f�d
}d}tjj|�}|j||d||f�tjj|dd
�}|j||d||f�d
}d}tjj|dd
�}|j||d||f�tjjd�}d}|j||d||f�tjjddd�}d}|j||d||f�dS)Nz"br%C3%BCckner_sapporo_20050930.docubrückner_sapporo_20050930.doczusing unquote(): %r != %r)rr-zbr%FCckner_sapporo_20050930.doczlatin-1)rz%E6%BC%A2%E5%AD%97u漢字z%F3%B1u�r�)r-r��ignoreu	漢%C3%BCu漢üu漢%FC)rrr4ra)rr'rr�rrr�test_unquote_with_unicode�sNz(UnquotingTests.test_unquote_with_unicodeN)r-r.r/rtr9r;r<r>r?r@rBrrrrr1s$	r1c@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}tjj|�}x$|D]}|j||d|||f�qW|j|jd�dd||jd�f�|jd�}||d}||d}|j|j�o�|j�d	||f�|jt	|�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�&rz#testing %s: expected 2 '&'s; got %srz1testing %s: '&' not located in proper place in %srr
z5testing %s: unexpected number of characters: %s != %sN��rErF)
rr�	urlencoder�rar6�indexr]�isdigitr
)	rr'Z	test_typeZexpect_somewherer�r$Zamp_locationZon_amp_leftZon_amp_rightrrr�help_inputtype�s$


zurlencode_Tests.help_inputtypecCs|jdddd�d�dS)N�1�2�3)�1st�2nd�3rdzusing dict as input type)rJ)rrrr�test_using_mapping�sz"urlencode_Tests.test_using_mappingcCs|jdd	d
gd�dS)NrNrKrOrLrPrMz*using sequence of two-item tuples as input)rNrK)rOrL)rPrM)rJ)rrrr�test_using_sequence�sz#urlencode_Tests.test_using_sequencecCs\ddi}dtd�td�f}tjj|�}|j||�ddi}d}tjj|�}|j||�dS)NrD�=z%s=%szkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrrGra)rr'rr�rrr�test_quoting�szurlencode_Tests.test_quotingcCs�ddddgi}dtjjtdddg��}tjj|�}|j||�tjj|d�}x$|dD]}d|}|j||�qXW|j|jd�dd	|jd��dS)
NZsequencerKrLrMzsequence=%sTrDrzExpected 2 '&'s, got %s)rrrr�rGrar�r6)rr'rr��valuerrr�
test_doseq�szurlencode_Tests.test_doseqcCs,|jdtjji��|jdtjjg��dS)Nr�)rarrrG)rrrr�test_empty_sequencesz#urlencode_Tests.test_empty_sequencecCs4|jdtjjddi��|jdtjjddi��dS)Nza=1�arza=None)rarrrG)rrrr�test_nonstring_valuessz%urlencode_Tests.test_nonstring_valuescCsh|jdtjjdddgid��|jdtjjdddgid��tjd	d
g�}|jdtjjd|id��dS)Nza=1&a=2rXrrTz
a=None&a=a�bza=a&a=b)rXr)rZr)rarrrGr�r�)rrrrr�test_nonstring_seq_valuessz)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|j||�d}d}tjj|�}|j||�d}d}tjj|d	d
�}|j||�dS)N� �Áz%3F=%3Fr�r�)rr-z
%C2%A0=%C3%81z%A0=%C1zlatin-1)r�r\r])r^�r\r])r_�r\r])r`)rrrGra)rr'rr�rrr�test_urlencode_encodingsz'urlencode_Tests.test_urlencode_encodingcCs�d}d}tjj|dddd�}|j||�d}d	}tjj|dddd
�}|j||�d}d}tjj|d�}|j||�d}d
}tjj|d�}|j||�d}d}tjj|ddd�}|j||�d }d}tjj|ddd�}|j||�dS)!Nr\r]z%3F=%3FTr�r�)�doseqrr-rz
%3F=1&%3F=%3F)rr-z
%C2%A0=%C3%81�*z%C2%A0=42&%C2%A0=%C3%81z%A0=%C1zlatin-1)rz%A0=42&%A0=%C1�r\r])rd�rr]�r\re)rf�r\r])rg�rcr]�r\rh)ri�r\r])rj�rcr]�r\rk)rl)rrrGra)rr'rr�rrr�test_urlencode_encoding_doseq*s4



z-urlencode_Tests.test_urlencode_encoding_doseqcCs`d}d}tjj|�}|j||�tjj|d�}|j||�d}d}tjj|d�}|j||�dS)N��$��$z
%A0%24=%C1%24Trcz%A0%24=42&%A0%24=%C1%24�rnro)rp�rcro�rnrq)rr)rrrGra)rr'rr�rrr�test_urlencode_bytesOsz$urlencode_Tests.test_urlencode_bytescCs�d}tjj|dd�}d}|j||�d}tjj|ddd�}d}|j||�d}d
}tjj|ddd�}|j||�d}tjj|ddd�}d}|j||�d}d}tjj|dddd
�}d}d
}tjj|dddd�}|j||�dS)N��$��$z:$)rz	%A0$=%C1$T)rbr�
rcz%A0$=%C1$&%A0$=13&%A0$=42zlatin-1)rr)rbrr�rtru)rw�rtru)rx�rurvrc�rtry)rz�rtru)r{�rtru)r|�rurvrc�rtr})r~)rrrGra)rr'r�rrrr�&test_urlencode_encoding_safe_parameter]s4
z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r-r.r/rtrJrQrRrTrVrWrYr[rarmrsrrrrrrC�s 
%rCc@s:eZdZdZdd�Zdd�Zejej	dkd�dd	��Z
d
S)�Pathname_Testsz&Test pathname2url() and url2pathname()cCs^tjjdddd�}d}tjj|�}|j||d||f�tjj|�}|j||d||f�dS)N�partsZofrXr�zparts/of/a/pathzpathname2url() failed; %s != %szurl2pathame() failed; %s != %s)rTr�rrrrrar)rZ
expected_pathZexpected_urlr�rrrr��szPathname_Tests.test_basiccCs�tjjddd�}dtjjd�}tjj|�}|j||d||f�|}tjj	|�}|j||d||f�tjjdd�}d	tjjd�}tjj|�}|j||d||f�d
}tjjdd�}tjj	|�}|j||d||f�dS)
NZneedszquot=ing�herez
needs/%s/herezpathname2url() failed; %s != %szurl2pathname() failed; %s != %sz	make sureZusing_quotez%s/using_quotezmake+sure/using_unquotez	make+sureZ
using_unquote)
rTr�rrrrrrrar)rr'rr�rrrrT�s.zPathname_Tests.test_quotingZwin32z.test specific to the urllib.url2path function.cCsfd	}d}x.|D]&}tjj|�}|j||d||f�qWd}d}tjj|�}|j||d||f�dS)
N�/C:/�///C:/�/C|//zC:\z/urllib.request..url2pathname() failed; %s != %sz
///C|/pathzC:\pathz.urllib.request.url2pathname() failed; %s != %s)r�r�r�)rrrra)rr'rrr�rrr�test_ntpath�s
zPathname_Tests.test_ntpathN)r-r.r/rtr�rTr�r��sys�platformr�rrrrr��s

r�c@seZdZdZdd�ZdS)�
Utility_Testsz=Testcase to test the various utility functions in the urllib.cCs|jtjj�t�dS)zATest the urllib.request.thishost utility function returns a tupleN)rerrZthishost�tuple)rrrr�
test_thishost�szUtility_Tests.test_thishostN)r-r.r/rtr�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�URLopener_Testsz4Testcase to test the open method of URLopener class.c
CsZGdd�dtjj�}tjdtf��.|j|�jd�d�|j|�jd�d�WdQRXdS)Nc@seZdZdd�ZdS)z8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenercSs|S)Nr)rrrrr�	open_spam�szBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spamN)r-r.r/r�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�rrrrar)rr�rrr�test_quoted_open�s



z URLopener_Tests.test_quoted_opencCs�Gdd�dtjj�}tjdd���tjdt�xndD]f}|jttjj	|�|jttjj�j
|�|jttjj�j|�|jt|�j
|�|jt|�j|�q4WWdQRXdS)	Nc@seZdZdd�ZdS)z<URLopener_Tests.test_local_file_open.<locals>.DummyURLopenercSs|S)Nr)rrrrr�open_local_file�szLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileN)r-r.r/r�rrrrr��sr�T)�recordrA�local_file://example�local-file://example)r�r�)rrr��warnings�catch_warnings�simplefilterrrqr�rrZretrieve)rr�rrrr�test_local_file_open�s
z$URLopener_Tests.test_local_file_openN)r-r.r/rtr�r�rrrrr��sr�c@s eZdZdZdd�Zdd�ZdS)�RequestTestsz&Unit tests for urllib.request.Request.cCs>tjj}|d�}|j|j�d�|di�}|j|j�d�dS)Nzhttp://www.python.orgr�ZPOST)rr�Requestra�
get_method)rr�rrrr�test_default_values>s

z RequestTests.test_default_valuescCs�tjj}|ddd�}|j|jd�|j|j�d�|didd�}|j|jd�|j|j�d�|ddd�}|j|j�d�d|_|j|j�d�dS)Nzhttp://www.python.orgZHEAD)�methodr�)rrr�rar�r�)rr�rrrr�test_with_method_argEsz!RequestTests.test_with_method_argN)r-r.r/rtr�r�rrrrr�;sr�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCs4|jtd�d�|jtd�d�|jtd�d�dS)Nz///C|zC:z///C:z///C|/zC:\)rar)rrrr�test_converting_drive_letterUsz.URL2PathNameTests.test_converting_drive_lettercCs$|jtd�d�|jtd�d�dS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\)rar)rrrr�$test_converting_when_no_drive_letterZsz6URL2PathNameTests.test_converting_when_no_drive_lettercCs|jtd�d�dS)Nz///C|/foo/bar/spam.foozC:\foo\bar\spam.foo)rar)rrrr�test_simple_compare_s
z%URL2PathNameTests.test_simple_comparecCs|jttd�dS)Nu///è|/)rq�IOErrorr)rrrr�test_non_ascii_drive_lettercsz-URL2PathNameTests.test_non_ascii_drive_lettercCs0dddg}x |D]}|jtt|��|�qWdS)NzC:z\\\C\test\\zC:\foo\bar\spam.foo)rarr)r�
list_of_pathsr�rrr�test_roundtrip_url2pathnamefs

z-URL2PathNameTests.test_roundtrip_url2pathnameN)r-r.r/r�r�r�r�r�rrrrr�Ss
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs$|jtd�d�|jtd�d�dS)NzC:z///C:zC:\)rar)rrrrr�psz.PathName2URLTests.test_converting_drive_lettercCs4|jtd�d�|jtd�d�|jtd�d�dS)Nz\\\folder\test\z/////folder/test/z\\folder\test\z////folder/test/z
\folder\test\z
/folder/test/)rar)rrrrr�ts


z6PathName2URLTests.test_converting_when_no_drive_lettercCs|jtd�d�dS)NzC:\foo\bar\spam.fooz///C:/foo/bar/spam.foo)rar)rrrrr�|s
z%PathName2URLTests.test_simple_comparecCs|jttd�dS)NzXX:\)rqr�r)rrrr�test_long_drive_letter�sz(PathName2URLTests.test_long_drive_lettercCs0dddg}x |D]}|jtt|��|�qWdS)Nz///C:z/////folder/test/z///C:/foo/bar/spam.foo)rarr)rr�r�rrr�test_roundtrip_pathname2url�s

z-PathName2URLTests.test_roundtrip_pathname2urlN)r-r.r/r�r�r�r�r�rrrrr�ns
r��__main__)NN)6rtZurllib.parserZurllib.requestZurllib.errorZhttp.clientr4Z
email.messagerir(r�Z
unittest.mockrr�rrTr��ImportErrorr�r�r�Z
nturl2pathrr�base64rr�rrrrr7rCr8r;ZTestCaserHrur�r�r�r�rrr1rCr�r�r�r�r�r�r-�mainrrrr�<module>sf

'	S6$
J
)N?D<r


Youez - 2016 - github.com/yon3zu
LinuXploit