Current File : //opt/imh-python/lib/python2.7/test/test_urllib.pyc
�
��Wc@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(#sRegresssion 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((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytsendallsc_s|S(N((Rtargstkwds((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytmakefilescSs |jr
dStjj||�S(Nt(tclosedtiotBytesIOtread(Rtamt((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR"s	cSs |jr
dStjj||�S(NR(RRRtreadline(Rtlength((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR's	N(t__name__t
__module__RRtNoneRR((R(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR
s	RcseZdZ�fd�ZRS(Rcs%�|j�|_|j|j_dS(N(tfakedatatsockt	__class__tfakesock(R(R
(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytconnect1s(RRRR"((R
(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR,s(RRthttplibtHTTPConnectionR(R((RR
si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytfakehttps	t
FakeHTTPMixincBseZd�Zd�ZRS(cCs1tjjtjkst�t|�tj_dS(N(R#tHTTPt_connection_classR$tAssertionErrorR%(RR((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR%:scCstjtj_dS(N(R#R$R'R((R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt
unfakehttp?s(RRR%R*(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytsetUpKscCs!|jj�tjtj�dS(sShut down the open objectN(R5R1tostremoveRR/(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(	sreadsreadlines	readlinessfilenosclosesinfosgeturlsgetcodes__iter__(t
assertTruethasattrR5(Rtattr((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_interface[s

cCs |j|j|jj��dS(N(tassertEqualR-R5R(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(RER-R5R(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R5R;RERR-(Rt
lines_list((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(	R5R<tassertIsInstancetintRER8RRR-(Rtfile_num((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_filenoss$cCs|jj�dS(N(R5R1(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt
test_closezscCs |j|jj�tj�dS(N(RJR5R=t	mimetoolstMessage(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt	test_infoscCs |j|jj�|j�dS(N(RER5R>R2(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_geturl�scCs|j|jj�d�dS(N(RER5R?R(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_getcode�scCs1x*|jj�D]}|j||j�qWdS(N(R5R@RER-(Rtline((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt	test_iter�scCs!|jttjd|j�dS(Ns./(tassertRaisest
ValueErrorR3R4R2(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_relativelocalfile�s(RRt__doc__R7R:RDRFRGRIRMRNRQRRRSRURX(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR+Cs												t
ProxyTestscBs,eZd�Zd�Zd�Zd�ZRS(cCsRtj�|_x<tjj�D]+}d|j�kr|jj|�qqWdS(Ntproxy(RtEnvironmentVarGuardtenvR8tenvirontkeystlowertunset(Rtk((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR7�scCs|jj�|`dS(N(R]t__exit__(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR:�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]tsetR3tgetproxies_environmentRERAtproxy_bypass_environment(Rtproxies((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt+test_getproxies_environment_keep_no_proxies�scCs�tj}|jjdd�|j|d��|j|d��|j|d��|j|d��|j|d��|j|d��|j|d	��|j|d
��|j|d��dS(NRds0localhost, anotherdomain.com, newdomain.com:1234Ret	LocalHostt	LOCALHOSTsnewdomain.com:1234sanotherdomain.com:8888swww.newdomain.com:1234tprelocalhosts
newdomain.comsnewdomain.com:1235(R3RiR]RgRAtassertFalse(Rtbypass((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt(test_proxy_bypass_environment_host_match�s	(RRR7R:RkRq(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRZ�s			tProxyTests_withOrderedEnvcBs#eZd�Zd�Zd�ZRS(cCstj|_tj�t_dS(N(R8R^t
_saved_envtcollectionstOrderedDict(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR7�scCs|jt_dS(N(RsR8R^(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR:�scCsBdtjd<dtjd<|jtjd��|jtjd��dtjd<dtjd<tj�}|ji|�d	tjd<d
tjd<|jtjd��|jtjd��|jtjd��|jtjd
��|jtjd��dtjd<dtjd<tj�}|jd|d�dS(NRtno_proxyRetNo_Proxyt	arbitraryt
http_proxyshttp://somewhere:3128t
HTTP_PROXYs%localhost, noproxy.com, my.proxy:1234sxyz.comsnoproxy.com:5678s
my.proxy:1234smy.proxyshttp://somewhereelse:3128t
Http_Proxythttp(R8R^RoR3RiRhRERA(RRj((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt,test_getproxies_environment_prefer_lowercase�s&







(RRR7R:R}(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRr�s		turlopen_HttpTestscBsheZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZRS(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%R3R4RERR>R?R*(Rtfp((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRF�s
cCsNd}|jd�z)tj|�}|j|j�|�Wd|j�XdS(Ns-http://docs.python.org/library/urllib.html#OKsHello!(R%R3R4RER>R*(RturlR((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_url_fragment�s
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%RVtIOErrorR3R4R*(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_read_bogus�s
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�R3R4R*(Rtmsg((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_invalid_redirectscCsYxRttj�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(	trangeR3tFancyURLopenertmaxtriesR%RVR�R4R*(Rti((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_redirect_limit_independentscCs9|jd�z|jttjd�Wd|j�XdS(NRshttp://something(R%RVR�R3R4R*(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_empty_socket"s
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/(RVR�R3R4ttempfiletmkstemptreplaceR8tpathtsepRAtexistsR1tunlinkRo(Rtfdttmp_filettmp_fileurlR((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_missing_localfile+s
cCs|jttjd�dS(Ns$ftp://localhost/not/existing/file.py(RVR�R3R4(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_ftp_nonexisting;scCs�|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(R3R4RtassertInRRERR>R?R*(Rtfakehttp_wrapperRt
authorization((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_userpass_inurl@s

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(RR3R4R�RRERtassertNotEqualR>R?R*(RR�R�R�R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_userpass_with_spaces_inurlPs

(
RRRYRFR�R�R�R�R�R�R�R�R�(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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.R0R1(RR6((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR7fs		cCs3x,|jD]!}ytj|�Wq
q
Xq
WdS(N(R�R8R9(Rteach((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR:{s
cCsdtjtjj|��S(Ns	file://%s(R3tpathname2urlR8R�tabspath(RtfilePath((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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�R8tfdopenR0R1(RR
tnewFdtnewFilePathtnewFile((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytcreateNewTempFile�s

cCs|jj|�dS(N(R�tappend(RtfileName((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3turlretrieveRR/RERJRORP(Rtresult((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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�R3R�R�RERAR8R�R�R.RR1R-(Rtsecond_tempR�R6R-((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(RJRKRE(tcountt
block_sizet
total_sizetcount_holder(R(si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt
hooktester�s
s%s.2(RR/R�R3R�R�(RR�R�((Rsi/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR��siii(R�R3R�R�RR/RER(RtreportR�tsrcFileName((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR��stxiiiii txxxxx(R�R3R�R�RR/RER(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR��sR�i iiii i(R�R3R�R�RR/RER(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_reporthook_8193_bytes�s
(RRRYR7R:R�R�R�R�R�R�R�R�R�(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR�cs								
		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((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt_reporthook�sshttp://example.comt
reporthook(R%RVR3tContentTooShortErrorR�R*(RR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt.test_short_content_raises_ContentTooShortError�s	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%RVR3R�R�R*(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pytAtest_short_content_raises_ContentTooShortError_without_reporthook�s
(RRRYR�R�(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(tjoinR3tquoteREt
quote_plus(Rtdo_not_quoteR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_never_quote(s	cCs|jtjjdd�dS(NiR�(RER3R�t
func_defaults(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_default_safe5scCsnd}tj|d|�}|j||d||f�tj|d|�}|j||d||f�dS(Ns<>tsafesusing quote(): %s != %ssusing quote_plus(): %s != %s(R3R�RER�(Rtquote_by_defaultR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt	test_safe9s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�tchrR�R�R3R�RER	R�RVt	TypeErrorR(Rtnumtshould_quoteRR�t
partial_quotetexpected((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_default_quotingDs.%

cCs�tjd�}|j|td�d|td�f�tjd�}|j|dd|�d}|jdtd��}tj|�}|j||d||f�|jdd�}tj|�}|j||d||f�dS(Nt susing quote(): %s != %st+susing quote_plus(): %s != +s
a b cd e fsusing quote_plus(): %s != %s(R3R�RER	R�R�(RR�tgiventexpect((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_quoting_space`scCs9|jtjd�d�|jtjdd�d�dS(Nsalpha+beta gammasalpha%2Bbeta+gammaR�salpha+beta+gamma(RER3R�(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_quoting_plusss(	RRRYR�R�R�R�R�R�(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR�s	
				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�R3tunquoteREtunquote_plusR�R�R�(Rtescape_listR�R�R�R�t
escape_string((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3R�RE(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_unquoting_badpercent�scCs<d}d}tj|�}|j||d||f�dS(Ns%Ab%eAs��susing unquote(): %r != %r(R3R�RE(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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	R3R�RER�(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3R�RER�R�(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3R�RE(Rtr((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_unquote_with_unicode�s(	RRRYR�R�R�R�R�R�(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR�ys					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(	R3t	urlencodeR�RER�tindexRAtisdigitR(	RR�t	test_typetexpect_somewhereR�R�tamp_locationton_amp_leftton_amp_right((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pythelp_inputtype�s$
cCs)|jidd6dd6dd6d�dS(Nt1t1stt2t2ndt3t3rdsusing dict as input type(R�(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_using_mapping�scCs|jdd	d
gd�dS(NRRRRRRs*using sequence of two-item tuples as input(s1stR(s2ndR(s3rdR(R�(R((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_using_sequence�scCs~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	R3R�RE(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(	NRRRtsequencessequence=%sR�isExpected 2 '&'s, got %s(R3R�tstrR�REtTrueR�R�(RR�R�R�tvalue((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt
test_doseqs"
(RRRYR�RRR	R(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R8R�R�R3R�REturl2pathname(Rt
expected_pathtexpected_urlR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R8R�R�R3R�R�RER(RR�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR	$s.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|//(R3RRE(RR�R�R�R�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_ntpath?s
(
RRRYR�R	tunittestt
skipUnlesstsystplatformR(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRs
	
	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(stypeR"(NR"(Ns
:opaquestring(stypeR(stypes
opaque:string(R3t	splittypeRER(RR#((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_splittypeTs	cCsOtj}|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:80R(swww.example.org:80s/foo/bar/baz.html(swww.example.org:80R(Ns/foo/bar/baz.html(R3t	splithostRER(RR%((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3t	splituserRER(RR'((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_splituseres	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(R)R*(R)sa
b(R)sa	b(R)sa
b(R)sab(R)sab(R)sa:b(R)sa b(suser 2R*(suser+1sa+b(R)R(R)N(RR*(R3tsplitpasswdRER(RR+((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_splitpasswdrs	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(R-R.(R-N(R-N(s	127.0.0.1N(s
parrot:cheeseN(s[::1]R.(s[::1]N(RR.(R3t	splitportRER(RR/((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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:88R-iXi����i7sparrot:s	127.0.0.1s
parrot:cheese(sparrotiX(sparroti����(sparroti7(sparroti����(sparroti7(s	127.0.0.1i����(s	127.0.0.1i7(sparrotN(sparrotN(R3t
splitnportRER(RR1((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3t
splitqueryRER(RR3((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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=barR5(shttp://example.com?foo=barR(RR5(shttp://example.com?foo=barN(shttp://example.com?foo=bar#bazR6(R3tsplittagRER(RR7((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3t	splitattrRE(RR9((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R;R<(R;R(RR<(R=N(R;sbar=baz(R3t
splitvalueRER(RR>((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/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(R3ttoBytesRERVtUnicodeErrorRtu(RR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_toBytes�scCs#tjd�}|j|d�dS(Ns<URL:type://host/path>stype://host/path(R3tunwrapRE(RR�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_unwrap�s(RRRYR$R&R(R,R0R2R4R8R:R?RCRE(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyR Ps				
								
	tURLopener_TestscBseZdZd�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�((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt	open_spam�s(RRRH(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRG�ssspam://example/ /s//example/%20/s,spam://c:|windows%/:=&?~#+!$,;'@()*[]|/path/s'//c:|windows%/:=&?~#+!$,;'@()*[]|/path/(R3t	URLopenerREtopen(RRG((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyttest_quoted_open�s
(RRRYRK(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyRF�scCsgddl}|j��I|jddt�tjtttt	t
ttt
tttt
t�
WdQXdS(Ni����tignores.*urllib\.urlopen.*Python 3.0(twarningstcatch_warningstfilterwarningstDeprecationWarningRtrun_unittestR+R~R�R�RZR�R�R�RR RFRr(RM((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt	test_main2s$
t__main__(!RYRtR3R#RRR8RROR�ttestRtbase64RR	R%tobjectR&tTestCaseR+RZRrR~R�R�R�R�R�RR RFRRR(((si/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib.pyt<module>s:		 
P($��&kVE<�a