HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.7/test/__pycache__/test_urllib.cpython-37.pyc
B

��g��@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
�5�dS)5z;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�,/usr/local/lib/python3.7/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	Cs$t�dtf��tj��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
dStj�||�S)N�)�closed�io�BytesIO�read)rZamtrrrr*Gsz!fakehttp.<locals>.FakeSocket.readcSs|jr
dStj�||�S)Nr&)r'r(r)�readline)r�lengthrrrr+Lsz%fakehttp.<locals>.FakeSocket.readlinecSs(|jd8_|jdkr$tj�|�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

r1cseZdZdZ�fdd�ZdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs�|j�|_|jt|�_dS)N)�fakedataZsock�typeZfakesock)r)r1rr�connect[sz,fakehttp.<locals>.FakeHTTPConnection.connect)r.r/r0rr4r)r1rrr Vsr )r(r)�http�client�HTTPConnectionr2)r2r)r r1r�fakehttp<sr8c@seZdZdd�Zdd�ZdS)�
FakeHTTPMixincCstjj|_t|�tj_dS)N)r5r6r7�_connection_classr8)rr2rrrr8ds
zFakeHTTPMixin.fakehttpcCs|jtj_dS)N)r:r5r6r7)rrrr�
unfakehttphszFakeHTTPMixin.unfakehttpN)r.r/r0r8r;rrrrr9csr9c@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t��dfS)Nr)r(r))r�filer3rrr�retrfilessz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSsdS)Nr)rrrrr-vsz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)NT)r.r/r0r@rBr-rrrr�FakeFtpWrapperns
rC)�objectrr�
ftpwrapper�_ftpwrapper_class)rrCrrr�fakeftpms
zFakeFTPMixin.fakeftpcCs|jtj_dS)N)rFrrrE)rrrr�	unfakeftp|szFakeFTPMixin.unfakeftpN)r.r/r0rGrHrrrrr<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�Wd|��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|j��t�tj�dS)zShut down the open objectN)rRr-�os�removerrO)rrrr�tearDown�s
zurlopen_FileTests.tearDowncCs*x$dD]}|�t|j|�d|�qWdS)N)	r*r+�	readlines�filenor-�info�geturl�getcode�__iter__z/object returned by urlopen() lacks %s attribute)�
assertTrue�hasattrrR)r�attrrrr�test_interface�s
z urlopen_FileTests.test_interfacecCs|�|j|j���dS)N)�assertEqualrNrRr*)rrrr�	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)rbrNrRr+)rrrr�
test_readline�szurlopen_FileTests.test_readlinecCs4|j��}|�t|�dd�|�|d|jd�dS)Nrz.readlines() returned the wrong number of linesrz"readlines() returned improper text)rRrXrbr
rN)rZ
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)	rRrY�assertIsInstance�intrbrUr*r
rN)rZfile_numrrr�test_fileno�s
zurlopen_FileTests.test_filenocCs|j��dS)N)rRr-)rrrr�
test_close�szurlopen_FileTests.test_closecCs|�|j��tjj�dS)N)rfrRrZ�email�message�Message)rrrr�	test_info�szurlopen_FileTests.test_infocCs|�|j��|j�dS)N)rbrRr[rQ)rrrr�test_geturl�szurlopen_FileTests.test_geturlcCs|�|j���dS)N)ZassertIsNonerRr\)rrrr�test_getcode�szurlopen_FileTests.test_getcodecCs"x|jD]}|�||j�qWdS)N)rRrbrN)r�linerrr�	test_iter�szurlopen_FileTests.test_itercCs|�ttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrrQ)rrrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r.r/r0�__doc__rTrWrarcrdrerhrirmrnrorqrtrrrrrI�s	rIc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�
ProxyTestscCs:t��|_x*ttj�D]}d|��kr|j�|�qWdS)N�proxy)rZEnvironmentVarGuard�env�listrU�environ�lower�unset)r�krrrrT�s
zProxyTests.setUpcCs|j��|`dS)N)rx�__exit__)rrrrrW�s
zProxyTests.tearDowncCsp|j�dd�tj��}|�d|d�|j�dd�|�tj�d��|�tj�d��|�tj�d��dS)N�NO_PROXY�	localhost�noz0localhost, anotherdomain.com, newdomain.com:1234zanotherdomain.comzanotherdomain.com:8888znewdomain.com:1234)rx�setrr�getproxies_environmentrbr^�proxy_bypass_environment)rrrrr�+test_getproxies_environment_keep_no_proxies�s
z6ProxyTests.test_getproxies_environment_keep_no_proxiesc	CspzP|j�dd�tj��}|�d|d�|j�dd�tj��}|�d|�Wd|j�d�|j�d�XdS)N�
HTTP_PROXYzhttp://somewhere:3128r5ZREQUEST_METHOD�GET)rxr�rrr�rb�assertNotInr|)rrrrr�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)Nrz8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr�Z	LocalHostZ	LOCALHOSTz
.localhostznewdomain.com:1234z.newdomain.com:1234z	foo.d.o.tzd.o.tzanotherdomain.com:8888z.anotherdomain.com:8888zwww.newdomain.com:1234Zprelocalhostz
newdomain.comznewdomain.com:1235)rrr�rxr�r^�assertFalse)r�bypassrrr�(test_proxy_bypass_environment_host_match�s"z3ProxyTests.test_proxy_bypass_environment_host_matchcCsntjj}|j�dd�|�|d��|�|d��|j�dd�|�|d��|�|d��|�|d��dS)Nr�*z
newdomain.comznewdomain.com:1234z*, anotherdomain.comzanotherdomain.com)rrr�rxr�r^r�)rr�rrr�*test_proxy_bypass_environment_always_matchsz5ProxyTests.test_proxy_bypass_environment_always_matchcCsDtjj}|j�dd�|�|d��|�|d��|�|d��dS)Nrz0localhost, anotherdomain.com, newdomain.com:1234z
localhost
zanotherdomain.com:8888
znewdomain.com:1234
)rrr�rxr�r�)rr�rrr�%test_proxy_bypass_environment_newlinesz0ProxyTests.test_proxy_bypass_environment_newlineN)
r.r/r0rTrWr�r�r�r�r�rrrrrv�s
rvc@s$eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_t��t_dS)N)rUrz�
_saved_env�collections�OrderedDict)rrrrrT!szProxyTests_withOrderedEnv.setUpcCs|jt_dS)N)r�rUrz)rrrrrW'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_proxyzhttp://somewhere:3128r�z%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128Z
Http_Proxyr5)	rUrzr�rrr�r�rbr^)rrrrr�,test_getproxies_environment_prefer_lowercase*s&









zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r.r/r0rTrWr�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�Wd|��XdS)NsHTTP/s 200 OK

Hello!zhttp://python.org/sHello!r&��)r8rrbr+r[r\r;)rZver�fprrr�
check_readFszurlopen_HttpTests.check_readcCs>d}|�d�z tj�|�}|�|��|�Wd|��XdS)Nz-http://docs.python.org/library/urllib.html#OKsHTTP/1.1 200 OK

Hello!)r8rrrrbr[r;)rrr�rrr�test_url_fragmentQs
z#urlopen_HttpTests.test_url_fragmentcCs4|�d�ztd�}|�|jj�Wd|��XdS)NsHTTP/1.1 200 OK

Hello!zhttp://www.python.org)r8rr^r�Z
will_closer;)r�resprrr�test_willclose[s

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

Hello.�\z\\zcontain control.*zhttp:zhttps:)ry�range�chrr8�repr�replacer5r6�
InvalidURL�assertRaisesRegexrrrr�r[r;)r�char_nor�schemeless_url�escaped_char_reprr�r�rrr�(test_url_path_with_control_char_rejectedcs 
z:urlopen_HttpTests.test_url_path_with_control_char_rejectedc	Cs�|�d�d}d|d}z�tjj}|�|d��tj�d|���WdQRX|�|d��tj�d|���WdQRXtd|���}|�d	|�	��|�d
|�	��|�d|�	��Wd|�
�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:� �
�
)r8r5r6r�r�rrrr�r[r;)rr>r�r�r�rrr�4test_url_path_with_newline_header_injection_rejected~s

zFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejectedc
Cs�x�ttdd��dgD]�}t|�}d|�d�}|�d�ztt|��dd�}tjj}|�	|d	|����t
d
|���WdQRX|�	|d	|����t
d|���WdQRXWd|��XqWdS)Nrr�r�z//localhostz/test/sHTTP/1.1 200 OK

Hello.r�z\\zcontain control.*zhttp:zhttps:)ryr�r�r8r�r�r5r6r�r�rr;)rr�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|���WdQRX|�|d��td|���WdQRXWd|��XdS)	NsHTTP/1.1 200 OK

Hello.zlocalhost
X-injected: header
z//z:8080/test/?test=azcontain control.*\\rzhttp:zcontain control.*\\nzhttps:)r8r5r6r�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|�d�dS)Ns0.9)r�)rrrr�
test_read_0_9�szurlopen_HttpTests.test_read_0_9cCs|�d�dS)Ns1.0)r�)rrrr�
test_read_1_0�szurlopen_HttpTests.test_read_1_0cCs|�d�dS)Ns1.1)r�)rrrr�
test_read_1_1�szurlopen_HttpTests.test_read_1_1cCs,|�d�z|�ttd�Wd|��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/)r8rr�OSErrorrr;)rrrr�test_read_bogus�s
z!urlopen_HttpTests.test_read_bogusc	CsF|�d�z,d}|�tjj|��td�WdQRXWd|��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/)r8r�r�error�	HTTPErrorrr;)r�msgrrr�test_invalid_redirect�sz'urlopen_HttpTests.test_invalid_redirectc	CsFx@tt�j�D]0}|�d�z|�tjjtd�Wd|�	�XqWdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
zhttp://something)
r�rZmaxtriesr8rrrr�r�rr;)r�irrr�test_redirect_limit_independent�s
z1urlopen_HttpTests.test_redirect_limit_independentcCs,|�d�z|�ttd�Wd|��XdS)Nr&zhttp://something)r8rrr�rr;)rrrr�test_empty_socket�s
z#urlopen_HttpTests.test_empty_socketc	CsB|�tjj��}td�WdQRX|�|jj�|�|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	rrrr��URLErrorrr^�	exception�filename�reason)r�errr�test_missing_localfile�sz(urlopen_HttpTests.test_missing_localfilec	Cs�t��\}}d|�tjjd�}z4|�tj�|��t|��}|�|�WdQRXWdt�	|�t�
|�X|�tj�|��|�t
jj��t|�WdQRXdS)Nzfile://localhost/r�)�tempfile�mkstempr�rU�path�sepr^�existsrr-�unlinkr�rrrr�r�)r�fdZtmp_fileZtmp_fileurlZfobjrrr�test_file_notexists�s

z%urlopen_HttpTests.test_file_notexistsc	CsFd}|�tjj��}t|�WdQRX|�|jj�|�|jj	�dS)Nzftp:///path)
rrrr�r�rr�r�r�r^r�)rZtest_ftp_urlr�rrr�test_ftp_nohosts
z!urlopen_HttpTests.test_ftp_nohostc	CsB|�tjj��}td�WdQRX|�|jj�|�|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.py)
rrrr�r�rr�r�r�r^r�)rr�rrr�test_ftp_nonexistingsz&urlopen_HttpTests.test_ftp_nonexistingZMAXFTPCACHErcCs@|��z(tj�ddddg�tjjd<td�Wd|��XdS)Nr=�passr���testzftp://localhost)rGrrrEZftpcacherrH)rrrr�test_ftp_cache_prunings
z(urlopen_HttpTests.test_ftp_cache_pruningcCsf|�d�zLtd�}|�|��d�|�|��d�|�|��d�|�|��d�Wd|��XdS)NsHTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/sHello!r&r�)r8rrbr+r[r\r;)rr�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	�Wd|��XdS)
NsHTTP/1.0 200 OK

Hello!za b:c dzhttp://{}@python.org/zAuthorization: Basic %s
�ASCIIzUTF-8sHello!r&r�)r8�formatr5r6r7r�encode�decoder�assertInrrbr+ZassertNotEqualr[r\r;)rZuserpassrZfakehttp_wrapperZ
authorizationr�rrr�test_userpass_inurl_w_spaces-s

z.urlopen_HttpTests.test_userpass_inurl_w_spacesc	Cs(t�dtf��tj��WdQRXdS)Nr�)rrrrr�	URLopener)rrrr�test_URLopener_deprecation@sz,urlopen_HttpTests.test_URLopener_deprecationc
CsNt��}t�dtf��.|�t��tjj	dd|d�WdQRXWdQRXdS)Nr�zhttps://localhostz/nonexistent/path)Zcafile�context)
�sslZcreate_default_contextrrrrrrsrrr)rr�rrr�test_cafile_and_contextDs
z)urlopen_HttpTests.test_cafile_and_contextN)"r.r/r0rur�r�r��unittest�
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrDrrr�r�r�r�r�rrrrr�Cs0

		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)rN�image�text_url�text_url_base64�	image_urlrrr�
text_url_resp�text_url_base64_resp�image_url_resp)rrrrrTQs
zurlopen_DataTests.setUpcCs*x$dD]}|�t|j|�d|�qWdS)N)r*r+rXr-rZr[r\r]z/object returned by urlopen() lacks %s attribute)r^r_r�)rr`rrrrams
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:,)r�zUS-ASCII)rfr�rZrjrkrlrbr��
get_paramsr��strr
r�rrr)rrrrrmus
zurlopen_DataTests.test_infocCs@|�|j��|j�|�|j��|j�|�|j��|j�dS)N)rbr�r[r�r�r�r�r�)rrrrrn~szurlopen_DataTests.test_geturlcCs0|�|j���t|j�����d�|j�dS)Nr�)rbr�r*r��dictrZr�rN)rrrr�test_read_text�sz urlopen_DataTests.test_read_textcCs0|�|j���t|j�����d�|j�dS)Nr�)rbr�r*r�r�rZr�rN)rrrr�test_read_text_base64�sz'urlopen_DataTests.test_read_text_base64cCs|�|j��|j�dS)N)rbr�r*r�)rrrr�test_read_image�sz!urlopen_DataTests.test_read_imagecCs|�ttjjd�dS)Nzdata:text/plain)rrrsrrr)rrrr�test_missing_comma�sz$urlopen_DataTests.test_missing_commacCs|�ttjjd�dS)Nzdata:;base64,Cg=)rrrsrrr)rrrr�test_invalid_base64_data�sz*urlopen_DataTests.test_invalid_base64_dataN)
r.r/r0rurTrarmrnr�r�r�r�r�rrrrr�Ns	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�|��Wdy|��WnYnXXdS)Nstesting urllib.urlretrieverK)�	tempFiles�registerFileForCleanUprrOrNrrPr-)r�FILErrrrT�szurlretrieve_FileTests.setUpcCs0x*|jD] }yt�|�WqYqXqWdS)N)r�rUrV)rZeachrrrrW�s
zurlretrieve_FileTests.tearDowncCsJtj�|�}y|�d�Wntk
r8t�d��YnXdtj�	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rUr��abspathr��UnicodeEncodeErrorr�ZSkipTestrrr)rZfilePathrrr�constructLocalFileUrl�sz+urlretrieve_FileTests.constructLocalFileUrlr&cCsZt��\}}z,|�|�t�|d�}|�|�|��Wdy|��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.rKN)r�r�r�rU�fdopenrPr-)rrZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s

z'urlretrieve_FileTests.createNewTempFilecCs|j�|�dS)N)r��append)rZfileNamerrrr��sz,urlretrieve_FileTests.registerFileForCleanUpcCs>tj�dtj�}|�|dtj�|�|dtjj	d�dS)Nzfile:%srrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrOrbrfrjrkrl)r�resultrrr�
test_basic�sz urlretrieve_FileTests.test_basiccCs�dtj}|�|�tj�|�tj�|�}|�||d�|�t	j
�|�d�t|d�}z|�
�}|��Wdy|��WnYnXX|�|j|�dS)Nz%s.2rzcopy of the file was not made�rb)rrOr�rrr�r�rbr^rUr�r�rr*r-rN)r�second_tempr�r�rNrrr�	test_copy�s


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


z%urlretrieve_FileTests.test_reporthookcCsXg}|fdd�}|��}tj�|�|�tj|�|�t|�d�|�|ddd�dS)NcSs|�|||f�dS)N)r�)rrr�_reportrrrr�szAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktesterrrr)	r�rrr�r�rrOrbr
)r�reportr�srcFileNamerrr�test_reporthook_0_bytes�s
z-urlretrieve_FileTests.test_reporthook_0_bytescCsng}|fdd�}|�d�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd�dS)NcSs|�|||f�dS)N)r�)rrrrrrrr
szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktestersxxxxxrr�r)	r�rrr�r�rrOrbr
)rrrrrrr�test_reporthook_5_bytess

z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|fdd�}|�dd�}tj�|�|�tj|�|�t|�d�|�|ddd�|�|ddd	�|�|ddd	�|�|ddd	�dS)
NcSs|�|||f�dS)N)r�)rrrrrrrrszDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester�xi �rrri )	r�rrr�r�rrOrbr
)rrrrrrr�test_reporthook_8193_bytess
z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r&)r.r/r0rurTrWr�r�r�r�r�rrr
r
rrrrr��s
	r�c@s eZdZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionsc	CsR|�d�dd�}|�tjj��(ztjjtj|d�Wd|�	�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�_reporthook2szYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthook)Z
reporthook)
r8rrrr��ContentTooShortErrorrr�r�
TEST_HTTP_URLr;)rrrrr�.test_short_content_raises_ContentTooShortError's
zDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorc	CsF|�d�|�tjj��$ztj�tj�Wd|�	�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
)
r8rrrr�rrr�rrr;)rrrr�Atest_short_content_raises_ContentTooShortError_without_reporthook<szWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r.r/r0rurrrrrrr$src@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�ZABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyz�
0123456789z_.-~zusing quote(): %r != %rzusing quote_plus(): %r != %r)�joinr�parse�quoterb�
quote_plus)rZdo_not_quoter�rrr�test_never_quotegszQuotingTests.test_never_quotecCs|�tjjjdd�dS)Nrr�)rbrrr�__defaults__)rrrr�test_default_safetszQuotingTests.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<>)�safezusing quote(): %r != %rzusing quote_plus(): %r != %rs<>uaübzlatin-1�ü)�encodingrr���)rrrrbr)rZquote_by_defaultr��expectrrr�	test_safexs,zQuotingTests.test_safec	Cs�dd�td�D�}|�d�|�td��d�|�}xd|D]\}tj�|�}|�t|�|d|t|�|f�tj�	|�}|�t|�|d|t|�|f�q:W~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%5Dcdzusing quote(): %r != %rzusing quote_plus(): %r != %r)
r�r�r�rrrrrbrr)rZshould_quoterr�Z
partial_quote�expectedrrr�test_default_quoting�s,


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�zusing quote(): %r != %r�+zusing quote_plus(): %r != +z
a b cd e fzusing quote_plus(): %r != %r)rrrrbrrr�)rr��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�+)rbrrr)rrrr�test_quoting_plus�szQuotingTests.test_quoting_pluscCsfd}d}tj�|�}|�||d||f�|jttjj|dd�tj�|�}|�||d||f�dS)Ns��ab�z%A2%D8ab%FFzusing quote(): %r != %rzlatin-1)rz"using quote_from_bytes(): %r != %r)rrrrbrr�	TypeErrorZquote_from_bytes)rr*r!r�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%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)rrrrbrrr�)rr*r!r�rrr�test_quote_with_unicode�sB

z$QuotingTests.test_quote_with_unicodecCsbd}d}tjj|dd�}|�||d||f�d}d}tjj|ddd	�}|�||d||f�dS)
Nu¢Ø ÿz
%A2%D8+%FFzlatin-1)rzusing quote_plus(): %r != %ruab漢字 cdzab%3F%3F+cdr�)rr0)rrrrb)rr*r!r�rrr�test_quote_plus_with_unicode
s
z)QuotingTests.test_quote_plus_with_unicodeN)
r.r/r0rurrr"r(r+r-r/r2r3rrrrrMs
*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.

    c	Csg}xrtd�D]f}tt|��}t|�}tj�|�}|�||d||f�tj�|�}|�||d||f�|�|�qWd�	|�}~tj�|�}|�|�
d�dd|�|�tt
ftjjd�|�tt
ftjjd�tjdtfd	d
��|�tt
ftjjd�WdQRXdS)N�zusing unquote(): %r != %rzusing unquote_plus(): %r != %rr�r	rz/using unquote(): not all characters escaped: %srT)�quietr&)r�rr�rr�unquoterb�unquote_plusr�r�countrrr.�AttributeErrorrr�BytesWarning)rZescape_listr$r*r!r�Z
escape_stringrrr�test_unquoting!s,
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%xabzusing unquote(): %r != %rz%xr	rJz"using unquote_to_bytes(): %r != %rr)	rrr7rbrL�unquote_to_bytesrrr.r:)rr*r!r�rrr�test_unquoting_badpercent:s@








z(UnquotingTests.test_unquoting_badpercentcCs.d}d}tj�|�}|�||d||f�dS)Nz%Ab%eAs��z"using unquote_to_bytes(): %r != %r)rrr=rb)rr*r!r�rrr�test_unquoting_mixed_case^sz(UnquotingTests.test_unquoting_mixed_casecCsXdtd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)Nzab%sd�cZabcdzusing quote(): %r != %rzusing unquote_plus(): %r != %r)rrrr7rbr8)rr*r!r�rrr�test_unquoting_partsgsz#UnquotingTests.test_unquoting_partscCs\d}|}tj�|�}|�||d||f�|�dd�}tj�|�}|�||d||f�dS)Nzare+there+spaces...zusing unquote(): %r != %rr)r�zusing unquote_plus(): %r != %r)rrr7rbr�r8)rr*r!r�rrr�test_unquoting_plusss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)	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=rb)rr*r!r�rrr�test_unquote_to_bytess.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)Nz"br%C3%BCckner_sapporo_20050930.docubrückner_sapporo_20050930.doczusing unquote(): %r != %r)rr0zbr%FCckner_sapporo_20050930.doczlatin-1)rz%E6%BC%A2%E5%AD%97u漢字z%F3%B1u�r�)r0r��ignoreu	漢%C3%BCu漢üu漢%FC)rrr7rb)rr*r!r�rrr�test_unquote_with_unicode�sNz(UnquotingTests.test_unquote_with_unicodeN)r.r/r0rur<r>r?rArBrCrErrrrr4s$	r4c@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�|�}x$|D]}|�||d|||f�qW|�|�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)
rr�	urlencoder�rbr9�indexr^�isdigitr
)	rr*Z	test_typeZexpect_somewherer�r'Zamp_locationZon_amp_leftZon_amp_rightrrr�help_inputtype�s$


zurlencode_Tests.help_inputtypecCs|�dddd�d�dS)N�1�2�3)�1st�2nd�3rdzusing dict as input type)rL)rrrr�test_using_mapping�sz"urlencode_Tests.test_using_mappingcCs|�dddgd�dS)N)rPrM)rQrN)rRrOz*using sequence of two-item tuples as input)rL)rrrr�test_using_sequencesz#urlencode_Tests.test_using_sequencecCs\ddi}dtd�td�f}tj�|�}|�||�ddi}d}tj�|�}|�||�dS)NrG�=z%s=%szkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrrIrb)rr*r!r�rrr�test_quotingszurlencode_Tests.test_quotingcCs�ddddgi}dtj�tdddg��}tj�|�}|�||�tj�|d�}x$|dD]}d|}|�||�qXW|�|�d�dd	|�d��dS)
NZsequencerMrNrOzsequence=%sTrGrzExpected 2 '&'s, got %s)rrrr�rIrbr�r9)rr*r!r��valuerrr�
test_doseqszurlencode_Tests.test_doseqcCs,|�dtj�i��|�dtj�g��dS)Nr�)rbrrrI)rrrr�test_empty_sequencesz#urlencode_Tests.test_empty_sequencecCs4|�dtj�ddi��|�dtj�ddi��dS)Nza=1�arza=None)rbrrrI)rrrr�test_nonstring_values!sz%urlencode_Tests.test_nonstring_valuescCsh|�dtj�dddgid��|�dtj�dddgid��t�ddg�}|�d	tj�d|id��dS)
Nza=1&a=2rZrrTz
a=None&a=a)rZr)�brza=a&a=b)rbrrrIr�r�)rrrrr�test_nonstring_seq_values%sz)urlencode_Tests.test_nonstring_seq_valuescCsnd}d}tjj|ddd�}|�||�d}d}tj�|�}|�||�d}d}tjj|dd	�}|�||�dS)
N))� �Áz%3F=%3Fr�r�)rr0z
%C2%A0=%C3%81z%A0=%C1zlatin-1)r)rrrIrb)rr*r!r�rrr�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)N))r^r_z%3F=%3FTr�r�)�doseqrr0))r^)rr_z
%3F=1&%3F=%3F)rr0z
%C2%A0=%C3%81))r^)�*r_z%C2%A0=42&%C2%A0=%C3%81z%A0=%C1zlatin-1)rz%A0=42&%A0=%C1)rrrIrb)rr*r!r�rrr�test_urlencode_encoding_doseq@s4



z-urlencode_Tests.test_urlencode_encoding_doseqcCs`d}d}tj�|�}|�||�tj�|d�}|�||�d}d}tj�|d�}|�||�dS)N))s�$s�$z
%A0%24=%C1%24T))s�$)rbs�$z%A0%24=42&%A0%24=%C1%24)rrrIrb)rr*r!r�rrr�test_urlencode_byteses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)N))s�$s�$z:$)rz	%A0$=%C1$T)rar))s�$)s�$�
rbz%A0$=%C1$&%A0$=13&%A0$=42zlatin-1)rr)rarr)rrrIrb)rr*r�r!rrr�&test_urlencode_encoding_safe_parameterss4
z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r.r/r0rurLrSrTrVrXrYr[r]r`rcrdrfrrrrrF�s 
%rFc@s:eZdZdZdd�Zdd�Ze�ej	dkd�dd	��Z
d
S)�Pathname_Testsz&Test pathname2url() and url2pathname()cCs^tj�dddd�}d}tj�|�}|�||d||f�tj�|�}|�||d||f�dS)N�partsZofrZr�zparts/of/a/pathzpathname2url() failed; %s != %szurl2pathame() failed; %s != %s)rUr�rrrrrbr)rZ
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/herezpathname2url() failed; %s != %szurl2pathname() failed; %s != %sz	make sureZusing_quotez%s/using_quotezmake+sure/using_unquotez	make+sureZ
using_unquote)
rUr�rrrrrrrbr)rr*r!r�rrrrV�s.zPathname_Tests.test_quoting�win32z.test specific to the urllib.url2path function.cCsfd}d}x.|D]&}tj�|�}|�||d||f�qWd}d}tj�|�}|�||d||f�dS)N)z/C:/z///C:/z/C|//zC:\z/urllib.request..url2pathname() failed; %s != %sz
///C|/pathzC:\pathz.urllib.request.url2pathname() failed; %s != %s)rrrrb)rr*r!rr�rrr�test_ntpath�s
zPathname_Tests.test_ntpathN)r.r/r0rur�rVr�r��sys�platformrkrrrrrg�s

rgc@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)rfrrZthishost�tuple)rrrr�
test_thishost�szUtility_Tests.test_thishostN)r.r/r0rurprrrrrn�srnc@s eZdZdZdd�Zdd�ZdS)�URLopener_Testsz4Testcase to test the open method of URLopener class.c	CsZGdd�dtjj�}t�dtf��.|�|��d�d�|�|��d�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/r0rrrrrr�DummyURLopener�srsz8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr�rrrrbr)rrsrrr�test_quoted_open�s



z URLopener_Tests.test_quoted_openc	Cs�Gdd�dtjj�}tjdd���t�dt�xndD]f}|�ttjj	|�|�ttj��j
|�|�ttj��j|�|�t|�j
|�|�t|�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/r0rurrrrrs�srsT)�recordrD)zlocal_file://examplezlocal-file://example)rrr��warnings�catch_warnings�simplefilterrrrr�rrZretrieve)rrsrrrr�test_local_file_open�s
z$URLopener_Tests.test_local_file_openN)r.r/r0rurtrzrrrrrq�srqc@s eZdZdZdd�Zdd�ZdS)�RequestTestsz&Unit tests for urllib.request.Request.cCs>tjj}|d�}|�|��d�|di�}|�|��d�dS)Nzhttp://www.python.orgr�ZPOST)rr�Requestrb�
get_method)rr|rrrr�test_default_valuesTs

z RequestTests.test_default_valuescCs�tjj}|ddd�}|�|jd�|�|��d�|didd�}|�|jd�|�|��d�|ddd�}|�|��d�d|_|�|��d�dS)Nzhttp://www.python.orgZHEAD)�methodr�)rrr|rbrr})rr|rrrr�test_with_method_arg[sz!RequestTests.test_with_method_argN)r.r/r0rur~r�rrrrr{Qsr{c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCs4|�td�d�|�td�d�|�td�d�dS)Nz///C|zC:z///C:z///C|/zC:\)rbr)rrrr�test_converting_drive_letterksz.URL2PathNameTests.test_converting_drive_lettercCs$|�td�d�|�td�d�dS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\)rbr)rrrr�$test_converting_when_no_drive_letterpsz6URL2PathNameTests.test_converting_when_no_drive_lettercCs|�td�d�dS)Nz///C|/foo/bar/spam.foozC:\foo\bar\spam.foo)rbr)rrrr�test_simple_compareus
z%URL2PathNameTests.test_simple_comparecCs|�ttd�dS)Nu///è|/)rr�IOErrorr)rrrr�test_non_ascii_drive_letterysz-URL2PathNameTests.test_non_ascii_drive_lettercCs0dddg}x |D]}|�tt|��|�qWdS)NzC:z\\\C\test\\zC:\foo\bar\spam.foo)rbrr)r�
list_of_pathsr�rrr�test_roundtrip_url2pathname|s

z-URL2PathNameTests.test_roundtrip_url2pathnameN)r.r/r0r�r�r�r�r�rrrrr�is
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs$|�td�d�|�td�d�dS)NzC:z///C:zC:\)rbr)rrrrr��sz.PathName2URLTests.test_converting_drive_lettercCs4|�td�d�|�td�d�|�td�d�dS)Nz\\\folder\test\z/////folder/test/z\\folder\test\z////folder/test/z
\folder\test\z
/folder/test/)rbr)rrrrr��s


z6PathName2URLTests.test_converting_when_no_drive_lettercCs|�td�d�dS)NzC:\foo\bar\spam.fooz///C:/foo/bar/spam.foo)rbr)rrrrr��s
z%PathName2URLTests.test_simple_comparecCs|�ttd�dS)NzXX:\)rrr�r)rrrr�test_long_drive_letter�sz(PathName2URLTests.test_long_drive_lettercCs0dddg}x |D]}|�tt|��|�qWdS)Nz///C:z/////folder/test/z///C:/foo/bar/spam.foo)rbrr)rr�r�rrr�test_roundtrip_pathname2url�s

z-PathName2URLTests.test_roundtrip_pathname2urlN)r.r/r0r�r�r�r�r�rrrrr��s
r��__main__)NN)6ruZurllib.parserZurllib.requestZurllib.errorZhttp.clientr5Z
email.messagerjr(r�Z
unittest.mockrr�rrUr��ImportErrorrlr�rwZ
nturl2pathrr�base64rr�rrrrr8rDr9r<ZTestCaserIrvr�r�r�r�rrr4rFrgrnrqr{r�r�r.�mainrrrr�<module>sf

'	SL$
J
)N?D<r