%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python2.7/test/
Upload File :
Create Path :
Current File : //usr/local/lib/python2.7/test/test_urllib.pyc


Nac@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
dZdZdefdYZd	ejfd
YZdejfdYZd
ejfdYZdejefdYZdejfdYZdejefdYZdejfdYZdejfdYZdejfdYZdejfdYZdejfdYZdejfd YZd!Ze d"krendS(#sRegression tests for urllibiN(ttest_support(t	b64encodecCsCtt|dj}t|dkr;d|}nd|S(s!Escape char as RFC 2396 specifiesiis0%st%(thextordtuppertlen(tcharthex_repr((s,/usr/local/lib/python2.7/test/test_urllib.pyt	hexescapes
csKdtjffdYdtjffdY|_S(Nt
FakeSocketcs8eZfdZdZddZddZRS(cs
|_dS(N(tbuf(tselftdata(tFakeHTTPConnection(s,/usr/local/lib/python2.7/test/test_urllib.pytsendallsc_s|S(N((Rtargstkwds((s,/usr/local/lib/python2.7/test/test_urllib.pytmakefilescSs |jr
dStjj||S(Nt(tclosedtiotBytesIOtread(Rtamt((s,/usr/local/lib/python2.7/test/test_urllib.pyR"s	cSs |jr
dStjj||S(NR(RRRtreadline(Rtlength((s,/usr/local/lib/python2.7/test/test_urllib.pyR's	N(t__name__t
__module__RRtNoneRR((R(s,/usr/local/lib/python2.7/test/test_urllib.pyR
s	RcseZdZfdZRS(Rcs%|j|_|j|j_dS(N(tfakedatatsockt	__class__tfakesock(R(R
(s,/usr/local/lib/python2.7/test/test_urllib.pytconnect1s(RRRR"((R
(s,/usr/local/lib/python2.7/test/test_urllib.pyR,s(RRthttplibtHTTPConnectionR(R((RR
s,/usr/local/lib/python2.7/test/test_urllib.pytfakehttps	t
FakeHTTPMixincBseZdZdZRS(cCs1tjjtjkstt|tj_dS(N(R#tHTTPt_connection_classR$tAssertionErrorR%(RR((s,/usr/local/lib/python2.7/test/test_urllib.pyR%:scCstjtj_dS(N(R#R$R'R((R((s,/usr/local/lib/python2.7/test/test_urllib.pyt
unfakehttp?s(RRR%R*(((s,/usr/local/lib/python2.7/test/test_urllib.pyR&9s	turlopen_FileTestscBseZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
ZRS(sTest 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|jWd|jXtj|_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((s,/usr/local/lib/python2.7/test/test_urllib.pytsetUpKscCs!|jjtjtjdS(sShut down the open objectN(R5R1tostremoveRR/(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttearDownVs
c	Cs5x.dD]&}|jt|j|d
|qWdS(NRRt	readlinestfilenoR1tinfotgeturltgetcodet__iter__s/object returned by urlopen() lacks %s attribute(	RRR;R<R1R=R>R?R@(t
assertTruethasattrR5(Rtattr((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_interface[s

cCs |j|j|jjdS(N(tassertEqualR-R5R(R((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_readcscCs<|j|j|jj|jd|jjddS(NRsKcalling readline() after exhausting the file did not return an empty string(RER-R5R(R((s,/usr/local/lib/python2.7/test/test_urllib.pyt
test_readlinefscCsF|jj}|jt|dd|j|d|jddS(Nis.readlines() returned the wrong number of linesis"readlines() returned improper text(R5R;RERR-(Rt
lines_list((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_readlinesls
cCsQ|jj}|j|td|jtj|t|j|jddS(Nsfileno() did not return an intsTReading on the file descriptor returned by fileno() did not return the expected text(	R5R<tassertIsInstancetintRER8RRR-(Rtfile_num((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_filenoss$cCs|jjdS(N(R5R1(R((s,/usr/local/lib/python2.7/test/test_urllib.pyt
test_closezscCs |j|jjtjdS(N(RJR5R=t	mimetoolstMessage(R((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_infoscCs |j|jj|jdS(N(RER5R>R2(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_geturlscCs|j|jjddS(N(RER5R?R(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_getcodescCs1x*|jjD]}|j||jqWdS(N(R5R@RER-(Rtline((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_iterscCs!|jttjd|jdS(Ns./(tassertRaisest
ValueErrorR3R4R2(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_relativelocalfiles(RRt__doc__R7R:RDRFRGRIRMRNRQRRRSRURX(((s,/usr/local/lib/python2.7/test/test_urllib.pyR+Cs												t
ProxyTestscBs5eZdZdZdZdZdZRS(cCsRtj|_x<tjjD]+}d|jkr|jj|qqWdS(Ntproxy(RtEnvironmentVarGuardtenvR8tenvirontkeystlowertunset(Rtk((s,/usr/local/lib/python2.7/test/test_urllib.pyR7scCs|jj|`dS(N(R]t__exit__(R((s,/usr/local/lib/python2.7/test/test_urllib.pyR:s
cCs|jjddtj}|jd|d|jjdd|jtjd|jtjd|jtjddS(NtNO_PROXYt	localhosttnos0localhost, anotherdomain.com, newdomain.com:1234sanotherdomain.comsanotherdomain.com:8888snewdomain.com:1234(R]tsetR3tgetproxies_environmentRERAtproxy_bypass_environment(Rtproxies((s,/usr/local/lib/python2.7/test/test_urllib.pyt+test_getproxies_environment_keep_no_proxiesscCszf|jjddtj}|jd|d|jjddtj}|jd|Wd|jjd|jjdXdS(Nt
HTTP_PROXYshttp://somewhere:3128thttptREQUEST_METHODtGET(R]RgR3RhREtassertNotInRa(RRj((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_proxy_cgi_ignorescCstj}|jjdd|j|d|j|d|j|d|j|d|j|d|j|d|j|d	|j|d
|j|d|j|ddS(
NRds8localhost, anotherdomain.com, newdomain.com:1234, .d.o.tRet	LocalHostt	LOCALHOSTsnewdomain.com:1234s	foo.d.o.tsanotherdomain.com:8888swww.newdomain.com:1234tprelocalhosts
newdomain.comsnewdomain.com:1235(R3RiR]RgRAtassertFalse(Rtbypass((s,/usr/local/lib/python2.7/test/test_urllib.pyt(test_proxy_bypass_environment_host_matchs	(RRR7R:RkRqRw(((s,/usr/local/lib/python2.7/test/test_urllib.pyRZs
				tProxyTests_withOrderedEnvcBs#eZdZdZdZRS(cCstj|_tjt_dS(N(R8R^t
_saved_envtcollectionstOrderedDict(R((s,/usr/local/lib/python2.7/test/test_urllib.pyR7scCs|jt_dS(N(RyR8R^(R((s,/usr/local/lib/python2.7/test/test_urllib.pyR:scCsBdtjd<dtjd<|jtjd|jtjddtjd<dtjd<tj}|ji|d	tjd<d
tjd<|jtjd|jtjd|jtjd|jtjd
|jtjddtjd<dtjd<tj}|jd|ddS(NRtno_proxyRetNo_Proxyt	arbitraryt
http_proxyshttp://somewhere:3128Rls%localhost, noproxy.com, my.proxy:1234sxyz.comsnoproxy.com:5678s
my.proxy:1234smy.proxyshttp://somewhereelse:3128t
Http_ProxyRm(R8R^RuR3RiRhRERA(RRj((s,/usr/local/lib/python2.7/test/test_urllib.pyt,test_getproxies_environment_prefer_lowercases&







(RRR7R:R(((s,/usr/local/lib/python2.7/test/test_urllib.pyRxs		turlopen_HttpTestscBszeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
s.Test urlopen() opening a fake http connection.cCs|jdzktjd}|j|jd|j|jd|j|jd|j|jdWd|jXdS(NsHello!shttp://python.org/Ri(R%R3R4RERR>R?R*(Rtfp((s,/usr/local/lib/python2.7/test/test_urllib.pyRFs
cCsNd}|jdz)tj|}|j|j|Wd|jXdS(Ns-http://docs.python.org/library/urllib.html#OKsHello!(R%R3R4RER>R*(RturlR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_url_fragments
cCsxtddtddD]d}t|}d|}|jdz-tjd|}|j||jWd|jXqWdS(Nii!iis//localhost:7777/test%s/sHTTP/1.1 200 OK

Hello.shttp:(trangetchrR%R3R4RpR>R*(Rtchar_noRtschemeless_urltresp((s,/usr/local/lib/python2.7/test/test_urllib.pyt#test_url_with_control_char_rejecteds#

cCs|jdd}d|d}zYtjd|}|jd|j|jd|j|jd|jWd|jXdS(	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%R3R4RpR>R*(RthostRR((s,/usr/local/lib/python2.7/test/test_urllib.pyt/test_url_with_newline_header_injection_rejecteds
cCs9|jdz|jttjdWd|jXdS(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
shttp://python.org/(R%RVtIOErrorR3R4R*(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_read_boguss
cCsO|jdz0d}|jt|tjdWdQXWd|jXdS(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:README
Connection: close
Content-Type: text/html; charset=iso-8859-1
sRedirection to url 'file:shttp://python.org/(R%tassertRaisesRegexpRR3R4R*(Rtmsg((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_invalid_redirect*scCsYxRttjjD];}|jdz|jttjdWd|jXqWdS(Ns_HTTP/1.1 302 Found
Location: file://guidocomputer.athome.com:/python/license
Connection: close
shttp://something(	RR3tFancyURLopenertmaxtriesR%RVRR4R*(Rti((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_redirect_limit_independent:scCs9|jdz|jttjdWd|jXdS(NRshttp://something(R%RVRR3R4R*(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_empty_socketHs
cCs|jttjdtj\}}d|jtjj	d}|j
tjj|ztj|}|jWdtj|tj
|X|jtjj||jttj|dS(Ns"file://localhost/a/missing/file.pysfile://localhost/t/(RVRR3R4ttempfiletmkstemptreplaceR8tpathtsepRAtexistsR1tunlinkRu(Rtfdttmp_filettmp_fileurlR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_missing_localfileQs
cCs|jttjddS(Ns$ftp://localhost/not/existing/file.py(RVRR3R4(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_ftp_nonexistingascCs|jdztjj}tjd}dtd}|j||j|j	|j
d|j	|j
d|j	|jd|j	|jdWd|j
XdS(NsHello!shttp://user:pass@python.org/sAuthorization: Basic %s
s	user:passRi(R%R#R'R(R3R4RtassertInRRERR>R?R*(Rtfakehttp_wrapperRt
authorization((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_userpass_inurlfs

cCs|jdzd}tjj}dtd}tj|}|j||j|j	|j
d|j	|j
d|j|j||j	|j
dWd|jXdS(NsHello!shttp://a b:c d@python.org/sAuthorization: Basic %s
sa b:c dRi(R%R#R'R(RR3R4RRRERtassertNotEqualR>R?R*(RRRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_userpass_with_spaces_inurlvs

(RRRYRFRRRRRRRRRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRs		
		
	
							turlretrieve_FileTestscBsteZdZdZdZdZddZdZdZdZ	d	Z
d
ZdZdZ
RS(
s(Test urllib.urlretrieve() on local filescCsrg|_|jtjd|_z0ttjd}|j|j|jWdy|jWnnXXdS(Nstesting urllib.urlretrieveR,(t	tempFilestregisterFileForCleanUpRR/R-R.R0R1(RR6((s,/usr/local/lib/python2.7/test/test_urllib.pyR7s		cCs3x,|jD]!}ytj|Wq
q
Xq
WdS(N(RR8R9(Rteach((s,/usr/local/lib/python2.7/test/test_urllib.pyR:s
cCsdtjtjj|S(Ns	file://%s(R3tpathname2urlR8Rtabspath(RtfilePath((s,/usr/local/lib/python2.7/test/test_urllib.pytconstructLocalFileUrlsRcCsltj\}}z:|j|tj|d}|j||jWdy|jWnnXX|S(sCreates 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(RRRR8tfdopenR0R1(RR
tnewFdtnewFilePathtnewFile((s,/usr/local/lib/python2.7/test/test_urllib.pytcreateNewTempFiles

cCs|jj|dS(N(Rtappend(RtfileName((s,/usr/local/lib/python2.7/test/test_urllib.pyRscCsKtjdtj}|j|dtj|j|dtjddS(Nsfile:%siisAdid not get a mimetools.Message instance as second returned value(R3turlretrieveRR/RERJRORP(Rtresult((s,/usr/local/lib/python2.7/test/test_urllib.pyt
test_basicscCsdtj}|j|tj|jtj|}|j||d|jtj	j
|dt|d}z|j}|j
Wdy|j
WnnXX|j|j|dS(Ns%s.2iscopy of the file was not madetrb(RR/RR3RRRERAR8RRR.RR1R-(Rtsecond_tempRR6R-((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_copys

csRdgfd}dtj}j|tjjtj||dS(NicsZj|tj|tj|tj||d|dd|d<dS(Nii(RJRKRE(tcountt
block_sizet
total_sizetcount_holder(R(s,/usr/local/lib/python2.7/test/test_urllib.pyt
hooktesters
s%s.2(RR/RR3RR(RRR((Rs,/usr/local/lib/python2.7/test/test_urllib.pyttest_reporthooks


cCsog}|d}|j}tj|j|tj||jt|d|j|ddddS(NcSs|j|||fdS(N(R(RRRt_report((s,/usr/local/lib/python2.7/test/test_urllib.pyRsiii(RR3RRRR/RER(RtreportRtsrcFileName((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_reporthook_0_bytess
cCsg}|d}|jd}tj|j|tj||jt|d|j|ddd|j|ddddS(	NcSs|j|||fdS(N(R(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyRstxiiiii txxxxx(RR3RRRR/RER(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_reporthook_5_bytess
cCsg}|d}|jdd}tj|j|tj||jt|d|j|ddd|j|ddddS(	NcSs|j|||fdS(N(R(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyRsRi iiii i(RR3RRRR/RER(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_reporthook_8193_bytess
(RRRYR7R:RRRRRRRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRs								
		turlretrieve_HttpTestscBs eZdZdZdZRS(s5Test urllib.urlretrieve() using fake http connectionscCsK|jdd}z#|jtjtjdd|Wd|jXdS(NsHTTP/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((s,/usr/local/lib/python2.7/test/test_urllib.pyt_reporthooksshttp://example.comt
reporthook(R%RVR3tContentTooShortErrorRR*(RR((s,/usr/local/lib/python2.7/test/test_urllib.pyt.test_short_content_raises_ContentTooShortErrors	cCs<|jdz|jtjtjdWd|jXdS(NsHTTP/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%RVR3RRR*(R((s,/usr/local/lib/python2.7/test/test_urllib.pytAtest_short_content_raises_ContentTooShortError_without_reporthook%s
(RRRYRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRs	tQuotingTestscBsDeZdZdZdZdZdZdZdZRS(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||ftj|}|j||d||fdS(NRtABCDEFGHIJKLMNOPQRSTUVWXYZtabcdefghijklmnopqrstuvwxyzt
0123456789s_.-susing quote(): %s != %ssusing quote_plus(): %s != %s(tjoinR3tquoteREt
quote_plus(Rtdo_not_quoteR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_never_quoteNs	cCs|jtjjdddS(NiR(RER3Rt
func_defaults(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_default_safe[scCsnd}tj|d|}|j||d||ftj|d|}|j||d||fdS(Ns<>tsafesusing quote(): %s != %ssusing quote_plus(): %s != %s(R3RRER(Rtquote_by_defaultR((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_safe_scCs\gtdD]}t|^q
}|jd|jtddj|}x|D]|}tj|}|jt||d|t||ftj|}|jt||d|t||fq[W~d}d}tj|}|j||d	||ftj|}|j||d
||f|j	t
tjddS(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(RRRRR3RRER	RRVt	TypeErrorR(Rtnumtshould_quoteRRt
partial_quotetexpected((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_default_quotingjs.%

cCstjd}|j|tdd|tdftjd}|j|dd|d}|jdtd}tj|}|j||d||f|jdd}tj|}|j||d||fdS(NRsusing quote(): %s != %st+susing quote_plus(): %s != +s
a b cd e fsusing quote_plus(): %s != %s(R3RRER	RR(RRtgiventexpect((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_quoting_spacescCs9|jtjdd|jtjddddS(Nsalpha+beta gammasalpha%2Bbeta+gammaRsalpha+beta+gamma(RER3R(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_quoting_pluss(	RRRYRRRRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyR4s	
				tUnquotingTestscBsDeZdZdZdZdZdZdZdZRS(swTests for unquote() and unquote_plus()

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

    cCsg}xtdD]}tt|}t|}tj|}|j||d||ftj|}|j||d||f|j|qWdj|}~tj|}|j|j	ddd|tj|}|j|j	ddd|dS(	Nisusing unquote(): %s != %ssusing unquote_plus(): %s != %sRRis-using quote(): not all characters escaped; %ss/using unquote(): not all characters escaped: %s(
RR	RR3tunquoteREtunquote_plusRRR(Rtescape_listRRRRt
escape_string((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquotings,cCsd}|}tj|}|j||d||fd}|}tj|}|j||d||fd}|}tj|}|j||d||fdS(Ns%xabsusing unquote(): %r != %rs%xR(R3RRE(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquoting_badpercentscCs<d}d}tj|}|j||d||fdS(Ns%Ab%eAssusing unquote(): %r != %r(R3RRE(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquoting_mixed_cases
cCsrdtd}d}tj|}|j||d||ftj|}|j||d||fdS(Nsab%sdtctabcdsusing quote(): %s != %ssusing unquote_plus(): %s != %s(R	R3RRER(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquoting_partsscCszd}|}tj|}|j||d||f|jdd}tj|}|j||d||fdS(Nsare+there+spaces...susing unquote(): %s != %sRRsusing unquote_plus(): %s != %s(R3RRERR(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquoting_plusscCs#tjd}|j|ddS(Nu"br%C3%BCckner_sapporo_20050930.docu brückner_sapporo_20050930.doc(R3RRE(Rtr((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unquote_with_unicodes(	RRRYRRRRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRs					turlencode_TestscBs;eZdZdZdZdZdZdZRS(sTests for urlencode()c	Csdddg}tj|}x.|D]&}|j||d|||fq%W|j|jddd||jdf|jd}||d}||d}|j|jo|jd	||f|jt|dd|t|dfd
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(	R3t	urlencodeRRERtindexRAtisdigitR(	RRt	test_typetexpect_somewhereRRtamp_locationton_amp_leftton_amp_right((s,/usr/local/lib/python2.7/test/test_urllib.pythelp_inputtypes$
cCs)|jidd6dd6dd6ddS(Nt1t1stt2t2ndt3t3rdsusing dict as input type(R	(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_using_mappingscCs|jdd	d
gddS(NRR
R
RRRs*using sequence of two-item tuples as input(RR
(R
R(RR(R	(R((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_using_sequencescCs~idd6}dtdtdf}tj|}|j||idd6}d}tj|}|j||dS(Nt=Rs%s=%ssA bunch of plusesskey nameskey+name=A+bunch+of+pluses(R	R3RRE(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_quoting"s

cCsidddgd6}dtjtdddg}tj|}|j||tj|t}x,|dD] }d|}|j||qtW|j|jddd|jddS(	NR
RRtsequencessequence=%sRisExpected 2 '&'s, got %s(R3RtstrRREtTrueRR(RRRRtvalue((s,/usr/local/lib/python2.7/test/test_urllib.pyt
test_doseq-s"
(RRRYR	RRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRs	 			tPathname_TestscBsDeZdZdZdZejejdkddZ	RS(s&Test pathname2url() and url2pathname()cCs}tjjdddd}d}tj|}|j||d||ftj|}|j||d||fdS(NtpartstoftaRsparts/of/a/pathspathname2url() failed; %s != %ssurl2pathame() failed; %s != %s(R8RRR3RREturl2pathname(Rt
expected_pathtexpected_urlR((s,/usr/local/lib/python2.7/test/test_urllib.pyR=scCs(tjjddd}dtjd}tj|}|j||d||f|}tj|}|j||d||ftjjdd}d	tjd}tj|}|j||d||fd
}tjjdd}tj|}|j||d||fdS(
Ntneedssquot=ingtheres
needs/%s/herespathname2url() failed; %s != %ssurl2pathname() failed; %s != %ss	make suretusing_quotes%s/using_quotesmake+sure/using_unquotes	make+suret
using_unquote(R8RRR3RRRER(RRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyRJs.twin32s'test specific to the nturl2path librarycCsd}d}x:|D]2}tj|}|j||d||fqWd}d}tj|}|j||d||fdS(	Ns/C:/s///C:/s/C|//sC:\s*nturl2path.url2pathname() failed; %s != %ss
///C|/pathsC:\path(s/C:/s///C:/s/C|//(R3RRE(RRRRR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_ntpathes
(
RRRYRRtunittestt
skipUnlesstsystplatformR%(((s,/usr/local/lib/python2.7/test/test_urllib.pyR:s
	
	t
Utility_TestscBszeZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZRS(
s=Testcase to test the various utility functions in the urllib.cCs{tj}|j|dd	|j|dd
|j|dd|j|dd|j|dd
dS(Nstype:opaquestringttypetopaquestrings
:opaquestringstype:Rstype:opaque:strings
opaque:string(R+R,(NR,(Ns
:opaquestring(R+R(R+s
opaque:string(R3t	splittypeRER(RR-((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splittypezs	cCstj}|j|dd|j|dd|j|dd|j|dd|j|d	d|j|dd|j|d
d|j|dd|j|dd|j|dddS( 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#(R3t	splithostRER(RR/((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splithosts*	cCs{tj}|j|dd	|j|dd
|j|dd|j|dd|j|dd
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(R3t	splituserRER(RR1((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitusers	cCs+tj}|j|dd|j|dd|j|dd|j|dd|j|d
d|j|dd|j|dd |j|dd!|j|dd"|j|dd#|j|dd$|j|dd%|j|dd&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(R3R4(R3sa
b(R3sa	b(R3sa
b(R3sab(R3sab(R3sa:b(R3sa b(suser 2R4(suser+1sa+b(R3R(R3N(RR4(R3tsplitpasswdRER(RR5((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitpasswds	cCstj}|j|dd|j|dd|j|dd
|j|dd|j|dd|j|dd|j|dd|j|d	ddS(Ns	parrot:88tparrott88sparrot:s	127.0.0.1s
parrot:cheeses[::1]:88s[::1]s:88R(R7R8(R7N(R7N(s	127.0.0.1N(s
parrot:cheeseN(s[::1]R8(s[::1]N(RR8(R3t	splitportRER(RR9((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitports	cCstj}|j|dd	|j|dd
|j|ddd|j|dd|j|ddd
|j|dd|j|ddd|j|dd|j|ddddS(Ns	parrot:88R7iXii7sparrot:s	127.0.0.1s
parrot:cheese(R7iX(R7i(R7i7(R7i(R7i7(s	127.0.0.1i(s	127.0.0.1i7(R7N(R7N(R3t
splitnportRER(RR;((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitnports	cCsetj}|j|dd|j|dd|j|dd	|j|dd
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(R3t
splitqueryRER(RR=((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitquerys	cCs{tj}|j|dd	|j|dd
|j|dd|j|dd|j|dd
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@(R3tsplittagRER(RRA((s,/usr/local/lib/python2.7/test/test_urllib.pyt
test_splittags	cCstj}|j|ddddgf|j|dddgf|j|ddddgf|j|ddgfdS(Ns/path;attr1=value1;attr2=value2s/pathsattr1=value1sattr2=value2s/path;Rs;attr1=value1;attr2=value2(R3t	splitattrRE(RRC((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitattrs	cCs{tj}|j|dd
|j|dd|j|dd|j|dd
|j|dddS(Nsfoo=bartfootbarsfoo=Rs=bartfoobarsfoo=bar=bazsbar=baz(RERF(RER(RRF(RGN(REsbar=baz(R3t
splitvalueRER(RRH((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_splitvalues	cCsBtjd}|j|d|jttjtjddS(Nuhttp://www.python.orgshttp://www.python.orgs#http://www.python.org/medi\u00e6val(R3ttoBytesRERVtUnicodeErrorRtu(RR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_toBytesscCs#tjd}|j|ddS(Ns<URL:type://host/path>stype://host/path(R3tunwrapRE(RR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_unwraps(RRRYR.R0R2R6R:R<R>RBRDRIRMRO(((s,/usr/local/lib/python2.7/test/test_urllib.pyR*vs			
								
	tURLopener_TestscBs eZdZdZdZRS(s4Testcase to test the open method of URLopener class.cCsUdtjfdY}|j|jdd|j|jdddS(NtDummyURLopenercBseZdZRS(cSs|S(N((RR((s,/usr/local/lib/python2.7/test/test_urllib.pyt	open_spams(RRRR(((s,/usr/local/lib/python2.7/test/test_urllib.pyRQssspam://example/ /s//example/%20/s,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/s'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/(R3t	URLopenerREtopen(RRQ((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_quoted_opens
cCsdtjfdY}xdD]}|jttj||jttjj||jttjj||jt|j||jt|j|q WdS(NRQcBseZdZRS(cSs|S(N((RR((s,/usr/local/lib/python2.7/test/test_urllib.pytopen_local_files(RRRV(((s,/usr/local/lib/python2.7/test/test_urllib.pyRQsslocal_file://exampleslocal-file://example(slocal_file://exampleslocal-file://example(R3RSRVRR4RTtretrieve(RRQR((s,/usr/local/lib/python2.7/test/test_urllib.pyttest_local_file_opens
(RRRYRURX(((s,/usr/local/lib/python2.7/test/test_urllib.pyRPs	
cCsgddl}|jI|jddttjtttt	t
ttt
tttt
t
WdQXdS(Nitignores.*urllib\.urlopen.*Python 3.0(twarningstcatch_warningstfilterwarningstDeprecationWarningRtrun_unittestR+RRRRZRRRRR*RPRx(RZ((s,/usr/local/lib/python2.7/test/test_urllib.pyt	test_mainws$
t__main__(!RYRzR3R#RR&R8R(RORttestRtbase64RR	R%tobjectR&tTestCaseR+RZRxRRRRRRRR*RPR_R(((s,/usr/local/lib/python2.7/test/test_urllib.pyt<module>s:		 
P5$&kVE<l	

Zerion Mini Shell 1.0