Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_urllib.cpython-35.pyc



��Yf�	�@s"dZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlZyddlZWnek
r�dZYnXddlZddlZddlZddlmZmZddlmZddlZdd�Zdaddd	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#�Z3e4d3kre
j5�dS)4z;Regression tests for what was in Python 2's "urllib" module�N)�patch)�support)�url2pathname�pathname2url)�	b64encodecCsFtt|��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/python35/lib64/python3.5/test/test_urllib.py�	hexescapes"
rcCso|dk	r$tjjd|�}nts<t�}|ant}|dkr[|j|�S|j||�SdS)z.urlopen(url [, data]) -> open file-like objectN�proxies)�urllib�request�FancyURLopener�
_urlopener�open)�url�datarZopenerrrr�urlopen%s		
rc	Cs.tjdtf��tjj�SWdQRXdS)Nz8FancyURLopener style of invoking requests is deprecated.)r�check_warnings�DeprecationWarningrrrrrrrr5s
rcsNG�fdd�dtj��G�fdd�dtjj��|�_�S)Ncs^eZdZdZ�fdd�Zdd�Zddd�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)Gs	z!fakehttp.<locals>.FakeSocket.readcSs |jr
dStjj||�S)Nr%)r&r'r(�readline)rZlengthrrrr*Ls	z%fakehttp.<locals>.FakeSocket.readlinecSs2|jd8_|jdkr.tjj|�dS)Nrr)r!r'r(�close)rrrrr+Qsz"fakehttp.<locals>.FakeSocket.close)	�__name__�
__module__�__qualname__r!r r$r)r*r+r)rrr�
FakeSocket=sr/cs(eZdZdZ�fdd�ZdS)z$fakehttp.<locals>.FakeHTTPConnectionNcs(�|j�|_|jt|�_dS)N)�fakedataZsock�typeZfakesock)r)r/rr�connect[sz,fakehttp.<locals>.FakeHTTPConnection.connect)r,r-r.rr2r)r/rrrVsr)r'r(�http�client�HTTPConnectionr0)r0r)rr/r�fakehttp<s"	r6c@s(eZdZdd�Zdd�ZdS)�
FakeHTTPMixincCs%tjj|_t|�tj_dS)N)r3r4r5�_connection_classr6)rr0rrrr6dszFakeHTTPMixin.fakehttpcCs|jtj_dS)N)r8r3r4r5)rrrr�
unfakehttphszFakeHTTPMixin.unfakehttpN)r,r-r.r6r9rrrrr7csr7c@s(eZdZdd�Zdd�ZdS)�FakeFTPMixincCs5Gdd�dt�}tjj|_|tj_dS)Nc@s:eZdZdddd�Zdd�Zdd�ZdS)	z,FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNTcSsdS)Nr)r�userZpasswd�hostZport�dirsZtimeoutZ
persistentrrr�__init__osz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__cSstj�dfS)Nr)r'r()r�filer1rrr�retrfilessz5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilecSsdS)Nr)rrrrr+vsz2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.close)r,r-r.r>r@r+rrrr�FakeFtpWrappernsrA)�objectrr�
ftpwrapper�_ftpwrapper_class)rrArrr�fakeftpmszFakeFTPMixin.fakeftpcCs|jtj_dS)N)rDrrrC)rrrr�	unfakeftp|szFakeFTPMixin.unfakeftpN)r,r-r.rErFrrrrr:lsr:c@s�eZdZdZdd�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.

    cCsvtd|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)rPr+�os�removerrM)rrrr�tearDown�s
zurlopen_FileTests.tearDownc	Cs5x.dD]&}|jt|j|�d
|�qWdS)Nr)r*�	readlines�filenor+�info�geturl�getcode�__iter__z/object returned by urlopen() lacks %s attribute)	r)r*rVrWr+rXrYrZr[)�
assertTrue�hasattrrP)r�attrrrr�test_interface�s

z urlopen_FileTests.test_interfacecCs |j|j|jj��dS)N)�assertEqualrLrPr))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)r`rLrPr*)rrrr�
test_readline�szurlopen_FileTests.test_readlinecCsF|jj�}|jt|�dd�|j|d|jd�dS)Nrz.readlines() returned the wrong number of linesrz"readlines() returned improper text)rPrVr`r
rL)rZ
lines_listrrr�test_readlines�s
z urlopen_FileTests.test_readlinescCsQ|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)	rPrW�assertIsInstance�intr`rSr)r
rL)rZfile_numrrr�test_fileno�s$zurlopen_FileTests.test_filenocCs|jj�dS)N)rPr+)rrrr�
test_close�szurlopen_FileTests.test_closecCs#|j|jj�tjj�dS)N)rdrPrX�email�message�Message)rrrr�	test_info�szurlopen_FileTests.test_infocCs |j|jj�|j�dS)N)r`rPrYrO)rrrr�test_geturl�szurlopen_FileTests.test_geturlcCs|j|jj��dS)N)ZassertIsNonerPrZ)rrrr�test_getcode�szurlopen_FileTests.test_getcodecCs+x$|jD]}|j||j�q
WdS)N)rPr`rL)r�linerrr�	test_iter�szurlopen_FileTests.test_itercCs$|jttjjd|j�dS)Nz./)�assertRaises�
ValueErrorrrrrO)rrrr�test_relativelocalfile�sz(urlopen_FileTests.test_relativelocalfileN)r,r-r.�__doc__rRrUr_rarbrcrfrgrkrlrmrorrrrrrrG�s	rGc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�
ProxyTestscCsOtj�|_x9ttj�D](}d|j�kr|jj|�qWdS)N�proxy)rZEnvironmentVarGuard�env�listrS�environ�lower�unset)r�krrrrR�szProxyTests.setUpcCs|jj�|`dS)N)rv�__exit__)rrrrrU�s
zProxyTests.tearDowncCs�|jjdd�tjj�}|jd|d�|jjdd�|jtjjd��|jtjjd��|jtjjd��dS)N�NO_PROXY�	localhost�noz0localhost, anotherdomain.com, newdomain.com:1234zanotherdomain.comzanotherdomain.com:8888znewdomain.com:1234)rv�setrr�getproxies_environmentr`r\�proxy_bypass_environment)rrrrr�+test_getproxies_environment_keep_no_proxies�sz6ProxyTests.test_getproxies_environment_keep_no_proxiescCs�zl|jjdd�tjj�}|jd|d�|jjdd�tjj�}|jd|�Wd|jjd�|jjd�XdS)N�
HTTP_PROXYzhttp://somewhere:3128r3ZREQUEST_METHOD�GET)rvr�rrr�r`�assertNotInrz)rrrrr�test_proxy_cgi_ignore�sz 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.tr~Z	LocalHostZ	LOCALHOSTznewdomain.com:1234z	foo.d.o.tzanotherdomain.com:8888zwww.newdomain.com:1234Zprelocalhostz
newdomain.comznewdomain.com:1235)rrr�rvr�r\�assertFalse)rZbypassrrr�(test_proxy_bypass_environment_host_match�sz3ProxyTests.test_proxy_bypass_environment_host_matchN)r,r-r.rRrUr�r�r�rrrrrt�s
rtc@s4eZdZdd�Zdd�Zdd�ZdS)�ProxyTests_withOrderedEnvcCstj|_tj�t_dS)N)rSrx�
_saved_env�collections�OrderedDict)rrrrrRszProxyTests_withOrderedEnv.setUpcCs|jt_dS)N)r�rSrx)rrrrrUsz"ProxyTests_withOrderedEnv.tearDowncCs]dtjd<dtjd<|jtjjd��|jtjjd��dtjd<dtjd<tjj�}|ji|�d	tjd<d
tjd<|jtjjd��|jtjjd��|jtjjd��|jtjjd
��|jtjjd��dtjd<dtjd<tjj�}|jd|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_Proxyr3)	rSrxr�rrr�r�r`r\)rrrrr�,test_getproxies_environment_prefer_lowercases&







zFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercaseN)r,r-r.rRrUr�rrrrr�	sr�c@s`eZdZdZdd�Zdd�Zdd�Zeje	d�d	d
��Z
eje	d�dd��Zd
d�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zejejd#d$�d%d&��Zd'd(�Zd)d*�Zd+d,�Zeje	d�d-d.��Zd/S)0�urlopen_HttpTestsz.Test urlopen() opening a fake http connection.c
Cs�|jd|d�zhtd�}|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%��)r6rr`r*rYrZr9)rZver�fprrr�
check_read0szurlopen_HttpTests.check_readc
CsQd}|jd�z,tjj|�}|j|j�|�Wd|j�XdS)Nz-http://docs.python.org/library/urllib.html#OKsHTTP/1.1 200 OK

Hello!)r6rrrr`rYr9)rrr�rrr�test_url_fragment;s
z#urlopen_HttpTests.test_url_fragmentc
CsB|jd�z#td�}|j|jj�Wd|j�XdS)NsHTTP/1.1 200 OK

Hello!zhttp://www.python.org)r6rr\r�Z
will_closer9)r�resprrr�test_willcloseEs

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

Hello.�\z\\zcontain control.*{}zhttp:{}zhttps:{})rw�range�chr�formatr6�repr�replacer3r4�
InvalidURL�assertRaisesRegexrrrr�rYr9)rZchar_nor�schemeless_urlZescaped_char_reprr�r�rrr�#test_url_with_control_char_rejectedMs$#
  z5urlopen_HttpTests.test_url_with_control_char_rejectedcCs|jd�d}d|d}z�tjj}|j|d��tjjdj|��WdQRX|j|d��tjjdj|��WdQRXtdj|��}|j	d	|j
��|j	d
|j
��|j	d|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:{}� �
�
)r6r3r4r�r�rrrr�r�rYr9)rr<r�r�r�rrr�/test_url_with_newline_header_injection_rejectedjs

  zAurlopen_HttpTests.test_url_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
Cs6|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/)r6rp�OSErrorrr9)rrrr�test_read_bogus�s
z!urlopen_HttpTests.test_read_boguscCsS|jd�z4d}|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/)r6r�r�error�	HTTPErrorrr9)r�msgrrr�test_invalid_redirect�sz'urlopen_HttpTests.test_invalid_redirectcCsYxRtt�j�D]>}|jd�z|jtjjtd�Wd|j	�XqWdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
zhttp://something)
r�rZmaxtriesr6rprr�r�rr9)r�irrr�test_redirect_limit_independent�sz1urlopen_HttpTests.test_redirect_limit_independentc
Cs6|jd�z|jttd�Wd|j�XdS)Nr%zhttp://something)r6rpr�rr9)rrrr�test_empty_socket�s
z#urlopen_HttpTests.test_empty_socketc	CsS|jtjj��}td�WdQRX|j|jj�|j|jj�dS)Nz/file://localhost/a/file/which/doesnot/exists.py)	rprr��URLErrorrr\�	exception�filename�reason)r�errr�test_missing_localfile�sz(urlopen_HttpTests.test_missing_localfilecCs�tj�\}}d|jtjjd�}z@|jtjj|��t|��}|j|�WdQRXWdtj	|�tj
|�X|jtjj|��|jt
jj��t|�WdQRXdS)Nzfile://localhost/�/)�tempfile�mkstempr�rS�path�sepr\�existsrr+�unlinkr�rprr�r�)r�fdZtmp_fileZtmp_fileurlZfobjrrr�test_file_notexists�s
z%urlopen_HttpTests.test_file_notexistsc	CsYd}|jtjj��}t|�WdQRX|j|jj�|j|jj	�dS)Nzftp:///path)
rprr�r�rr�r�r�r\r�)rZtest_ftp_urlr�rrr�test_ftp_nohost�s
z!urlopen_HttpTests.test_ftp_nohostc	CsS|jtjj��}td�WdQRX|j|jj�|j|jj	�dS)Nz.ftp://localhost/a/file/which/doesnot/exists.py)
rprr�r�rr�r�r�r\r�)rr�rrr�test_ftp_nonexisting�sz&urlopen_HttpTests.test_ftp_nonexistingZMAXFTPCACHErcCsR|j�z6tjjddddg�tjjd<td�Wd|j�XdS)Nr;�passr~��testzftp://localhost)rErrrCZftpcacherrF)rrrr�test_ftp_cache_pruning�s

(z(urlopen_HttpTests.test_ftp_cache_pruningc
Cs�|jd�zhtd�}|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�)r6rr`r*rYrZr9)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�)r6r�r3r4r5r�encode�decoder�assertInrr`r*ZassertNotEqualrYrZr9)rZuserpassrZfakehttp_wrapperZ
authorizationr�rrr�test_userpass_inurl_w_spaces�s
z.urlopen_HttpTests.test_userpass_inurl_w_spacesc	Cs.tjdtf��tjj�WdQRXdS)Nr�)rrrrr�	URLopener)rrrr�test_URLopener_deprecationsz,urlopen_HttpTests.test_URLopener_deprecationc
CsCtj�}|jt��!tjjdddd|�WdQRXdS)Nzhttps://localhostZcafilez/nonexistent/path�context)�sslZcreate_default_contextrprqrrr)rr�rrr�test_cafile_and_contexts	z)urlopen_HttpTests.test_cafile_and_contextN) r,r-r.rsr�r�r��unittest�
skipUnlessr�r�r�r�r�r�r�r�r�r�r�r�r�r�rrBrrr�r�r�r�r�rrrrr�-s,

	$	r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�urlopen_DataTestsz"Test urlopen() opening a data URL.cCsyd|_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)rL�image�text_url�text_url_base64�	image_urlrrr�
text_url_resp�text_url_base64_resp�image_url_resp)rrrrrRs						zurlopen_DataTests.setUpcCs5x.d
D]&}|jt|j|�d	|�qWdS)Nr)r*rVr+rXrYrZr[z/object returned by urlopen() lacks %s attribute)r)r*rVr+rXrYrZr[)r\r]r�)rr^rrrr_8s

z urlopen_DataTests.test_interfacecCs�|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�)rdr�rXrhrirjr`r��
get_paramsr��strr
r�rrr)rrrrrk@s
!zurlopen_DataTests.test_infocCsX|j|jj�|j�|j|jj�|j�|j|jj�|j�dS)N)r`r�rYr�r�r�r�r�)rrrrrlIs
zurlopen_DataTests.test_geturlcCsB|j|jj�jt|jj�j��d�|j�dS)Nr�)r`r�r)r��dictrXr�rL)rrrr�test_read_textOsz urlopen_DataTests.test_read_textcCsB|j|jj�jt|jj�j��d�|j�dS)Nr�)r`r�r)r�r�rXr�rL)rrrr�test_read_text_base64Ssz'urlopen_DataTests.test_read_text_base64cCs |j|jj�|j�dS)N)r`r�r)r�)rrrr�test_read_imageXsz!urlopen_DataTests.test_read_imagecCs|jttjjd�dS)Nzdata:text/plain)rprqrrr)rrrr�test_missing_comma[sz$urlopen_DataTests.test_missing_commacCs|jttjjd�dS)Nzdata:;base64,Cg=)rprqrrr)rrrr�test_invalid_base64_data^sz*urlopen_DataTests.test_invalid_base64_dataN)
r,r-r.rsrRr_rkrlr�r�r�r�r�rrrrr�s	r�c@s�eZdZdZdd�Zdd�Zdd�Zdd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�urlretrieve_FileTestsz(Test urllib.urlretrieve() on local filescCssg|_|jtj�d|_z0ttjd�}|j|j�|j�Wdy|j�WnYnXXdS)Nstesting urllib.urlretrieverI)�	tempFiles�registerFileForCleanUprrMrLrrNr+)r�FILErrrrRfs		zurlretrieve_FileTests.setUpc
Cs4x-|jD]"}ytj|�Wq
Yq
Xq
WdS)N)r�rSrT)rZeachrrrrU{s
zurlretrieve_FileTests.tearDowncCs[tjj|�}y|jd�Wn!tk
rFtjd��YnXdtjj	|�S)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rSr��abspathr��UnicodeEncodeErrorr�ZSkipTestrrr)rZfilePathrrr�constructLocalFileUrl�s
z+urlretrieve_FileTests.constructLocalFileUrlr%cCsmtj�\}}z:|j|�tj|d�}|j|�|j�Wdy|j�WnYnXX|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.rIN)r�r�r�rS�fdopenrNr+)rrZnewFdZnewFilePathZnewFilerrr�createNewTempFile�s

z'urlretrieve_FileTests.createNewTempFilecCs|jj|�dS)N)r��append)rZfileNamerrrr��sz,urlretrieve_FileTests.registerFileForCleanUpcCsQtjjdtj�}|j|dtj�|j|dtjj	d�dS)Nzfile:%srrzFdid not get an email.message.Message instance as second returned value)
rr�urlretrieverrMr`rdrhrirj)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�WnYnXX|j|j|�dS)Nz%s.2rzcopy of the file was not made�rb)rrMr�rrr�r�r`r\rSr�r�rr)r+rL)r�second_tempr�r�rLrrr�	test_copy�s

zurlretrieve_FileTests.test_copycsXdg�fdd�}dtj}�j|�tjj�jtj�||�dS)NrcsZ�j|t��j|t��j|t��j||d�|dd|d<dS)Nrr)rdrer`)�block_count�block_read_size�	file_sizeZcount_holder)rrr�
hooktester�s
z9urlretrieve_FileTests.test_reporthook.<locals>.hooktesterz%s.2)rrMr�rrr�r�)rr�r�r)rr�test_reporthook�s

	z%urlretrieve_FileTests.test_reporthookcCsug}|dd�}|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�rrMr`r
)r�reportr��srcFileNamerrr�test_reporthook_0_bytes�s
z-urlretrieve_FileTests.test_reporthook_0_bytescCs�g}|dd�}|jd�}tjj|j|�tj|�|jt|�d�|j|ddd�|j|ddd�dS)	NcSs|j|||f�dS)N)r�)r�r�r�r�rrrr��szAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktester�x�rrrsxxxxx)	r�rrr�r�rrMr`r
)rr�r�rrrr�test_reporthook_5_bytes�s
z-urlretrieve_FileTests.test_reporthook_5_bytescCs�g}|dd�}|jdd�}tjj|j|�tj|�|jt|�d�|j|ddd�|j|ddd	�|j|ddd	�|j|ddd	�dS)
NcSs|j|||f�dS)N)r�)r�r�r�r�rrrr��szDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktesterri �rrri )	r�rrr�r�rrMr`r
)rr�r�rrrr�test_reporthook_8193_bytes�s
z0urlretrieve_FileTests.test_reporthook_8193_bytesN)r,r-r.rsrRrUr�r�r�r�r�r�rrrrrrrr�cs	r�c@s.eZdZdZdd�Zdd�ZdS)�urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionscCsb|jd�dd�}|jtjj��-ztjjdd|�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�_reporthook�szYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthookzhttp://example.com/Z
reporthook)r6rprr��ContentTooShortErrorrr�r9)rrrrr�.test_short_content_raises_ContentTooShortError�szDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorcCsP|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/)r6rprr�r	rr�r9)rrrr�Atest_short_content_raises_ContentTooShortError_without_reporthookszWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookN)r,r-r.rsr
rrrrrr�src@s�eZdZdZdd�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

    cCs}djddddg�}tjj|�}|j||d||f�tjj|�}|j||d||f�dS)Nr�ZABCDEFGHIJKLMNOPQRSTUVWXYZZabcdefghijklmnopqrstuvwxyz�
0123456789z_.-zusing quote(): %r != %rzusing quote_plus(): %r != %r)�joinr�parse�quoter`�
quote_plus)rZdo_not_quoter�rrr�test_never_quote2s	zQuotingTests.test_never_quotecCs!|jtjjjdd�dS)Nrr�)r`rrr�__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�tjjddddd	�}tjjddddd
�}|j||d||f�tjjddddd�}tjjddddd
�}|j||d||f�dS)Nz<>�safezusing quote(): %r != %rzusing quote_plus(): %r != %rs<>uaüb�encodingzlatin-1�ür�s�)rrrr`r)rZquote_by_defaultr��expectrrr�	test_safeCs,	zQuotingTests.test_safecCsFdd�td�D�}|jd�|jtd��dj|�}x�|D]�}tjj|�}|jt|�|d|t|�|f�tjj	|�}|jt|�|d|t|�|f�qOW~d	}d
}tjj|�}|j||d||f�tjj	|�}|j||d||f�dS)
NcSsg|]}t|��qSr)r�)�.0�numrrr�
<listcomp>cs	z5QuotingTests.test_default_quoting.<locals>.<listcomp>� z
<>#%"{}|\^[]`r�r�z1using quote(): %s should be escaped to %s, not %sz6using quote_plus(): %s should be escapes to %s, not %szab[]cdz
ab%5B%5Dcdzusing quote(): %r != %rzusing quote_plus(): %r != %r)
r�r�r�rrrrr`rr)rZshould_quoterr�Z
partial_quote�expectedrrr�test_default_quoting`s,

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)rrrr`rrr�)rr��givenrrrr�test_quoting_space|szQuotingTests.test_quoting_spacecCsz|jtjjd�d�|jtjjdd�d�|jtjjd�d�|jtjjdd�d�dS)Nzalpha+beta gammazalpha%2Bbeta+gammar zalpha+beta+gammasalpha+beta gamma�+)r`rrr)rrrr�test_quoting_plus�szQuotingTests.test_quoting_pluscCs�d}d}tjj|�}|j||d||f�|jttjj|dd�tjj|�}|j||d||f�dS)Ns��ab�z%A2%D8ab%FFzusing quote(): %r != %rrzlatin-1z"using quote_from_bytes(): %r != %r)rrrr`rp�	TypeErrorZquote_from_bytes)rr!rr�rrr�test_quote_bytes�szQuotingTests.test_quote_bytescCs�d}d}tjj|�}|j||d||f�tjj|dddd�}|j||d||f�d}d}tjj|dd�}|j||d||f�d}d	}tjj|�}|j||d||f�d}|jttjj|dd�d}d
}tjj|dddd�}|j||d||f�d}d}tjj|dddd
�}|j||d||f�dS)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFzusing quote(): %r != %rr�errorsz%A2%D8ab%FFzlatin-1u漢字z%E6%BC%A2%E5%AD%97z%3F%3Fr�z%26%2328450%3B%26%2323383%3B�xmlcharrefreplace)rrrr`rpr�)rr!rr�rrr�test_quote_with_unicode�sB		z$QuotingTests.test_quote_with_unicodecCs�d}d}tjj|dd�}|j||d||f�d}d}tjj|dddd	�}|j||d||f�dS)
Nu¢Ø ÿz
%A2%D8+%FFrzlatin-1zusing quote_plus(): %r != %ruab漢字 cdzab%3F%3F+cdr'r�)rrrr`)rr!rr�rrr�test_quote_plus_with_unicode�s	z)QuotingTests.test_quote_plus_with_unicodeN)
r,r-r.rsrrrrr"r$r&r)r*rrrrrs
*rc@sjeZdZdZdd�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.

    cCsng}x�td�D]�}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: %s�quietTr%)r�rr�rr�unquoter`�unquote_plusr�r�countrpr%�AttributeErrorrr�BytesWarning)rZescape_listrr!rr�Z
escape_stringrrr�test_unquoting�s,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	rHz"using unquote_to_bytes(): %r != %r)	rrr.r`rJ�unquote_to_bytesrpr%r1)rr!rr�rrr�test_unquoting_badpercents@z(UnquotingTests.test_unquoting_badpercentcCs?d}d}tjj|�}|j||d||f�dS)Nz%Ab%eAs��z"using unquote_to_bytes(): %r != %r)rrr4r`)rr!rr�rrr�test_unquoting_mixed_case)s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)rrrr.r`r/)rr!rr�rrr�test_unquoting_parts2s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)rrr.r`r�r/)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)rrr4r`)rr!rr�rrr�test_unquote_to_bytesJs.z$UnquotingTests.test_unquote_to_bytescCsd}d}tjj|�}|j||d||f�tjj|dddd�}|j||d||f�tjjddd�}d}|j||d||f�d}d	}tjj|�}|j||d||f�d
}d}tjj|�}|j||d||f�tjj|dd�}|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 != %rrr'zbr%FCckner_sapporo_20050930.doczlatin-1z%E6%BC%A2%E5%AD%97u漢字z%F3%B1u�r�r��ignoreu	漢%C3%BCu漢üu漢%FC)rrr.r`)rr!rr�rrr�test_unquote_with_unicodeisN	z(UnquotingTests.test_unquote_with_unicodeN)r,r-r.rsr3r5r6r8r9r:r<rrrrr+�s$	r+c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�urlencode_TestszTests for urlencode()c	Csdddg}tjj|�}x.|D]&}|j||d|||f�q(W|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 %srrz5testing %s: unexpected number of characters: %s != %sN��r?r@)
rr�	urlencoder�r`r0�indexr\�isdigitr
)	rr!Z	test_typeZexpect_somewherer�rZamp_locationZon_amp_leftZon_amp_rightrrr�help_inputtype�s$
zurlencode_Tests.help_inputtypecCs&|jddddddid�dS)N�1st�1�2nd�2�3rd�3zusing dict as input type)rD)rrrr�test_using_mapping�sz"urlencode_Tests.test_using_mappingcCs|jdd	d
gd�dS)NrErFrGrHrIrJz*using sequence of two-item tuples as input)rErF)rGrH)rIrJ)rD)rrrr�test_using_sequence�sz#urlencode_Tests.test_using_sequencecCs�ddi}dtd�td�f}tjj|�}|j||�ddi}d}tjj|�}|j||�dS)Nr>�=z%s=%szkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrrAr`)rr!rr�rrr�test_quoting�szurlencode_Tests.test_quotingcCs�ddddgi}dtjjtdddg��}tjj|�}|j||�tjj|d�}x,|dD] }d|}|j||�q|W|j|jd�dd	|jd��dS)
NZsequencerFrHrJzsequence=%sTr>rzExpected 2 '&'s, got %s)rrrr�rAr`r�r0)rr!rr��valuerrr�
test_doseq�s%
zurlencode_Tests.test_doseqcCs<|jdtjji��|jdtjjg��dS)Nr�)r`rrrA)rrrr�test_empty_sequence�sz#urlencode_Tests.test_empty_sequencecCsH|jdtjjddi��|jdtjjddi��dS)Nza=1�arza=None)r`rrrA)rrrr�test_nonstring_values�s"z%urlencode_Tests.test_nonstring_valuescCs�|jdtjjdddgid��|jdtjjdddgid��tjd	d
g�}|jdtjjd|id��dS)Nza=1&a=2rRrrTz
a=None&a=a�bza=a&a=b)rRr)rTr)r`rrrAr�r�)rrrrr�test_nonstring_seq_values�s+	"	z)urlencode_Tests.test_nonstring_seq_valuescCs�d}d}tjj|dddd�}|j||�d}d}tjj|�}|j||�d}d	}tjj|dd
�}|j||�dS)N� �Áz%3F=%3Frr�r'r�z
%C2%A0=%C3%81z%A0=%C1zlatin-1�rVrW)rX�rVrW)rY�rVrW)rZ)rrrAr`)rr!rr�rrr�test_urlencode_encoding�sz'urlencode_Tests.test_urlencode_encodingcCsQd}d}tjj|dddddd	�}|j||�d}d}tjj|ddddd	�}|j||�d}d}tjj|d�}|j||�d}d}tjj|d�}|j||�d}d}tjj|ddd�}|j||�d }d}tjj|ddd�}|j||�dS)!NrVrWz%3F=%3F�doseqTrr�r'r�rz
%3F=1&%3F=%3Fz
%C2%A0=%C3%81�*z%C2%A0=42&%C2%A0=%C3%81z%A0=%C1zlatin-1z%A0=42&%A0=%C1�rVrW)r^�rrW�rVr_)r`�rVrW)ra�r]rW�rVrb)rc�rVrW)rd�r]rW�rVre)rf)rrrAr`)rr!rr�rrr�test_urlencode_encoding_doseqs4z-urlencode_Tests.test_urlencode_encoding_doseqcCs�d}d}tjj|�}|j||�tjj|d�}|j||�d}d}tjj|d�}|j||�dS)N��$��$z
%A0%24=%C1%24Tr]z%A0%24=42&%A0%24=%C1%24�rhri)rj�r]ri�rhrk)rl)rrrAr`)rr!rr�rrr�test_urlencode_bytes0sz$urlencode_Tests.test_urlencode_bytescCsPd}tjj|dd�}d}|j||�d}tjj|dddd�}d}|j||�d}d
}tjj|ddd�}|j||�d}tjj|dddd�}d}|j||�d}d}tjj|dddddd�}d}d
}tjj|ddddd�}|j||�dS)N��$��$rz:$z	%A0$=%C1$r\T�
r]z%A0$=%C1$&%A0$=13&%A0$=42rzlatin-1�rnro)rq�rnro)rr�rorpr]�rnrs)rt�rnro)ru�rnro)rv�rorpr]�rnrw)rx)rrrAr`)rr!r�rrrr�&test_urlencode_encoding_safe_parameter>s4			z6urlencode_Tests.test_urlencode_encoding_safe_parameterN)r,r-r.rsrDrKrLrNrPrQrSrUr[rgrmryrrrrr=�s 
%r=c@sUeZdZdZdd�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�partsZofrRr�zparts/of/a/pathzpathname2url() failed; %s != %szurl2pathame() failed; %s != %s)rSr�rrrrr`r)rZ
expected_pathZexpected_urlr�rrrr�is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)
rSr�rrrrrrr`r)rr!rr�rrrrNvs.zPathname_Tests.test_quoting�win32z.test specific to the urllib.url2path function.cCs�d	}d}x=|D]5}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~rr�)rrrr`)rr!rrr�rrr�test_ntpath�s
zPathname_Tests.test_ntpathN)r,r-r.rsr�rNr�r��sys�platformr�rrrrrzfs

rzc@s"eZdZdZdd�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)rdrrZthishost�tuple)rrrr�
test_thishost�szUtility_Tests.test_thishostN)r,r-r.rsr�rrrrr��sr�c@s.eZdZdZdd�Zdd�ZdS)�URLopener_Testsz4Testcase to test the open method of URLopener class.c
CsuGdd�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�sr�z8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr�rrrr`r)rr�rrr�test_quoted_open�s

z URLopener_Tests.test_quoted_opencCs�Gdd�dtjj�}tjdd���tjdt�x�dD]�}|jttjj	|�|jttjj�j
|�|jttjj�j|�|jt|�j
|�|jt|�j|�qFWWdQRXdS)	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��sr��recordTr;�local_file://example�local-file://example)r�r�)rrr��warnings�catch_warnings�simplefilterrrpr�rrZretrieve)rr�rrrr�test_local_file_open�s
z$URLopener_Tests.test_local_file_openN)r,r-r.rsr�r�rrrrr��sr�c@s.eZdZdZdd�Zdd�ZdS)�RequestTestsz&Unit tests for urllib.request.Request.cCsWtjj}|d�}|j|j�d�|di�}|j|j�d�dS)Nzhttp://www.python.orgr�ZPOST)rr�Requestr`�
get_method)rr�rrrr�test_default_valuess
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.org�methodZHEADr�)rrr�r`r�r�)rr�rrrr�test_with_method_arg&s	z!RequestTests.test_with_method_argN)r,r-r.rsr�r�rrrrr�sr�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�URL2PathNameTestscCsF|jtd�d�|jtd�d�|jtd�d�dS)Nz///C|zC:z///C:z///C|/zC:\)r`r)rrrr�test_converting_drive_letter6sz.URL2PathNameTests.test_converting_drive_lettercCs0|jtd�d�|jtd�d�dS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\)r`r)rrrr�$test_converting_when_no_drive_letter;sz6URL2PathNameTests.test_converting_when_no_drive_lettercCs|jtd�d�dS)Nz///C|/foo/bar/spam.foozC:\foo\bar\spam.foo)r`r)rrrr�test_simple_compare@sz%URL2PathNameTests.test_simple_comparecCs|jttd�dS)Nu///è|/)rp�IOErrorr)rrrr�test_non_ascii_drive_letterDsz-URL2PathNameTests.test_non_ascii_drive_lettercCs@dddg}x*|D]"}|jtt|��|�qWdS)NzC:z\\\C\test\\zC:\foo\bar\spam.foo)r`rr)r�
list_of_pathsr�rrr�test_roundtrip_url2pathnameGs
	
z-URL2PathNameTests.test_roundtrip_url2pathnameN)r,r-r.r�r�r�r�r�rrrrr�4s
r�c@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�PathName2URLTestscCs0|jtd�d�|jtd�d�dS)NzC:z///C:zC:\)r`r)rrrrr�Qsz.PathName2URLTests.test_converting_drive_lettercCsF|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/)r`r)rrrrr�Usz6PathName2URLTests.test_converting_when_no_drive_lettercCs|jtd�d�dS)NzC:\foo\bar\spam.fooz///C:/foo/bar/spam.foo)r`r)rrrrr�]sz%PathName2URLTests.test_simple_comparecCs|jttd�dS)NzXX:\)rpr�r)rrrr�test_long_drive_letterasz(PathName2URLTests.test_long_drive_lettercCs@dddg}x*|D]"}|jtt|��|�qWdS)Nz///C:z/////folder/test/z///C:/foo/bar/spam.foo)r`rr)rr�r�rrr�test_roundtrip_pathname2urlds
	
z-PathName2URLTests.test_roundtrip_pathname2urlN)r,r-r.r�r�r�r�r�rrrrr�Os
r��__main__)6rsZurllib.parserZurllib.requestZurllib.errorZhttp.clientr3Z
email.messagerhr'r�Z
unittest.mockrr�rrSr��ImportErrorr�r�r�Z
nturl2pathrr�base64rr�rrrrr6rBr7r:ZTestCaserGrtr�r�r�r�rrr+r=rzr�r�r�r�r�r,�mainrrrr�<module>sZ
'	S6$�J�)���<r