Uname: Linux web3.us.cloudlogin.co 5.10.226-xeon-hst #2 SMP Fri Sep 13 12:28:44 UTC 2024 x86_64
Software: Apache
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.210.96.117
Your Ip: 18.217.209.151
User: edustar (269686) | Group: tty (888)
Safe Mode: OFF
Disable Function:
NONE

name : test_urllib.pyo
�
@��cc@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
d�Zd�Zdefd��YZd	ejfd
��YZdejfd��YZd
ejfd��YZdejefd��YZdejfd��YZdejefd��YZdejfd��YZdejfd��YZdejfd��YZdejfd��YZdejfd��YZdejfd ��YZd!�Ze d"kre�ndS(#sRegression tests for urllibi����N(ttest_support(t	b64encodecCsCtt|��dj�}t|�dkr;d|}nd|S(s!Escape char as RFC 2396 specifiesiis0%st%(thextordtuppertlen(tcharthex_repr((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	hexescapes
csKdtjf�fd��Y�dtjf�fd��Y�|�_�S(Nt
FakeSocketcs8eZ�fd�Zd�Zdd�Zdd�ZRS(cs
|�_dS(N(tbuf(tselftdata(tFakeHTTPConnection(s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytsendallsc_s|S(N((Rtargstkwds((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytmakefilescSs |jr
dStjj||�S(Nt(tclosedtiotBytesIOtread(Rtamt((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR"s	cSs |jr
dStjj||�S(NR(RRRtreadline(Rtlength((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR's	N(t__name__t
__module__RRtNoneRR((R(s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR
s	RcseZdZ�fd�ZRS(Rcs%�|j�|_|j|j_dS(N(tfakedatatsockt	__class__tfakesock(R(R
(s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytconnect1s(RRRR"((R
(s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR,s(RRthttplibtHTTPConnectionR(R((RR
s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytfakehttps	t
FakeHTTPMixincBseZd�Zd�ZRS(cCst|�tj_dS(N(R%R#tHTTPt_connection_class(RR((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR%:scCstjtj_dS(N(R#R$R'R((R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
unfakehttp?s(RRR%R)(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR&9s	turlopen_FileTestscBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�ZRS(s�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.

    cCspd|jj|_ttjd�}z|j|j�Wd|j�Xtj|_t	j
d|j�|_dS(s'Setup of a temp file to use for testingstest_urllib: %s
twbNsfile:%s(R RttexttfileRtTESTFNtwritetclosetpathnameturllibturlopentreturned_obj(RtFILE((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytsetUpKscCs!|jj�tjtj�dS(sShut down the open objectN(R4R0tostremoveRR.(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttearDownVs
c	Cs5x.dD]&}|jt|j|�d
|�qWdS(NRRt	readlinestfilenoR0tinfotgeturltgetcodet__iter__s/object returned by urlopen() lacks %s attribute(	RRR:R;R0R<R=R>R?(t
assertTruethasattrR4(Rtattr((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_interface[s

cCs |j|j|jj��dS(N(tassertEqualR,R4R(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_readcscCs<|j|j|jj��|jd|jj�d�dS(NRsKcalling readline() after exhausting the file did not return an empty string(RDR,R4R(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
test_readlinefscCsF|jj�}|jt|�dd�|j|d|jd�dS(Nis.readlines() returned the wrong number of linesis"readlines() returned improper text(R4R:RDRR,(Rt
lines_list((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_readlinesls
cCsQ|jj�}|j|td�|jtj|t|j��|jd�dS(Nsfileno() did not return an intsTReading on the file descriptor returned by fileno() did not return the expected text(	R4R;tassertIsInstancetintRDR7RRR,(Rtfile_num((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_filenoss$cCs|jj�dS(N(R4R0(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
test_closezscCs |j|jj�tj�dS(N(RIR4R<t	mimetoolstMessage(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_infoscCs |j|jj�|j�dS(N(RDR4R=R1(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_geturl�scCs|j|jj�d�dS(N(RDR4R>R(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_getcode�scCs1x*|jj�D]}|j||j�qWdS(N(R4R?RDR,(Rtline((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_iter�scCs!|jttjd|j�dS(Ns./(tassertRaisest
ValueErrorR2R3R1(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_relativelocalfile�s(RRt__doc__R6R9RCRERFRHRLRMRPRQRRRTRW(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR*Cs												t
ProxyTestscBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCsRtj�|_x<tjj�D]+}d|j�kr|jj|�qqWdS(Ntproxy(RtEnvironmentVarGuardtenvR7tenvirontkeystlowertunset(Rtk((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR6�scCs|jj�|`dS(N(R\t__exit__(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR9�s
cCs�|jjdd�tj�}|jd|d�|jjdd�|jtjd��|jtjd��|jtjd��dS(NtNO_PROXYt	localhosttnos0localhost, anotherdomain.com, newdomain.com:1234sanotherdomain.comsanotherdomain.com:8888snewdomain.com:1234(R\tsetR2tgetproxies_environmentRDR@tproxy_bypass_environment(Rtproxies((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt+test_getproxies_environment_keep_no_proxies�scCs�zf|jjdd�tj�}|jd|d�|jjdd�tj�}|jd|�Wd|jjd�|jjd�XdS(Nt
HTTP_PROXYshttp://somewhere:3128thttptREQUEST_METHODtGET(R\RfR2RgRDtassertNotInR`(RRi((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_proxy_cgi_ignore�scCs�tj}|jjdd�|j|d��|j|d��|j|d��|j|d��|j|d��|j|d��|j|d	��|j|d
��|j|d��|j|d��dS(
NRcs8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tRdt	LocalHostt	LOCALHOSTsnewdomain.com:1234s	foo.d.o.tsanotherdomain.com:8888swww.newdomain.com:1234tprelocalhosts
newdomain.comsnewdomain.com:1235(R2RhR\RfR@tassertFalse(Rtbypass((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt(test_proxy_bypass_environment_host_match�s	(RRR6R9RjRpRv(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRY�s
				tProxyTests_withOrderedEnvcBs#eZd�Zd�Zd�ZRS(cCstj|_tj�t_dS(N(R7R]t
_saved_envtcollectionstOrderedDict(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR6�scCs|jt_dS(N(RxR7R](R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR9�scCsBdtjd<dtjd<|jtjd��|jtjd��dtjd<dtjd<tj�}|ji|�d	tjd<d
tjd<|jtjd��|jtjd��|jtjd��|jtjd
��|jtjd��dtjd<dtjd<tj�}|jd|d�dS(NRtno_proxyRdtNo_Proxyt	arbitraryt
http_proxyshttp://somewhere:3128Rks%localhost, noproxy.com, my.proxy:1234sxyz.comsnoproxy.com:5678s
my.proxy:1234smy.proxyshttp://somewhereelse:3128t
Http_ProxyRl(R7R]RtR2RhRgRDR@(RRi((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt,test_getproxies_environment_prefer_lowercase�s&







(RRR6R9R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRw�s		turlopen_HttpTestscBszeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
s.Test urlopen() opening a fake http connection.cCs�|jd�zktjd�}|j|j�d�|j|j�d�|j|j�d�|j|j�d�Wd|j�XdS(NsHello!shttp://python.org/Ri�(R%R2R3RDRR=R>R)(Rtfp((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRE�s
cCsNd}|jd�z)tj|�}|j|j�|�Wd|j�XdS(Ns-http://docs.python.org/library/urllib.html#OKsHello!(R%R2R3RDR=R)(RturlR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_url_fragment�s
cCs�x�tdd�tdd�D]d}t|�}d|}|jd�z-tjd|�}|j||j��Wd|j�XqWdS(Nii!iis//localhost:7777/test%s/sHTTP/1.1 200 OK

Hello.shttp:(trangetchrR%R2R3RoR=R)(Rtchar_noRtschemeless_urltresp((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt#test_url_with_control_char_rejecteds#

cCs�|jd�d}d|d}zYtjd|�}|jd|j��|jd|j��|jd|j��Wd|j�XdS(	NsHTTP/1.1 200 OK

Hello.s:localhost:7777?a=1 HTTP/1.1
X-injected: header
TEST: 123s//s:8080/test/?test=ashttp:t s
s
(R%R2R3RoR=R)(RthostR�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt/test_url_with_newline_header_injection_rejecteds
cCs9|jd�z|jttjd�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
shttp://python.org/(R%RUtIOErrorR2R3R)(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_read_boguss
cCsO|jd�z0d}|jt|��tjd�WdQXWd|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:README
Connection: close
Content-Type: text/html; charset=iso-8859-1
sRedirection to url 'file:shttp://python.org/(R%tassertRaisesRegexpR�R2R3R)(Rtmsg((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_invalid_redirect*scCsYxRttj�j�D];}|jd�z|jttjd�Wd|j�XqWdS(Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
shttp://something(	R�R2tFancyURLopenertmaxtriesR%RUR�R3R)(Rti((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_redirect_limit_independent:scCs9|jd�z|jttjd�Wd|j�XdS(NRshttp://something(R%RUR�R2R3R)(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_empty_socketHs
cCs�|jttjd�tj�\}}d|jtjj	d�}|j
tjj|��ztj|�}|j�Wdtj|�tj
|�X|jtjj|��|jttj|�dS(Ns"file://localhost/a/missing/file.pysfile://localhost/t/(RUR�R2R3ttempfiletmkstemptreplaceR7tpathtsepR@texistsR0tunlinkRt(Rtfdttmp_filettmp_fileurlR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_missing_localfileQs
cCs|jttjd�dS(Ns$ftp://localhost/not/existing/file.py(RUR�R2R3(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_ftp_nonexistingascCs�|jd�z�tjj}tjd�}dtd�}|j||j�|j	|j
�d�|j	|j
�d�|j	|j�d�|j	|j�d�Wd|j
�XdS(NsHello!shttp://user:pass@python.org/sAuthorization: Basic %s
s	user:passRi�(R%R#R'R(R2R3RtassertInRRDRR=R>R)(Rtfakehttp_wrapperR�t
authorization((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_userpass_inurlfs

cCs�|jd�z�d}tjj}dtd�}tj|�}|j||j�|j	|j
�d�|j	|j
�d�|j|j�|�|j	|j
�d�Wd|j�XdS(NsHello!shttp://a b:c d@python.org/sAuthorization: Basic %s
sa b:c dRi�(R%R#R'R(RR2R3R�RRDRtassertNotEqualR=R>R)(RR�R�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_userpass_with_spaces_inurlvs

(RRRXRER�R�R�R�R�R�R�R�R�R�R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��s		
		
	
							turlretrieve_FileTestscBsteZdZd�Zd�Zd�Zdd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
RS(
s(Test urllib.urlretrieve() on local filescCsrg|_|jtj�d|_z0ttjd�}|j|j�|j�Wdy|j�WnnXXdS(Nstesting urllib.urlretrieveR+(t	tempFilestregisterFileForCleanUpRR.R,R-R/R0(RR5((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR6�s		cCs3x,|jD]!}ytj|�Wq
q
Xq
WdS(N(R�R7R8(Rteach((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR9�s
cCsdtjtjj|��S(Ns	file://%s(R2tpathname2urlR7R�tabspath(RtfilePath((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytconstructLocalFileUrl�sRcCsltj�\}}z:|j|�tj|d�}|j|�|j�Wdy|j�WnnXX|S(s�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.R+N(R�R�R�R7tfdopenR/R0(RR
tnewFdtnewFilePathtnewFile((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytcreateNewTempFile�s

cCs|jj|�dS(N(R�tappend(RtfileName((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��scCsKtjdtj�}|j|dtj�|j|dtjd�dS(Nsfile:%siisAdid not get a mimetools.Message instance as second returned value(R2turlretrieveRR.RDRIRNRO(Rtresult((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
test_basic�scCs�dtj}|j|�tj|jtj�|�}|j||d�|jtj	j
|�d�t|d�}z|j�}|j
�Wdy|j
�WnnXX|j|j|�dS(Ns%s.2iscopy of the file was not madetrb(RR.R�R2R�R�RDR@R7R�R�R-RR0R,(Rtsecond_tempR�R5R,((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_copy�s

csRdg�fd�}dtj}�j|�tj�jtj�||�dS(NicsZ�j|t��j|t��j|t��j||d�|dd|d<dS(Nii(RIRJRD(tcountt
block_sizet
total_sizetcount_holder(R(s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
hooktester�s
s%s.2(RR.R�R2R�R�(RR�R�((Rs7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_reporthook�s


cCsog}|d�}|j�}tj|j|�tj|�|jt|�d�|j|ddd�dS(NcSs|j|||f�dS(N(R�(R�R�R�t_report((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��siii(R�R2R�R�RR.RDR(RtreportR�tsrcFileName((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_reporthook_0_bytes�s
cCs�g}|d�}|jd�}tj|j|�tj|�|jt|�d�|j|ddd�|j|ddd�dS(	NcSs|j|||f�dS(N(R�(R�R�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��stxiiiii txxxxx(R�R2R�R�RR.RDR(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_reporthook_5_bytes�s
cCs�g}|d�}|jdd�}tj|j|�tj|�|jt|�d�|j|ddd�|j|ddd�dS(	NcSs|j|||f�dS(N(R�(R�R�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR�sR�i iiii i(R�R2R�R�RR.RDR(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_reporthook_8193_bytes�s
(RRRXR6R9R�R�R�R�R�R�R�R�R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��s								
		turlretrieve_HttpTestscBs eZdZd�Zd�ZRS(s5Test urllib.urlretrieve() using fake http connectionscCsK|jd�d�}z#|jtjtjdd|�Wd|j�XdS(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(N((tpar1tpar2tpar3((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt_reporthooksshttp://example.comt
reporthook(R%RUR2tContentTooShortErrorR�R)(RR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt.test_short_content_raises_ContentTooShortErrors	cCs<|jd�z|jtjtjd�Wd|j�XdS(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
shttp://example.com/(R%RUR2R�R�R)(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytAtest_short_content_raises_ContentTooShortError_without_reporthook%s
(RRRXR�R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR�s	tQuotingTestscBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(swTests 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

    cCswdjddddg�}tj|�}|j||d||f�tj|�}|j||d||f�dS(NRtABCDEFGHIJKLMNOPQRSTUVWXYZtabcdefghijklmnopqrstuvwxyzt
0123456789s_.-susing quote(): %s != %ssusing quote_plus(): %s != %s(tjoinR2tquoteRDt
quote_plus(Rtdo_not_quoteR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_never_quoteNs	cCs|jtjjdd�dS(NiR�(RDR2R�t
func_defaults(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_default_safe[scCsnd}tj|d|�}|j||d||f�tj|d|�}|j||d||f�dS(Ns<>tsafesusing quote(): %s != %ssusing quote_plus(): %s != %s(R2R�RDR�(Rtquote_by_defaultR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_safe_scCs\gtd�D]}t|�^q
}|jd�|jtd��dj|�}x�|D]|}tj|�}|jt|�|d|t|�|f�tj|�}|jt|�|d|t|�|f�q[W~d}d}tj|�}|j||d	||f�tj|�}|j||d
||f�|j	t
tjd�dS(Ni s
<>#%"{}|\^[]`iRs1using quote(): %s should be escaped to %s, not %ss6using quote_plus(): %s should be escapes to %s, not %ssab[]cds
ab%5B%5Dcdsusing quote(): %s != %ssusing quote_plus(): %s != %s(R�R�R�R�R2R�RDR	R�RUt	TypeErrorR(Rtnumtshould_quoteRR�t
partial_quotetexpected((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_default_quotingjs.%

cCs�tjd�}|j|td�d|td�f�tjd�}|j|dd|�d}|jdtd��}tj|�}|j||d||f�|jdd�}tj|�}|j||d||f�dS(NR�susing quote(): %s != %st+susing quote_plus(): %s != +s
a b cd e fsusing quote_plus(): %s != %s(R2R�RDR	R�R�(RR�tgiventexpect((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_quoting_space�scCs9|jtjd�d�|jtjdd�d�dS(Nsalpha+beta gammasalpha%2Bbeta+gammaR�salpha+beta+gamma(RDR2R�(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_quoting_plus�s(	RRRXR�R�R�R�R�R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR�4s	
				tUnquotingTestscBsDeZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(swTests for unquote() and unquote_plus()

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

    cCsg}x�td�D]�}tt|��}t|�}tj|�}|j||d||f�tj|�}|j||d||f�|j|�qWdj|�}~tj|�}|j|j	d�dd|�tj|�}|j|j	d�dd|�dS(	Ni�susing unquote(): %s != %ssusing unquote_plus(): %s != %sRRis-using quote(): not all characters escaped; %ss/using unquote(): not all characters escaped: %s(
R�R	R�R2tunquoteRDtunquote_plusR�R�R�(Rtescape_listR�R�R�R�t
escape_string((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquoting�s,cCs�d}|}tj|�}|j||d||f�d}|}tj|�}|j||d||f�d}|}tj|�}|j||d||f�dS(Ns%xabsusing unquote(): %r != %rs%xR(R2R�RD(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquoting_badpercent�scCs<d}d}tj|�}|j||d||f�dS(Ns%Ab%eAs��susing unquote(): %r != %r(R2R�RD(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquoting_mixed_case�s
cCsrdtd�}d}tj|�}|j||d||f�tj|�}|j||d||f�dS(Nsab%sdtctabcdsusing quote(): %s != %ssusing unquote_plus(): %s != %s(R	R2R�RDR�(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquoting_parts�scCszd}|}tj|�}|j||d||f�|jdd�}tj|�}|j||d||f�dS(Nsare+there+spaces...susing unquote(): %s != %sR�R�susing unquote_plus(): %s != %s(R2R�RDR�R�(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquoting_plus�scCs#tjd�}|j|d�dS(Nu"br%C3%BCckner_sapporo_20050930.docu brückner_sapporo_20050930.doc(R2R�RD(Rtr((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unquote_with_unicode�s(	RRRXR�R�R�R�R�R�(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��s					turlencode_TestscBs;eZdZd�Zd�Zd�Zd�Zd�ZRS(sTests for urlencode()c	Csdddg}tj|�}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(sHelper 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.

        s1st=1s2nd=2s3rd=3stesting %s: %s not found in %st&is#testing %s: expected 2 '&'s; got %sis1testing %s: '&' not located in proper place in %siis5testing %s: unexpected number of characters: %s != %sNiiii(	R2t	urlencodeR�RDR�tindexR@tisdigitR(	RR�t	test_typetexpect_somewhereR�R�tamp_locationton_amp_leftton_amp_right((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pythelp_inputtype�s$
cCs)|jidd6dd6dd6d�dS(Nt1t1stt2t2ndt3t3rdsusing dict as input type(R(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_using_mappingscCs|jdd	d
gd�dS(NR
R	RRRR
s*using sequence of two-item tuples as input(R
R	(RR(RR
(R(R((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_using_sequencescCs~idd6}dtd�td�f}tj|�}|j||�idd6}d}tj|�}|j||�dS(Nt=R�s%s=%ssA bunch of plusesskey nameskey+name=A+bunch+of+pluses(R	R2RRD(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_quoting"s

cCs�idddgd6}dtjtdddg��}tj|�}|j||�tj|t�}x,|dD] }d|}|j||�qtW|j|jd�dd|jd��dS(	NR	RR
tsequencessequence=%sR�isExpected 2 '&'s, got %s(R2R�tstrRRDtTrueR�R�(RR�R�R�tvalue((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
test_doseq-s"
(RRRXRRRRR(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR��s	 			tPathname_TestscBsDeZdZd�Zd�Zejejdkd�d��Z	RS(s&Test pathname2url() and url2pathname()cCs}tjjdddd�}d}tj|�}|j||d||f�tj|�}|j||d||f�dS(NtpartstoftaR�sparts/of/a/pathspathname2url() failed; %s != %ssurl2pathame() failed; %s != %s(R7R�R�R2R�RDturl2pathname(Rt
expected_pathtexpected_urlR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR�=scCs(tjjddd�}dtjd�}tj|�}|j||d||f�|}tj|�}|j||d||f�tjjdd�}d	tjd�}tj|�}|j||d||f�d
}tjjdd�}tj|�}|j||d||f�dS(
Ntneedssquot=ingtheres
needs/%s/herespathname2url() failed; %s != %ssurl2pathname() failed; %s != %ss	make suretusing_quotes%s/using_quotesmake+sure/using_unquotes	make+suret
using_unquote(R7R�R�R2R�R�RDR(RR�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRJs.twin32s'test specific to the nturl2path librarycCs�d}d}x:|D]2}tj|�}|j||d||f�qWd}d}tj|�}|j||d||f�dS(	Ns/C:/s///C:/s/C|//sC:\s*nturl2path.url2pathname() failed; %s != %ss
///C|/pathsC:\path(s/C:/s///C:/s/C|//(R2RRD(RR�R�R�R�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_ntpathes
(
RRRXR�Rtunittestt
skipUnlesstsystplatformR$(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR:s
	
	t
Utility_TestscBszeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�ZRS(
s=Testcase to test the various utility functions in the urllib.cCs{tj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS(Nstype:opaquestringttypetopaquestrings
:opaquestringstype:Rstype:opaque:strings
opaque:string(R*R+(NR+(Ns
:opaquestring(R*R(R*s
opaque:string(R2t	splittypeRDR(RR,((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splittypezs	cCs�tj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d�|j|d�d�dS( Ns%//www.example.org:80/foo/bar/baz.htmlswww.example.org:80s/foo/bar/baz.htmls//www.example.org:80Rs//127.0.0.1#@host.coms	127.0.0.1s/#@host.coms//127.0.0.1#@host.com:80s/#@host.com:80s//127.0.0.1:80#@host.coms127.0.0.1:80s///files/files//example.net/file;sexample.nets/file;s//example.net/file?s/file?s//example.net/file#s/file#(swww.example.org:80s/foo/bar/baz.html(swww.example.org:80R(Ns/foo/bar/baz.html(s	127.0.0.1s/#@host.com(s	127.0.0.1s/#@host.com:80(s127.0.0.1:80s/#@host.com(Rs/file(sexample.nets/file;(sexample.nets/file?(sexample.nets/file#(R2t	splithostRDR(RR.((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splithost�s*	cCs{tj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS(NsUser:Pass@www.python.org:080s	User:Passswww.python.org:080s@www.python.org:080Rs
User:Pass@s(User@example.com:Pass@www.python.org:080sUser@example.com:Pass(s	User:Passswww.python.org:080(Rswww.python.org:080(Nswww.python.org:080(s	User:PassR(sUser@example.com:Passswww.python.org:080(R2t	splituserRDR(RR0((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splituser�s	cCs+tj}|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d
�d�|j|d�d�|j|d�d �|j|d�d!�|j|d�d"�|j|d�d#�|j|d�d$�|j|d�d%�|j|d�d&�dS('Nsuser:abtusertabsuser:a
bsa
bsuser:a	bsa	bsuser:a
bsa
bsuser:absabsuser:absabsuser:a:bsa:bsuser:a bsa bs	user 2:absuser 2s
user+1:a+bsuser+1sa+bsuser:Rs:ab(R2R3(R2sa
b(R2sa	b(R2sa
b(R2sab(R2sab(R2sa:b(R2sa b(suser 2R3(suser+1sa+b(R2R(R2N(RR3(R2tsplitpasswdRDR(RR4((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitpasswd�s	cCs�tj}|j|d�d�|j|d�d�|j|d�d
�|j|d�d�|j|d�d�|j|d�d�|j|d�d�|j|d	�d�dS(Ns	parrot:88tparrott88sparrot:s	127.0.0.1s
parrot:cheeses[::1]:88s[::1]s:88R(R6R7(R6N(R6N(s	127.0.0.1N(s
parrot:cheeseN(s[::1]R7(s[::1]N(RR7(R2t	splitportRDR(RR8((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitport�s	cCs�tj}|j|d�d	�|j|d�d
�|j|dd�d�|j|d�d�|j|dd�d
�|j|d�d�|j|dd�d�|j|d�d�|j|dd�d�dS(Ns	parrot:88R6iXi����i7sparrot:s	127.0.0.1s
parrot:cheese(R6iX(R6i����(R6i7(R6i����(R6i7(s	127.0.0.1i����(s	127.0.0.1i7(R6N(R6N(R2t
splitnportRDR(RR:((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitnport�s	cCsetj}|j|d�d�|j|d�d�|j|d�d	�|j|d�d
�dS(Nshttp://python.org/fake?foo=barshttp://python.org/fakesfoo=barshttp://python.org/fake?foo=bar?Rs?foo=bar(shttp://python.org/fakesfoo=bar(shttp://python.org/fake?foo=barR(shttp://python.org/fakeN(Rsfoo=bar(R2t
splitqueryRDR(RR<((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitquery�s	cCs{tj}|j|d�d	�|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�dS(Nshttp://example.com?foo=bar#bazshttp://example.com?foo=bartbazshttp://example.com?foo=bar#Rs#bazs"http://example.com?foo=bar#baz#bootboo(shttp://example.com?foo=barR>(shttp://example.com?foo=barR(RR>(shttp://example.com?foo=barN(shttp://example.com?foo=bar#bazR?(R2tsplittagRDR(RR@((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt
test_splittag�s	cCs�tj}|j|d�dddgf�|j|d�ddgf�|j|d�dddgf�|j|d�dgf�dS(Ns/path;attr1=value1;attr2=value2s/pathsattr1=value1sattr2=value2s/path;Rs;attr1=value1;attr2=value2(R2t	splitattrRD(RRB((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitattr�s	cCs{tj}|j|d�d
�|j|d�d�|j|d�d�|j|d�d
�|j|d�d�dS(Nsfoo=bartfootbarsfoo=Rs=bartfoobarsfoo=bar=bazsbar=baz(RDRE(RDR(RRE(RFN(RDsbar=baz(R2t
splitvalueRDR(RRG((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_splitvalue�s	cCsBtjd�}|j|d�|jttjtjd��dS(Nuhttp://www.python.orgshttp://www.python.orgs#http://www.python.org/medi\u00e6val(R2ttoBytesRDRUtUnicodeErrorRtu(RR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_toBytesscCs#tjd�}|j|d�dS(Ns<URL:type://host/path>stype://host/path(R2tunwrapRD(RR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_unwraps(RRRXR-R/R1R5R9R;R=RARCRHRLRN(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyR)vs			
								
	tURLopener_TestscBs eZdZd�Zd�ZRS(s4Testcase to test the open method of URLopener class.cCsUdtjfd��Y}|j|�jd�d�|j|�jd�d�dS(NtDummyURLopenercBseZd�ZRS(cSs|S(N((RR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	open_spams(RRRQ(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRPssspam://example/ /s//example/%20/s,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/s'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/(R2t	URLopenerRDtopen(RRP((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_quoted_opens
cCs�dtjfd��Y}x�dD]�}|jttj|�|jttj�j|�|jttj�j|�|jt|�j|�|jt|�j|�q WdS(NRPcBseZd�ZRS(cSs|S(N((RR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pytopen_local_files(RRRU(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyRPsslocal_file://exampleslocal-file://example(slocal_file://exampleslocal-file://example(R2RRRUR�R3RStretrieve(RRPR�((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyttest_local_file_opens
(RRRXRTRW(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyROs	
cCsgddl}|j��I|jddt�tjtttt	t
ttt
tttt
t�
WdQXdS(Ni����tignores.*urllib\.urlopen.*Python 3.0(twarningstcatch_warningstfilterwarningstDeprecationWarningRtrun_unittestR*R�R�R�RYR�R�R�RR)RORw(RY((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt	test_mainws$
t__main__(!RXRyR2R#RR%R7R'RNR�ttestRtbase64RR	R%tobjectR&tTestCaseR*RYRwR�R�R�R�R�R�RR)ROR^R(((s7/usr/local/python-2.7/lib/python2.7/test/test_urllib.pyt<module>s:		 
P5$��&kVE<�l	
© 2025 GrazzMean