python (3.11.7)

(root)/
lib/
python3.11/
test/
__pycache__/
test_urllib.cpython-311.opt-1.pyc

evdZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZddl
mZddlmZddlmZddlmZddlZ	ddlZn
#e$rdZYnwxYwddlZddlZddlmZmZdd	lmZddlZejse
jd
dZ da!d5dZ"d
Z#d6dZ$Gdde%Z&Gdde%Z'Gdde
j(Z)Gdde
j(Z*Gdde
j(Z+Gdde
j(e&e'Z,Gdde
j(Z-Gdde
j(Z.Gd d!e
j(e&Z/Gd"d#e
j(Z0Gd$d%e
j(Z1Gd&d'e
j(Z2Gd(d)e
j(Z3Gd*d+e
j(Z4Gd,d-e&e
j(Z5Gd.d/e
j(Z6Gd0d1e
j(Z7Gd2d3e
j(Z8e9d4kre
j:dSdS)7z;Regression tests for what was in Python 2's "urllib" moduleN)patch)support)	os_helper)
socket_helper)warnings_helper)url2pathnamepathname2url)	b64encodeztest requires gethostname()ctt|dd}t|dkrd|z}d|zS)z!Escape char as RFC 2396 specifiesNz0%s%)hexordupperlen)charhex_reprs  D/BuggyBox/python/3.11.7/bootstrap/lib/python3.11/test/test_urllib.py	hexescaper sM3t99~~abb!''))H
8}}8#>c|!tj|}ntst}|ant}|||S|||S)z.urlopen(url [, data]) -> open file-like objectN)proxies)urllibrequestFancyURLopener
_urlopeneropen)urldataropeners    rurlopenr"+sn..w.??
!!

|{{3{{3%%%rctjdtf5tjcdddS#1swxYwYdS)Nz8FancyURLopener style of invoking requests is deprecated.)rcheck_warningsDeprecationWarningrrrrrrr;s		'
G
 
!
!//~,,..//////////////////sAAAFcGfddtjGfddtjj|_S)Nc:eZdZdZfdZdZddZddZdZdS)	fakehttp.<locals>.FakeSocketr
c|_dSN)buf)selfr FakeHTTPConnections  rsendallz$fakehttp.<locals>.FakeSocket.sendallFs%)"""rc&|xjdz
c_|S)Nr
)io_refs)r-argskwdss   rmakefilez%fakehttp.<locals>.FakeSocket.makefileIsLLALLKrNcT|jrdStj||SNr)closedioBytesIOread)r-amts  rr:z!fakehttp.<locals>.FakeSocket.readMs'{
s:??4---rcT|jrdStj||Sr6)r7r8r9readline)r-lengths  rr=z%fakehttp.<locals>.FakeSocket.readlineRs){
s:&&tV444rc~|xjdzc_|jdkr!tj|dSdS)Nr
r)r1r8r9closer-s rr@z"fakehttp.<locals>.FakeSocket.closeWsCLLALL|q  
  &&&&&! rr+)	__name__
__module____qualname__r1r/r4r:r=r@)r.sr
FakeSocketr)Csy	*	*	*	*	*				.	.	.	.
	5	5	5	5
	'	'	'	'	'rrEc,eZdZdZfdZrdZdSdS)$fakehttp.<locals>.FakeHTTPConnectionNcd|j|_|jt|_dSr+)fakedatasocktypefakesock)r-rEs rconnectz,fakehttp.<locals>.FakeHTTPConnection.connectas,"
4=11DI"&)DJJrcdSr+r&rAs rr@z*fakehttp.<locals>.FakeHTTPConnection.closejr)rBrCrDr,rMr@)rE
mock_closesrr.rG\sX	,	,	,	,	,	





		rr.)r8r9httpclientHTTPConnectionrI)rIrPr.rEs `@@rfakehttprTBs'''''''RZ'''2T[7 #+rceZdZddZdZdS)
FakeHTTPMixinFcvt||}tjj|_|tj_dS)NrP)rTrQrRrS_connection_class)r-rIrPfake_http_classs    rrTzFakeHTTPMixin.fakehttprs1"8
CCC!%!;%4"""rc2|jtj_dSr+)rYrQrRrSrAs r
unfakehttpzFakeHTTPMixin.unfakehttpws%)%;"""rNF)rBrCrDrTr\r&rrrVrVqs75555
<<<<<rrVceZdZdZdZdS)FakeFTPMixinczGddt}tjj|_|tj_dS)Nc&eZdZ		ddZdZdZdS),FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapperNTcdSr+r&)r-userpasswdhostportdirstimeout
persistents        r__init__z5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.__init__~src,tjdfS)Nr)r8r9)r-filerKs   rretrfilez5FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.retrfilesz||Q&rcdSr+r&rAs rr@z2FakeFTPMixin.fakeftp.<locals>.FakeFtpWrapper.closerOr)NT)rBrCrDrkrnr@r&rrFakeFtpWrapperrb}sLHL $




'
'
'




rrp)objectrr
ftpwrapper_ftpwrapper_class)r-rps  rfakeftpzFakeFTPMixin.fakeftp|sK										V						"(!:$2!!!rc2|jtj_dSr+)rsrrrrrAs r	unfakeftpzFakeFTPMixin.unfakeftps$($:!!!rN)rBrCrDrtrvr&rrr_r_{s2
3
3
3;;;;;rr_creZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZdZdZdS)urlopen_FileTestszTest 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.

    ctd|jjzd|_t	t
jd}	||j|n#|wxYwt
j|_	tj|j	|_
td|j
z|_dS)Nztest_urllib: %s
asciiwbfile:%s)bytes	__class__rBtextrrTESTFNwriter@pathnamerparsequotequoted_pathnamer"returned_obj)r-fs  rsetUpzurlopen_FileTests.setUps-0GG!##	!4((	
GGDI
GGIIIIAGGIIII!(
%|11$-@@#I0D$DEEsA--Bct|jtjtjdS)zShut down the open objectN)rr@osremoverrrAs rtearDownzurlopen_FileTests.tearDowns0!!!
	)"#####rchdD].}|t|j|d|z/dS)N)	r:r=	readlinesfilenor@infogeturlgetcode__iter__/object returned by urlopen() lacks %s attribute)
assertTruehasattrrr-attrs  rtest_interfacez urlopen_FileTests.test_interfacesSG		DOOGD$5t<<J



		rcj||j|jdSr+)assertEqualrrr:rAs r	test_readzurlopen_FileTests.test_reads/D$5$:$:$<$<=====rc||j|j|d|jddS)NrzKcalling readline() after exhausting the file did not return an empty string)rrrr=rAs r
test_readlinezurlopen_FileTests.test_readlinescD$5$>$>$@$@AAAd/88::3	4	4	4	4	4rc|j}|t|dd||d|jddS)Nr
z.readlines() returned the wrong number of linesrz"readlines() returned improper text)rrrrr)r-
lines_lists  rtest_readlinesz urlopen_FileTests.test_readlinessm&0022
Z!I	K	K	KA	=	?	?	?	?	?rc|j}||td|tj|t|j|jddS)Nzfileno() did not return an intzTReading on the file descriptor returned by fileno() did not return the expected text)	rrassertIsInstanceintrrr:rr)r-file_nums  rtest_filenozurlopen_FileTests.test_filenosp$++--h-MNNN3ty>>::DI<	=	=	=	=	=rc8|jdSr+)rr@rAs r
test_closezurlopen_FileTests.test_closes	
!!!!!rcd||jjtjjdSr+)rrheadersemailmessageMessagerAs rtest_headerszurlopen_FileTests.test_headerss)d/79NOOOOOrcP||jj|jdSr+)rrrrrAs rtest_urlzurlopen_FileTests.test_urls'*.0DEEEEErcD||jjdSr+)assertIsNonerstatusrAs rtest_statuszurlopen_FileTests.test_statuss"$+233333rc~||jtjjdSr+)rrrrrrrAs r	test_infozurlopen_FileTests.test_infos2d/4466
8MNNNNNrcj||j|jdSr+)rrrrrAs rtest_geturlzurlopen_FileTests.test_geturls0*1133T5IJJJJJrc^||jdSr+)rrrrAs rtest_getcodezurlopen_FileTests.test_getcodes+$+335566666rcP|jD]}|||jdSr+)rrr)r-lines  r	test_iterzurlopen_FileTests.test_iters;%	.	.DT49----	.	.rcl|ttjjd|jzdS)Nz./)assertRaises
ValueErrorrrr"rrAs rtest_relativelocalfilez(urlopen_FileTests.test_relativelocalfiles,*V^%;D4=<PQQQQQrN)rBrCrD__doc__rrrrrrrrrrrrrrrrr&rrrxrxs"FFF$$$
>>>444???==="""
PPPFFF444OOOKKK777...RRRRRrrxc2eZdZdZdZdZdZdZdZdS)
ProxyTestsc|tj|_t	t
jD]2}d|vr|j|3dS)Nproxy)	enterContextrEnvironmentVarGuardenvlistrenvironlowerunset)r-ks  rrzProxyTests.setUpsk$$Y%B%D%DEEbj!!	"	"A!''))##q!!!	"	"rc|jddtj}|d|d|jdd|tjd|tjd|tjddS)NNO_PROXY	localhostno0localhost, anotherdomain.com, newdomain.com:1234anotherdomain.comanotherdomain.com:8888newdomain.com:1234)rsetrrgetproxies_environmentrrproxy_bypass_environmentr-rs  r+test_getproxies_environment_keep_no_proxiesz6ProxyTests.test_getproxies_environment_keep_no_proxiessZ---.7799gdm444Z!STTT??@STTUUU??@XYYZZZ??@TUUVVVVVrc*	|jddtj}|d|d|jddtj}|d||jd|jddS#|jd|jdwxYw)N
HTTP_PROXYhttp://somewhere:3128rQREQUEST_METHODGET)rrrrrrassertNotInrrs  rtest_proxy_cgi_ignorez ProxyTests.test_proxy_cgi_ignores		)HLL'>???n;;==G4gfoFFFHLL)5111n;;==GVW---HNN+,,,HNN<(((((
HNN+,,,HNN<((((sB$C6Dctjj}|jdd||d||d||d||d||d||d||d	||d
||d||d||d
||d||d||ddS)Nrz8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tr	LocalHost	LOCALHOSTz
.localhostrz.newdomain.com:1234z	foo.d.o.tzd.o.trz.anotherdomain.com:8888zwww.newdomain.com:1234prelocalhost
newdomain.comznewdomain.com:1235rrrrrrassertFalser-bypasss  r(test_proxy_bypass_environment_host_matchz3ProxyTests.test_proxy_bypass_environment_host_match
s8ZO	Q	Q	Q{++,,,{++,,,{++,,,|,,---344555455666{++,,,w(((788999899:::788999//00000111 45566666rctjj}|jdd||d||d|jdd||d||d||ddS)Nr*rrz*, anotherdomain.comrrrs  r*test_proxy_bypass_environment_always_matchz5ProxyTests.test_proxy_bypass_environment_always_match s8Z%%%//000344555Z!788823344400111 45566666rctjj}|jdd||d||d||ddS)Nrrz
localhost
zanotherdomain.com:8888
znewdomain.com:1234
)rrrrrrrs  r%test_proxy_bypass_environment_newlinez0ProxyTests.test_proxy_bypass_environment_newline*s8ZG	I	I	I
../// :;;<<< 67788888rN)	rBrCrDrrrrrrr&rrrrsq"""	W	W	W
)
)
)777&77799999rrc eZdZdZdZdZdS)ProxyTests_withOrderedEnvcbtj|_tjt_dSr+)rr
_saved_envcollectionsOrderedDictrAs rrzProxyTests_withOrderedEnv.setUp5s* ,..


rc(|jt_dSr+)rrrrAs rrz"ProxyTests_withOrderedEnv.tearDown;s_


rcdtjd<dtjd<|tjd|tjddtjd<dtjd<tj}|i|d	tjd<d
tjd<|tjd|tjd|tjd|tjd
|tjddtjd<dtjd<tj}|d|ddS)Nno_proxyrNo_Proxy	arbitrary
http_proxyrrz%localhost, noproxy.com, my.proxy:1234zxyz.comznoproxy.com:5678z
my.proxy:1234zmy.proxyzhttp://somewhereelse:3128
Http_ProxyrQ)	rrrrrrrrrrs  r,test_getproxies_environment_prefer_lowercasezFProxyTests_withOrderedEnv.test_getproxies_environment_prefer_lowercase>s!#
:!,
:@@MMNNN@@MMNNN#%
< #:
< .7799W%%%!H
:!*
:??LLMMM??@RSSTTT??PPQQQ@@LLMMM@@MMNNN#:
< #>
< .77990'&/BBBBBrN)rBrCrDrrrr&rrrr3sF///%%%CCCCCrrceZdZdZdZdZdZeje	ddZ
eje	ddZeje	ddZeje	dd	Z
d
ZdZdZd
ZdZdZdZdZdZdZdZejejdddZdZdZdZ eje	ddZ!dS)urlopen_HttpTestsz.Test urlopen() opening a fake http connection.c|d|zdz	td}||d||d||d||d|dS#|wxYw)NsHTTP/s 200 OK

Hello!http://python.org/Hello!rrTr"rr=rrr\)r-verfps   r
check_readzurlopen_HttpTests.check_readZs

hn'??@@@	-..BR[[]]I666R[[]]C000RYY[[*>???RZZ\\3///OODOOsB/C""C8cd}|d	tj|}||||dS#|wxYw)Nz-http://docs.python.org/library/urllib.html#OKHTTP/1.1 200 OK

Hello!)rTrrr"rrr\)r-rr	s   rtest_url_fragmentz#urlopen_HttpTests.test_url_fragmentes~=

6777	'',,BRYY[[#...OODOOsAA66Bc|d	td}||jj|dS#|wxYw)Nrhttp://www.python.org)rTr"rr	
will_closer\)r-resps  rtest_willclosez urlopen_HttpTests.test_willcloseosk

6777	233DOODG.///OODOOs.AA1zssl module requiredc*ttdddgzD]o}t|}d|d}|d	t	|dd}tjj}|	|d	|5tjd
|dddn#1swxYwY|	|d	|5tjd|dddn#1swxYwYtd
|}|
|||X#|wxYwdS)Nr!z//localhost:7777/test/HTTP/1.1 200 OK

Hello.\\\contain control.*http:https:)rrangechrrTreprreplacerQrR
InvalidURLassertRaisesRegexrrr"rrr\)r-char_norschemeless_urlescaped_char_reprr!rs       r(test_url_path_with_control_char_rejectedz:urlopen_HttpTests.test_url_path_with_control_char_rejectedwsFE!TNN++tf4	"	"Gw<<D<T<<<NMM:;;;
"%)JJ$6$6tU$C$C!![3
++ G4E G GIIEEN**+C>+C+CDDDEEEEEEEEEEEEEEE++ G4E G GIIFFN**+DN+D+DEEEFFFFFFFFFFFFFFF7~7788  t{{}}555!!!!!!!!/	"	"sUA
E:#CE:C	E:C	E:0#DE:D#	#E:&D#	'=E::Fc|dd}d|zdz}	tjj}||d5t
jd|dddn#1swxYwY||d5t
jd|dddn#1swxYwYtd|}|d	|	|d
|	|d|	|
dS#|
wxYw)Nrz:localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123//:8080/test/?test=az*contain control.*\\r.*(found at least . .)rcontain control.*\\nr 

)rTrQrRr!r"rrr"rrr\)r-rfr$r!rs     r4test_url_path_with_newline_header_injection_rejectedzFurlopen_HttpTests.test_url_path_with_newline_header_injection_rejecteds

6777O';;	/J''IKK
A
A&&'?~'?'?@@@
A
A
A
A
A
A
A
A
A
A
A
A
A
A
A''
4KLL
B
B&&'@'@'@AAA
B
B
B
B
B
B
B
B
B
B
B
B
B
B
B3>3344DS$++--000T4;;==111T4;;==111OODOOsT'E2#A7+E27A;;E2>A;?E2#C;E2CE2CB
E22FctttdddgzD]}t|}d|d}|d	t	|dd}tjj}|	|d	|5td
|dddn#1swxYwY|	|d	|5td|dddn#1swxYwY|#|wxYwdS)Nrrrz//localhostz/test/rrrrrr)rrrrTrr rQrRr!r"r"r\)r-r#rr$r%r!s      r(test_url_host_with_control_char_rejectedz:urlopen_HttpTests.test_url_host_with_control_char_rejectedsE!TNN++tf4
	"
	"Gw<<D74777NMM:;;;	
"$(JJ$6$6tU$C$C!![3
++ G4E G GII664N44555666666666666666++J8_L]8_8_``775^55666777777777777777!!!!!!!!
	"
	"sUA
DB<0D<C	DC	D C?3D?D	DD	DD5c|dd}d|zdz}	tjj}||d5td|dddn#1swxYwY||d5td|dddn#1swxYwY|dS#|wxYw)	Nrzlocalhost
X-injected: header
r(r)zcontain control.*\\rrr*r)rTrQrRr!r"r"r\)r-rfr$r!s    r4test_url_host_with_newline_header_injection_rejectedzFurlopen_HttpTests.test_url_host_with_newline_header_injection_rejectedss

67774';;	/J''355
2
2000111
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2''
4KLL
3
3111222
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
OODOOsS'CA'C'A++C.A+/CB'C'B++C.B+/CCc0|ddS)Ns0.9r
rAs r
test_read_0_9zurlopen_HttpTests.test_read_0_9s	
rc0|ddS)Ns1.0r4rAs r
test_read_1_0zurlopen_HttpTests.test_read_1_0rc0|ddS)Ns1.1r4rAs r
test_read_1_1zurlopen_HttpTests.test_read_1_1r8rc|dd	|ttd|dS#|wxYw)NsHTTP/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
TrXrrTrOSErrorr"r\rAs rtest_read_bogusz!urlopen_HttpTests.test_read_bogussq


					gw0DEEEOODOOs!AA&c,|dd	d}|tjj|5tddddn#1swxYwY|dS#|wxYw)NsHTTP/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
TrXzRedirection to url 'file:r)rTr"rerror	HTTPErrorr"r\)r-msgs  rtest_invalid_redirectz'urlopen_HttpTests.test_invalid_redirects


					-C''(>DD
.
.,---
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
OODOOs/'A=AA=A  A=#A $A==Bc,ttjD]r}|dd	|t
jjtd|	Z#|	wxYwdS)Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
TrXhttp://something)
rrmaxtriesrTrrr@rAr"r\)r-is  rtest_redirect_limit_independentz1urlopen_HttpTests.test_redirect_limit_independents~''011		"		"AMM




"!!&,"8'&(((!!!!!!!!		"		"s+A;;Bc|d	|ttd|dS#|wxYw)NrrEr<rAs rtest_empty_socketz#urlopen_HttpTests.test_empty_sockets`	


c	gw0BCCCOODOOs!AA$c|tjj5}t	ddddn#1swxYwY||jj||jjdS)Nz/file://localhost/a/file/which/doesnot/exists.py)	rrr@URLErrorr"r	exceptionfilenamereasonr-es  rtest_missing_localfilez(urlopen_HttpTests.test_missing_localfiles


v|4
5
5	GEFFF	G	G	G	G	G	G	G	G	G	G	G	G	G	G	G,---*+++++AAActj\}}d|tjjdz}	|tj|t|5}||dddn#1swxYwYtj	|tj
|n-#tj	|tj
|wxYw|tj||tjj5t|ddddS#1swxYwYdS)Nzfile://localhost/r)tempfilemkstempr rpathseprexistsr"r@unlinkrrrr@rL)r-fdtmp_filetmp_fileurlfobjs     rtest_file_notexistsz%urlopen_HttpTests.test_file_notexistss'))H)H,<,<RW[#,N,NN	 OOBGNN844555%%
&%%%
&
&
&
&
&
&
&
&
&
&
&
&
&
&
&
HRLLLIh
HRLLLIh11222


v|4
5
5	!	!K   	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!	!sCACB#C#B''C*B'+C*DE77E;>E;cd}|tjj5}t	|dddn#1swxYwY||jj||jj	dS)Nzftp:///path
rrr@rLr"rrMrNrrO)r-test_ftp_urlrQs   rtest_ftp_nohostz!urlopen_HttpTests.test_ftp_nohost s$


v|4
5
5	"L!!!	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"-...*+++++sAA
Ac|tjj5}t	ddddn#1swxYwY||jj||jj	dS)Nz.ftp://localhost/a/file/which/doesnot/exists.pyrarPs  rtest_ftp_nonexistingz&urlopen_HttpTests.test_ftp_nonexisting's


v|4
5
5	FDEEE	F	F	F	F	F	F	F	F	F	F	F	F	F	F	F-...*+++++rSMAXFTPCACHErc|	tjddddgtjjd<td|dS#|wxYw)Nrdpassrtestzftp://localhost)rtrrrrftpcacher"rvrAs rtest_ftp_cache_pruningz(urlopen_HttpTests.test_ftp_cache_pruning-sz	.4n.G.GPVXcegik.l.lFN#F+%&&&NNDNNsAA00Bc|d	td}||d||d||d||d|dS#|wxYw)NHTTP/1.0 200 OK

Hello!zhttp://user:pass@python.org/rrrr)r-r	s  rtest_userpass_inurlz%urlopen_HttpTests.test_userpass_inurl6s

6777	788BR[[]]I666R[[]]C000RYY[[*HIIIRZZ\\3///OODOOsB/CC2c|d	d}d|}tjj}dt|ddz}t|}|	||j
d||d||d|
||||d	|dS#|wxYw)
Nrnza b:c dzhttp://{}@python.org/zAuthorization: Basic %s
ASCIIzUTF-8rrr)rTformatrQrRrSr
encodedecoder"assertInr,rr=assertNotEqualrrr\)r-userpassrfakehttp_wrapper
authorizationr	s      rtest_userpass_inurl_w_spacesz.urlopen_HttpTests.test_userpass_inurl_w_spacesAsB

6777	 H)00::C#{9:&xw'?'?@@GGPPQMBMM-)9)=)D)DW)M)MNNNR[[]]I666R[[]]C000		S111RZZ\\3///OODOOsD=E**Fctjdtf5tjddddS#1swxYwYdSNr)rr$r%rr	URLopenerrAs rtest_URLopener_deprecationz,urlopen_HttpTests.test_URLopener_deprecationTs

+R0B,C
D
D	'	'N$$&&&	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'	'sAAAc<tj}tjdtf5|t5tj	dd|dddn#1swxYwYddddS#1swxYwYdS)Nrzhttps://localhostz/nonexistent/path)cafilecontext)
sslcreate_default_contextrr$r%rrrrr")r-rs  rtest_cafile_and_contextz)urlopen_HttpTests.test_cafile_and_contextXs,..

+R1C,D
E
E		"":..

&&'0CW'














																		s5B
#A9-B9A=	=BA=	BBBN)"rBrCrDrr
r
runittest
skipUnlessrr&r.r0r2r5r7r:r>rCrHrJrRr_rcrerrqrrrlrorzr~rr&rrrrWs#88			X344""54"4X344542X344""54" X34454   
       """,,,!!!,,,,,,U\&.-3343			&'''X34454rrcHeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdS)urlopen_DataTestsz"Test urlopen() opening a data URL.c|tjjd|_d|_d|_d|_d|_tj	|j|_
tj	|j|_tj	|j|_dS)Nutest data URLs :;,%=& ö Ä sUPNG


IHDR{@sRGBIDATc```?
o/IENDB`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%3Dzdata:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAIAAAB7
QOjdAAAAAXNSR0IArs4c6QAAAA9JREFUCNdj%0AYGBg%2BP//PwAGAQL%2BCm8 vHgAAAABJRU5ErkJggg%3D%3D%0A%20)
addCleanuprr
urlcleanuprimagetext_urltext_url_base64	image_urlr"
text_url_resptext_url_base64_respimage_url_resprAs rrzurlopen_DataTests.setUpes1222;	
F	

(	


	

.	

$^33DMBB$*N$:$: %"%"!$n44T^DDrchdD].}|t|j|d|z/dS)N)r:r=rr@rrrrr)rrrrs  rrz urlopen_DataTests.test_interfacesSG		DOOGD$6==J



		rcV||jtjj||jddg||j	dtt|j|tjdddgdS)N)z
text/plainr)charsetz
ISO-8859-1zcontent-lengthzdata:,)rzUS-ASCII)rrrrrrrr
get_paramsrstrrrrrr"rAs rrzurlopen_DataTests.test_infosd055779NOOO27799DDFF
!:;	=	=	=,11334DEDJ  	"	"	"//99>>@@KKMM
!89	;	;	;	;	;rc2||j|j||j|j||j|jdSr+)rrrrrrrrrAs rrzurlopen_DataTests.test_geturls+2244dmDDD299;; 	"	"	",3355t~FFFFFrc||jt	|jd|jdSNr)rrr:rtdictrrrrAs rtest_read_textz urlopen_DataTests.test_read_texts|+002299#((**557788CEEFJi	Q	Q	Q	Q	Qrc||jt	|jd|jdSr)rrr:rtrrrrrAs rtest_read_text_base64z'urlopen_DataTests.test_read_text_base64sw27799@@*//11<<>>??	JLLI					rcj||j|jdSr+)rrr:rrAs rtest_read_imagez!urlopen_DataTests.test_read_images/,1133TZ@@@@@rc\|ttjjddS)Nzdata:text/plainrrrrr"rAs rtest_missing_commaz$urlopen_DataTests.test_missing_commas&*V^%;<MNNNNNrc\|ttjjddS)Nzdata:;base64,Cg=rrAs rtest_invalid_base64_dataz*urlopen_DataTests.test_invalid_base64_datas&*V^%;<NOOOOOrN)
rBrCrDrrrrrrrrrrr&rrrrbs,,EEE>;;;GGGQQQ
AAAOOOPPPPPrrcVeZdZdZdZdZdZddZdZdZ	d	Z
d
ZdZdZ
d
ZdS)urlretrieve_FileTestsz(Test urllib.urlretrieve() on local filesc|tjjg|_|tjd|_	ttjd}|
|j||dS#YdSxYw#|w#YwxYwxYw)Nstesting urllib.urlretriever{)rrrr	tempFilesregisterFileForCleanUprrrrrr@)r-FILEs  rrzurlretrieve_FileTests.setUps1222	
##I$45551			($//DJJty!!!JJLLLDDDDDs1AB9B11B69C:CCCCcP|jD]}tj|#YxYwdSr+)rrr)r-eachs  rrzurlretrieve_FileTests.tearDowns7N		D4DD		s#ctj|}	|dn"#t$rtjdwxYwdtj	|zS)Nzutf-8z!filePath is not encodable to utf8z	file://%s)
rrWabspathrsUnicodeEncodeErrorrSkipTestrrr	)r-filePaths  rconstructLocalFileUrlz+urlretrieve_FileTests.constructLocalFileUrls|7??8,,	IOOG$$$$!	I	I	I#$GHHH	IV^88BBBBs	7ArcRtj\}}	||tj|d}||||n'#Yn#xYw#|w#YwxYwxYw|S)zCreates 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.r{)rUrVrrfdopenrr@)r-r newFdnewFilePathnewFiles     rcreateNewTempFilez'urlretrieve_FileTests.createNewTempFiles
&-//{	''444it,,GMM$MMOOODDDDs0AB+BBB$BB$B!B$c:|j|dSr+)rappend)r-fileNames  rrz,urlretrieve_FileTests.registerFileForCleanUpsh'''''rctjdtjz}||dtj||dtjj	ddS)Nr|rr
zFdid not get an email.message.Message instance as second returned value)
rrurlretrieverrrrrrr)r-results  r
test_basicz urlretrieve_FileTests.test_basicsr++I	8H,HIII$4555fQi)>9	:	:	:	:	:rcdtjz}||tj|tj|}|||d|tj
|dt|d}	|
}||n'#Yn#xYw#|w#YwxYwxYw||j|dS)N%s.2rzcopy of the file was not maderb)rrrrrrrrrrrWrYrr:r@r)r-second_temprrrs     r	test_copyzurlretrieve_FileTests.test_copys y//##K000++D,F,F--*,,fQi000{3369	:	:	:K&&	99;;DJJLLLDDDDD)))))s0(D*C??DD#DD#D D#cdgffd	}dtjz}|tjtj||dS)Nrc|t|t|t||d|ddz|d<dS)Nrr
)rrr)block_countblock_read_size	file_sizecount_holderr-s    r
hooktesterz9urlretrieve_FileTests.test_reporthook.<locals>.hooktestersu!!+s333!!/3777!!)S111[,q/:::*1o1LOOOrr)rrrrrrr)r-rrs`  rtest_reporthookz%urlretrieve_FileTests.test_reporthooksNOS	2	2	2	2	2	2y//##K000""&&y'788	%	%	%	%	%rcBg}|fd}|}tj||t
j||t|d||ddddS)Nc6||||fdSr+rrrr_reports    rrzAurlretrieve_FileTests.test_reporthook_0_bytes.<locals>.hooktester!NNK)DEEEEErr
rr	rrrrrrrrrr-reportrsrcFileNames    rtest_reporthook_0_bytesz-urlretrieve_FileTests.test_reporthook_0_bytessHN	F	F	F	F,,..""4#=#=k#J#Jj	*	*	*Va(((1q)))))rcg}|fd}|d}tj||t
j||t|d||ddd||ddddS)Nc6||||fdSr+rrs    rrzAurlretrieve_FileTests.test_reporthook_5_bytes.<locals>.hooktester$rrsxxxxxrrr
rrs    rtest_reporthook_5_bytesz-urlretrieve_FileTests.test_reporthook_5_bytessHN	F	F	F	F,,X66""4#=#=k#J#Jj	*	*	*Va(((1q)))1q)))))rcg}|fd}|ddz}tj||t
j||t|d||ddd||ddd||ddd||ddddS)	Nc6||||fdSr+rrs    rrzDurlretrieve_FileTests.test_reporthook_8193_bytes.<locals>.hooktester2rrxi rrr
i rrs    rtest_reporthook_8193_bytesz0urlretrieve_FileTests.test_reporthook_8193_bytes-sHN	F	F	F	F,,TD[99""4#=#=k#J#Jj	*	*	*Va(((1t,,,1t,,,1t,,,1t,,,,,rN)r)rBrCrDrrrrrrrrrrrrr&rrrrs220CCC (((:::***$%%%	*	*	****-----rrceZdZdZdZdZdS)urlretrieve_HttpTestsz5Test urllib.urlretrieve() using fake http connectionsc|tjj|dd}|tjj5	tjtj
||n#|wxYw	ddddS#1swxYwYdS)NHTTP/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
cdSr+r&)par1par2par3s   r_reporthookzYurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError.<locals>._reporthookNsDr)
reporthookrrrrrTrr@ContentTooShortErrorrr
TEST_HTTP_URLr\)r-rs  r.test_short_content_raises_ContentTooShortErrorzDurlretrieve_HttpTests.test_short_content_raises_ContentTooShortErrorAs1222

						

v|@
A
A	"	"
"**7+@6A+CCC!!!!!!!!!	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"s*!C
#+B#C
#B99C

CCc|tjj|d|tjj5	tjtj
|n#|wxYw	ddddS#1swxYwYdS)NrrrAs rAtest_short_content_raises_ContentTooShortError_without_reporthookzWurlretrieve_HttpTests.test_short_content_raises_ContentTooShortError_without_reporthookXs1222

			

v|@
A
A	"	"
"**7+@AAA!!!!!!!!!		"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"	"s*C )B	CB44CC	C	N)rBrCrDrrrr&rrrr>s8??"""."""""rrcHeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
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

    c$dgd}tj|}|||d|d|tj|}|||d|d|dS)Nr)ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
0123456789z_.-~using quote():  != using quote_plus(): )joinrrrr
quote_plus)r-do_not_quoters   rtest_never_quotezQuotingTests.test_never_quotesxx!)!)!)**##L11vv6BllFFK	M	M	M((66vv:F,,O	Q	Q	Q	Q	Qrcf|tjjjdddS)Nrr)rrrr__defaults__rAs rtest_default_safezQuotingTests.test_default_safes++8;SAAAAArcd}tj||}|||d|d|tj||}|||d|d|tj|d}|||d|d|tjddd	
}tjddd
}|||d|d|tjddd
}tjddd
}|||d|d|dS)
Nz<>saferrrs<>uaüblatin-1ü)encodingrr)rrrrr)r-quote_by_defaultrexpects    r	test_safezQuotingTests.test_safes##$4;K#LL)666F6F6FO	Q	Q	Q(()9.>)@@)66***FF4	5	5	5##$45#AA)666F6F6FO	Q	Q	Q##Hyv#NN##Hyr#JJ &&&&*	+	+	+##Hyw#OO##Hyr#JJ &&&&*	+	+	+	+	+rc8dtdD}|d|tdd|}|D]}tj|}|t||d|dt|d|tj	|}|t||d	|d
t|d|~d}d}tj|}|||d|d
|tj	|}|||d	|d
|dS)Nc,g|]}t|Sr&)r).0nums  r
<listcomp>z5QuotingTests.test_default_quoting.<locals>.<listcomp>s666SC666r z
<>#%"{}|\^[]`rrrz should be escaped to z, not rz should be escapes to zab[]cdz
ab%5B%5Dcdr)
rrrrrrrrrr)r-should_quoterr
partial_quoteexpecteds      rtest_default_quotingz!QuotingTests.test_default_quotings76E"II666,---CHH%%%ww|,, 
	>
	>D\''--FYt__ff#ddIdOOOOVV=
>
>
>\,,T22FYt__ff#ddIdOOOOVV=
>
>
>
>
 
##M22666>hhG	I	I	I((7766;C88VVL	N	N	N	N	Nrc
tjd}||t	dd|dt	dtjd}||dd|zd}|dt	d}tj|}|||d|d||dd}tj|}|||d|d|dS)Nr+rr+zusing quote_plus(): %r != +z
a b cd e fr)rrrrrrr )r-rgivenr
s    rtest_quoting_spacezQuotingTests.test_quoting_spacesU##C((36<ffinnnM	O	O	O((--6?	A	A	AsIcNN33##E**6<ffffE	G	G	GsC((((//;A6666J	L	L	L	L	Lrc|tjdd|tjddd|tjdd|tjddddS)Nzalpha+beta gammazalpha%2Bbeta+gammarzalpha+beta+gammasalpha+beta gamma+)rrrrrAs rtest_quoting_pluszQuotingTests.test_quoting_pluss001CDD-	/	/	/001CSII+	-	-	-	
001DEE-	/	/	/	
001CTJJ+	-	-	-	-	-rcXd}d}tj|}|||d|d||t
tjj|dtj|}|||d|d|dS)Nab%A2%D8ab%FFrrrrzusing quote_from_bytes(): )rrrrr	TypeErrorquote_from_bytesr-rr
rs    rtest_quote_byteszQuotingTests.test_quote_bytess!##E**6<ffffE	G	G	G	
)V\%7%.		0	0	0..u55"FFFF,	-	-	-	-	-rcrd}d}tj|}|||d|d|tj|dd}|||d|d|d}d}tj|d}|||d|d|d	}d
}tj|}|||d|d|d	}|t
tjj|dd	}d}tj|dd}|||d|d|d	}d
}tj|dd}|||d|d|dS)Nu¢Øabÿz%C2%A2%C3%98ab%C3%BFrrrerrorsrrr 漢字%E6%BC%A2%E5%AD%97z%3F%3Fr z%26%2328450%3B%26%2323383%3Bxmlcharrefreplace)rrrrrrr#s    rtest_quote_with_unicodez$QuotingTests.test_quote_with_unicodes? '##E**6<ffffE	G	G	G##ED#FF6<ffffE	G	G	G!##EI#>>6<ffffE	G	G	G%##E**6<ffffE	G	G	G,fl.@%-6		8	8	8##EI+4$666<ffffE	G	G	G/##EI+>$@@6<ffffE	G	G	G	G	Grcd}d}tj|d}|||d|d|d}d}tj|dd	
}|||d|d|dS)Nu¢Ø ÿz
%A2%D8+%FFrr rruab漢字 cdzab%3F%3F+cdr r&)rrrrr#s    rtest_quote_plus_with_unicodez)QuotingTests.test_quote_plus_with_unicode(s(((CC;A6666J	L	L	L$((09);;;A6666J	L	L	L	L	LrN)
rBrCrDrrrrrrrr$r+r-r&rrrrks2QQQBBB+++:NNN8LLL&
-
-
---- (G(G(GT
L
L
L
L
LrrcBeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
S)UnquotingTestszwTests for unquote() and unquote_plus()

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

    c	*g}tdD]}tt|}t|}tj|}|||d|d|tj|}|||d|d|||d	|}~tj|}||
ddd|z|ttftjjd|ttftjjd	dS)
Nusing unquote(): rusing unquote_plus(): rrr
z/using unquote(): not all characters escaped: %sr&)rrrrrunquoterunquote_plusrrcountrr!AttributeError)r-escape_listrrr
r
escape_strings       rtest_unquotingzUnquotingTests.test_unquoting?s::
	&
	&Cc#hh''EXXF\))%00FVVV<BFFFFK
M
M
M\..u55FVVV$ffff.
/
/
/
u%%%%,,
%%m44c**A &'	(	(	(	
9n5v|7KTRRR9n5v|7KRPPPPPrc"d}|}tj|}|||d|d|d}|}tj|}|||d|d|d}|}tj|}|||d|d|d}t	|d}tj|}|||d|d|d}t	|d}tj|}|||d|d|d}t	|d}tj|}|||d|d||ttftjjd|ttftjjddS)	Nz%xabr2rz%xrrzusing unquote_to_bytes(): r&)	rrr4rr}unquote_to_bytesrr!r7r#s    rtest_unquoting_badpercentz(UnquotingTests.test_unquoting_badpercentVs<%%e,,"FFFF*,	-	-	-%%e,,"FFFF*,	-	-	-%%e,,"FFFF*,	-	-	-ug&&..u55"FFFF*,	-	-	-ug&&..u55"FFFF*,	-	-	-ug&&..u55"FFFF*,	-	-	-9n5v|7TVZ[[[9n5v|7TVXYYYYYrcd}d}tj|}|||d|d|dS)Nz%Ab%eAsr<rrrr=rr#s    rtest_unquoting_mixed_casez(UnquotingTests.test_unquoting_mixed_casezsY..u55"FFFF,	-	-	-	-	-rcdtdz}d}tj|}|||d|d|tj|}|||d|d|dS)Nzab%sdcabcdrrr3)rrrr4rr5r#s    rtest_unquoting_partsz#UnquotingTests.test_unquoting_partss)C..(%%e,,6<ffffE	G	G	G**511=CVVVVL	N	N	N	N	Nrc*d}|}tj|}|||d|d||dd}tj|}|||d|d|dS)Nzare+there+spaces...r2rrr+r3)rrr4rr r5r#s    rtest_unquoting_plusz"UnquotingTests.test_unquoting_pluss%%%e,,8>G	I	I	IsC((**511=CVVVVL	N	N	N	N	Nrcd}d}tj|}|||d|d|tjd}d}|||d|d|d}d}tj|}|||d|d|d	}d}tj|}|||d|d|dS)
N"br%C3%BCckner_sapporo_20050930.docsbrückner_sapporo_20050930.docr<r	漢%C3%BCs漢üs%A2%D8ab%FFrs	%A2ab%FFr@r#s    rtest_unquote_to_bytesz$UnquotingTests.test_unquote_to_bytessA48..u55"FFFF,	-	-	-..~>>("FFFF,	-	-	-"..u55"FFFF,	-	-	-
 "..u55"FFFF,	-	-	-	-	-rcd}d}tj|}|||d|d|tj|dd}|||d|d|tjdd}d}|||d|d|d	}d
}tj|}|||d|d|d}d}tj|}|||d|d|tj|d
}|||d|d|d}d}tj|d}|||d|d|tjd}d}|||d|d|tjdd}d}|||d|d|dS)NrIubrückner_sapporo_20050930.docr2rr&zbr%FCckner_sapporo_20050930.docrr r)r(z%F3%B1u�r )r'rignorerJu漢üu漢%FCrrr4rr#s    rtest_unquote_with_unicodez(UnquotingTests.test_unquote_with_unicodes45%%e,,8>G	I	I	I%%ed4%HH8>G	I	I	I%%&G/8&::58>G	I	I	I%%%e,,8>G	I	I	I%%e,,8>G	I	I	I%%eI%>>8>G	I	I	I%%eH%==8>G	I	I	I%%n558>G	I	I	I
%%kI%FF8>G	I	I	I	I	Ircd}d}tj|}|||d|d|d}d}tj|}|||d|d|d}d}tj|}|||d|d|dS)	Nsblueberryjamblueberryjamr2rsblåbærsyltetøyublåbærsyltetøysbl%c3%a5b%c3%a6rsyltet%c3%b8jublåbærsyltetøjrNr#s    rtest_unquoting_with_bytes_inputz.UnquotingTests.test_unquoting_with_bytes_inputs%%e,,8>G	I	I	I70%%e,,8>G	I	I	I10%%e,,8>G	I	I	I	I	IrN)rBrCrDrr:r>rArErGrKrOrRr&rrr/r/8sQQQ."Z"Z"ZH---
N
N
N
N
N
N--->8I8I8ItIIIIIrr/cZeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdS)urlencode_TestszTests for urlencode()cjgd}tj|}|D]"}|||d|d|d|#||ddd|d|d|d}||dz
}||dz}||o|d|d	||t|d
d|dt|dd
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 z: z not found in &rz: expected 2 '&'s; got r
z%: '&' not located in proper place in z#: unexpected number of characters: rN)
rr	urlencoderurr6indexrisdigitr)	r-r	test_typeexpect_somewhererramp_locationon_amp_lefton_amp_rights	         rhelp_inputtypezurlencode_Tests.help_inputtypes~766''..(	8	8HMM(FF#))XXXvv7
8
8
8
8	
c**AA#))V\\#%6%6%68	9	9	9||C((\A-.lQ./++--H,2F2F2H2Hii)	*	*	*	
Vkk$))S[[[[++?	@	@	@	@	@rc:|ddddddS)N123)1st2nd3rdzusing dict as input typer`rAs rtest_using_mappingz"urlencode_Tests.test_using_mapping.s33c==6	8	8	8	8	8rc6|gdddS)N))rerb)rfrc)rgrdz*using sequence of two-item tuples as inputrhrAs rtest_using_sequencez#urlencode_Tests.test_using_sequence3s5FFFH	J	J	J	J	Jrc0ddi}tddtd}tj|}|||ddi}d}tj|}|||dS)NrV=zkey namezA bunch of pluseszkey+name=A+bunch+of+pluses)rrrrXrr#s    rtest_quotingzurlencode_Tests.test_quoting8sS	%cNNNNIcNNN;''..(((/0-''..(((((rcdgdi}dtjtgdz}tj|}|||tj|d}|dD]}d|z}|||||ddd|dzdS)Nsequence)rbrcrdzsequence=%sTrVrzExpected 2 '&'s, got %s)rrrrrXrrur6)r-rr
rvalues     r
test_doseqzurlencode_Tests.test_doseqCsOOO,!8!8___9M9M!N!NN''..(((''t44:&	*	*E"U*FMM&&))))c**A2V\\#5F5FF	H	H	H	H	Hrc|dtji|dtjgdSr|rrrrXrAs rtest_empty_sequencez#urlencode_Tests.test_empty_sequencePsTV\33B77888V\33B7788888rc|dtjddi|dtjddidS)Nza=1ar
za=NonertrAs rtest_nonstring_valuesz%urlencode_Tests.test_nonstring_valuesTs\ 6 6Qx @ @AAA6<#9#93+#F#FGGGGGrc~|dtjdddgid|dtjdddgidt	jddg}|d	tjd|iddS)
Nza=1&a=2rwr
rTz
a=None&a=a)rwr
)br
za=a&a=b)rrrrXrr)r-r s  rtest_nonstring_seq_valuesz)urlencode_Tests.test_nonstring_seq_valuesXsFL$:$:C!Q=$$O$OPPP//tSk0BDII	K	K	K&(';<<//dTBB	D	D	D	D	Drcfd}d}tj|dd}|||d}d}tj|}|||d}d}tj|d	}|||dS)
N) Á%3F=%3Frqr r&
%C2%A0=%C3%81%A0=%C1rr rrrXrr#s    rtest_urlencode_encodingz'urlencode_Tests.test_urlencode_encoding`s'''	'RR(((( ''..((((''	'BB(((((rcd}d}tj|ddd}|||d}d}tj|ddd	}|||d}d
}tj|d}|||d}d}tj|d}|||d}d
}tj|dd}|||d}d}tj|dd}|||dS)Nr}rTrqr )doseqrr'))r~)r
rz
%3F=1&%3F=%3Fr&r))r~)*rz%C2%A0=42&%C2%A0=%C3%81rrr z%A0=42&%A0=%C1rr#s    rtest_urlencode_encoding_doseqz-urlencode_Tests.test_urlencode_encoding_doseqss'''T18(LL(((- ''t18(LL(((( ''t44(((-*''t44((((''ti'HH(((-!''ti'HH(((((rcXd}d}tj|}|||tj|d}|||d}d}tj|d}|||dS)N)$$z
%A0%24=%C1%24T))r)rrz%A0%24=42&%A0%24=%C1%24rr#s    rtest_urlencode_bytesz$urlencode_Tests.test_urlencode_bytess- ''..(((''t44(((4*''t44(((((rcd}tj|d}d}|||d}tj|dd}d}|||d}d}tj|dd}|||d}tj|dd	
}d}|||d}d}tj|ddd	}d}d}tj|ddd	
}|||dS)Nrz:$rz	%A0$=%C1$T)rr))r)r
rz%A0$=%C1$&%A0$=13&%A0$=42r)rr)rrrr)r-rrr
s    r&test_urlencode_encoding_safe_parameterz6urlencode_Tests.test_urlencode_encoding_safe_parametersy
.''D'99(((-''T'EE(((9,''t$'??(((.''D1:(<<(((-''T1:(<<9,''t$1:(<<(((((rN)rBrCrDrr`rirkrnrrrurxr{rrrrr&rrrTrTs@@@@888
JJJ
	)	)	)HHH999HHHDDD)))&#)#)#)J)))&)&)&)&)&)rrTceZdZdZdZdZejej	dkddZ
ejej	dkddZd	S)
Pathname_Testsz&Test pathname2url() and url2pathname()c>tjdddd}d}tj|}|||d|d|tj|}|||d|d|dS)	NpartsofrwrWzparts/of/a/pathpathname2url() failed; rzurl2pathame() failed; )rrWrrrr	rr)r-
expected_pathexpected_urlrs    rrzPathname_Tests.test_basicsWdC@@
(,,];;vv &&,,0	1	1	1,,\:: &&--1	2	2	2	2	2rc8tjddd}dtjdz}tj|}|||d|d||}tj	|}|||d|d|tjdd	}d
tjdz}tj|}|||d|d|d}tjdd
}tj	|}|||d|d|dS)Nneedszquot=ingherez
needs/%s/hererrzurl2pathname() failed; z	make sureusing_quotez%s/using_quotezmake+sure/using_unquotez	make+sure
using_unquote)
rrWrrrrrr	rrr#s    rrnzPathname_Tests.test_quotingsWj&99 6<#5#5j#A#AA,,U33 &&&&*	+	+	+,,V44 &&&&*	+	+	+[-88!FL$6$6{$C$CC,,U33 &&&&*	+	+	+*k?;;,,U33 &&&&*	+	+	+	+	+rwin32z*test specific to the nturl2path functions.cd}d}tj|}|||d|d|d}d}tj|}|||d|d|dS)Nz
\\?\C:\dirz	///C:/dirrrz\\?\unc\server\share\dirz/server/share/dir)rrr	rr#s    r
test_prefixeszPathname_Tests.test_prefixess!,,U33 &&&&*	+	+	+1$,,U33 &&&&*	+	+	+	+	+rz.test specific to the urllib.url2path function.c	d}d}|D]>}tj|}|||d|d|?d}d}tj|}|||d|d|dS)N)z/C:/z///C:/z/C|//C:\z'urllib.request..url2pathname() failed; rz
///C|/pathzC:\pathz&urllib.request.url2pathname() failed; )rrrr)r-rr
rrs     rtest_ntpathzPathname_Tests.test_ntpaths,	/	/C^0055FVVV$ffff.
/
/
/
/,,U33 &&&&*	+	+	+	+	+rN)rBrCrDrrrnrrsysplatformrrr&rrrrs00222+++6X0EGG
+
+GG
+ X0IKK
+
+KK
+
+
+rrceZdZdZdZdS)
Utility_Testsz=Testcase to test the various utility functions in the urllib.ct|tjtdS)zATest the urllib.request.thishost utility function returns a tupleN)rrrthishosttuplerAs r
test_thishostzUtility_Tests.test_thishosts,fn5577?????rN)rBrCrDrrr&rrrrs.GG@@@@@rrceZdZdZdZejedZejedZ	ejedZ
dS)URLopener_Testsz4Testcase to test the open method of URLopener class.clGddtjj}tjdt
f5||dd||ddddddS#1swxYwYdS)NceZdZdZdS)8URLopener_Tests.test_quoted_open.<locals>.DummyURLopenerc|Sr+r&r-rs  r	open_spamzBURLopener_Tests.test_quoted_open.<locals>.DummyURLopener.open_spam)
rN)rBrCrDrr&rrDummyURLopenerr(#




rrz8DummyURLopener style of invoking requests is deprecated.zspam://example/ /z//example/%20/z,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/z'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/)rrr}rr$r%rr)r-rs  rtest_quoted_openz URLopener_Tests.test_quoted_open's+					V^5			
+K"$%%		;		;
^^--22#%%%5
7
7
7
^^--22>@@9
;
;
;		;		;		;		;		;		;		;		;		;		;		;		;		;		;		;		;		;		;sA#B))B-0B-)categoryctj5}tj|\}}t	j|dtj|z}tj	
|\}}|tj
|tj
|ddddS#1swxYwYdS)N)dirzfile:)rtemp_dirrUrVrr@rrr	r}retrieverrWnormcase)r-tmpdirr[tmpfilefileurlrN_s       rtest_urlopener_retrieve_filez,URLopener_Tests.test_urlopener_retrieve_file6s


!
!	TV"*v666KBHRLLL ; ;G D DDG .2244==gFFKHaRW--h779I9I'9R9RSSS
	T	T	T	T	T	T	T	T	T	T	T	T	T	T	T	T	T	TsCC44C8;C8cBd}|d||jtj|\}}|tj	
|dddS)Nzhttp://www.python.org/file.txtrr
z.txt)rTrr\rrr}rrrrWsplitext)r-rrNrs    rtest_urlopener_retrieve_remotez.URLopener_Tests.test_urlopener_retrieve_remote@s.

6777(((n..0099#>>!))(33A6?????rc8Gddtjj}dD]}|ttjj||ttjj||ttjj||t|j||t|j|dS)NceZdZdZdS)<URLopener_Tests.test_local_file_open.<locals>.DummyURLopenerc|Sr+r&rs  ropen_local_filezLURLopener_Tests.test_local_file_open.<locals>.DummyURLopener.open_local_fileLrrN)rBrCrDrr&rrrrKrrr)zlocal_file://examplezlocal-file://example)rrr}rr=r"rr)r-rrs   rtest_local_file_openz$URLopener_Tests.test_local_file_openHs						V^5			D	G	GCgv~'=sCCCgv~'?'?'A'A'FLLLgv~'?'?'A'A'JCPPPg~~'7'7'<cBBBg~~'7'7'@#FFFF	G	GrN)rBrCrDrrrignore_warningsr%rrrr&rrrr$s>>
;
;
;%_$.@AAATTBAT%_$.@AAA@@BA@%_$.@AAA
G
GBA
G
G
GrrceZdZdZdZdZdS)RequestTestsz&Unit tests for urllib.request.Request.ctjj}|d}||d|di}||ddS)NrrPOST)rrRequestr
get_methodr-rrs   rtest_default_valuesz RequestTests.test_default_valuesYsx.('122++--u555'1266++--v66666rc2tjj}|dd}||jd||d|did}||jd||d|dd}||dd|_||ddS)NrHEAD)methodr)rrrrrrrs   rtest_with_method_argz!RequestTests.test_with_method_arg`s.('1&AAA000++--v666'12fEEE000++--v666'1%@@@++--u555++--v66666rN)rBrCrDrrrr&rrrrVs80077777777rrc,eZdZdZdZdZdZdZdS)URL2PathNameTestsc|tdd|tdd|tdddS)Nz///C|C:///C:z///C|/rrrrAs rtest_converting_drive_letterz.URL2PathNameTests.test_converting_drive_letterpsbg..555g..555h//88888rc|tdd|tdddS)Nz
///C/test/z
\\\C\test\z////C/test/z	\\C\test\rrAs r$test_converting_when_no_drive_letterz6URL2PathNameTests.test_converting_when_no_drive_letterusFl335FGGGm446FGGGGGrcL|tdddS)Nz///C|/foo/bar/spam.fooC:\foo\bar\spam.foorrAs rtest_simple_comparez%URL2PathNameTests.test_simple_comparezs2&>??/	1	1	1	1	1rcH|ttddS)Nu///è|/)rIOErrorrrAs rtest_non_ascii_drive_letterz-URL2PathNameTests.test_non_ascii_drive_letter~s '<?????rcxgd}|D]2}|tt||3dS)N)rz\\\C\test\\r)rrr	r-
list_of_pathsrWs   rtest_roundtrip_url2pathnamez-URL2PathNameTests.test_roundtrip_url2pathnames[
"	E	ED\,t*<*<==tDDDD	E	ErN)rBrCrDrrrrrr&rrrrnsj999
HHH
111@@@EEEEErrc,eZdZdZdZdZdZdZdS)PathName2URLTestsc|tdd|tdddS)Nrrrrr	rAs rrz.PathName2URLTests.test_converting_drive_lettersDd++W555f--w77777rc|tdd|tdd|tdddS)Nz\\\folder\test\/////folder/test/z\\folder\test\z////folder/test/z
\folder\test\z
/folder/test/rrAs rrz6PathName2URLTests.test_converting_when_no_drive_letters~&<==,	.	.	.&;<<+	-	-	-&:;;(	*	*	*	*	*rcL|tdddS)Nr///C:/foo/bar/spam.foorrAs rrz%PathName2URLTests.test_simple_compares2&<==1	4	4	4	4	4rcH|ttddS)NzXX:\)rrr	rAs rtest_long_drive_letterz(PathName2URLTests.test_long_drive_letters '<99999rcxgd}|D]2}|tt||3dS)N)rrr)rr	rrs   rtest_roundtrip_pathname2urlz-PathName2URLTests.test_roundtrip_pathname2urls[333
"	E	ED\,t*<*<==tDDDD	E	ErN)rBrCrDrrrrrr&rrrrsd888***444:::EEEEErr__main__)NNr]);rurllib.parserurllib.requesturllib.errorhttp.clientrQ
email.messagerr8r
unittest.mockrrjrtest.supportrrrrrImportErrorrrU
nturl2pathrr	base64r
rhas_gethostnamerrrr"rrTrqrVr_TestCaserxrrrrrrrr/rTrrrrrrrBmainr&rr<module>rsAA				""""""&&&&&&((((((				JJJJ
CCC



11111111$;
(
9
:
::

&
&
&
& ///,,,,^<<<<<F<<<;;;;;6;;;(ZRZRZRZRZR)ZRZRZRzD9D9D9D9D9"D9D9D9N!C!C!C!C!C 1!C!C!CHHHHHH)=,HHHVJPJPJPJPJP)JPJPJPZL-L-L-L-L-H-L-L-L-^*"*"*"*"*"H-}*"*"*"ZJLJLJLJLJL8$JLJLJLZPIPIPIPIPIX&PIPIPIfA)A)A)A)A)h'A)A)A)FL+L+L+L+L+X&L+L+L+\@@@@@H%@@@/G/G/G/G/GmX%6/G/G/Gd777778$7770EEEEE)EEE6EEEEE)EEE8zHMOOOOOsAAA