Current File : //opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyo
�
��Wc@s�ddlZddlZddlZddlZddlZddlZddlZddlmZej	dde
�Zej	d�Zyddl
Z
Wnek
r�eZ
nXejje�Zejjed�Zejjed�Zdejfd	��YZd
ejfd��YZdejfd
��YZdfd��YZdejfd��YZdejfd��YZ de fd��YZ!de fd��YZ"d�Z#de fd��YZ$d�Z%e&dkr�e%�ndS(i����N(ttest_supportt	mimetoolst
deprecatedt	threadingskeycert.pemskeycert2.pemtLoopbackHttpServercBs eZdZd�Zd�ZRS(s^HTTP server w/ a few modifications that make it useful for
    loopback testing purposes.
    cCs*tjj|||�|jjd�dS(Ng�������?(tBaseHTTPServert
HTTPServert__init__tsockett
settimeout(tselftserver_addresstRequestHandlerClass((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR scCs,|jj�\}}|jd�||fS(s"BaseHTTPServer method, overridden.g$@(RtacceptR	(R
trequesttclient_address((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytget_request)s
(t__name__t
__module__t__doc__RR(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyRs		tLoopbackHttpServerThreadcBs)eZdZd�Zd�Zd�ZRS(s2Stoppable thread that runs a loopback http server.cCsVtjj|�t|_tj�|_d|_td|�|_	|j	j
|_dS(NsHTTP/1.0s	127.0.0.1i(s	127.0.0.1i(RtThreadRtFalset_stoptEventtreadytprotocol_versionRthttpdtserver_porttport(R
trequest_handler((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR8s		cCst|_|j�dS(s.Stops the webserver if it's currently running.N(tTrueRtjoin(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytstopCs	cCs.|jj�x|js)|jj�qWdS(N(RtsetRRthandle_request(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytrunKs
(RRRRR!R$(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR5s		tBasicAuthHandlercBsleZdZdZdZdZdeefZeje�Z	d�Z
d�Zd�Zd�Z
d	�ZRS(
s,Handler for performing Basic Authentication.ttestUserttestPasstTests%s:%scOstjj|||�dS(N(RtBaseHTTPRequestHandlerR(R
targstkwargs((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR\scGsdS(N((R
tformatR*((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytlog_message_scCs+|jd�|jdd�|j�dS(Ni�sContent-types	text/html(t
send_responsetsend_headertend_headers(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytdo_HEADcs
cCsB|jd�|jdd|j�|jdd�|j�dS(Ni�sWWW-AuthenticatesBasic realm="%s"sContent-types	text/html(R.R/tREALMR0(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytdo_AUTHHEADhs
cCsu|jjd�dkr5|j�|jjd�n<|jjd�d|jkrg|jjd�n
|j�dS(Nt
AuthorizationsNo Auth Header ReceivedsBasic s	It works!(theaderst	getheadertNoneR3twfiletwritetENCODED_AUTH(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytdo_GETns
	(RRRtUSERtPASSWDR2tUSER_PASSWDtbase64t	b64encodeR:RR-R1R3R;(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR%Ss				tDigestAuthHandlercBs_eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
s-Handler for performing digest authentication.cCs1d|_g|_i|_d|_d|_dS(Nis
Test Realmtauth(t_request_numt_noncest_userst_realm_namet_qop(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR}s
				cCs
||_dS(N(RG(R
tqop((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytset_qop�scCs
||_dS(N(RE(R
tusers((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt	set_users�scCs
||_dS(N(RF(R
trealm((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt	set_realm�scCsA|jd7_tjt|j��j�}|jj|�|S(Ni(RCthashlibtmd5tstrt	hexdigestRDtappend(R
tnonce((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt_generate_nonce�scCs�|jd�}||d}|jd�}i}xu|D]m}|jd�\}}|j�}|ddkr�|ddkr�|dd!}n|j�}|||<q9W|S(Nt it,t=it"i����(tfindtsplittstrip(R
tauth_strtfirst_space_indextpartst	auth_dicttparttnametvalue((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt_create_auth_dict�s
 cCs�i}|j|�||d<||d<||d<d|}tj|�j�}d|}tj|�j�}	||d<|	|d<d|}
tj|
�j�}||d	kS(
Ntpasswordtmethodturis#%(username)s:%(realm)s:%(password)ss%(method)s:%(uri)stHA1tHA2s3%(HA1)s:%(nonce)s:%(nc)s:%(cnonce)s:%(qop)s:%(HA2)stresponse(tupdateRNRORQ(R
R_RdReRft
final_dicttHA1_strRgtHA2_strRhtresponse_strRi((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt_validate_auth�s







cCsg|jdd�|jdd�|jdd|j|j|j�f�|j�|jjd�tS(Ni�sProxy Authentication RequiredsContent-Types	text/htmlsProxy-Authenticates(Digest realm="%s", qop="%s",nonce="%s", sProxy Authentication Required.(	R.R/RFRGRTR0R8R9R(R
R((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt_return_auth_challenge�s
cCst|j�dkrtSd|jkr5|j|�S|j|jd�}|d|jkrr|j|d}n
|j|�S|jd�|jkr�|j|�S|jj|d�t	}x>|j
|jgD]*}|j|||j
|�r�t}q�q�W|s|j|�StSdS(sPerforms digest authentication on the given HTTP request
        handler.  Returns True if authentication was successful, False
        otherwise.

        If no users have been set, then digest auth is effectively
        disabled and this method will always return True.
        isProxy-AuthorizationtusernameRSN(tlenRERR5RpRctgetRDtremoveRtpatht
short_pathRotcommand(R
RR_Rdtauth_validatedRu((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR#�s,	


		

(RRRRRIRKRMRTRcRoRpR#(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyRAzs								tFakeProxyHandlercBs)eZdZd�Zd�Zd�ZRS(s�This is a 'fake proxy' that makes it look like the entire
    internet has gone down due to a sudden zombie invasion.  It main
    utility is in providing us with authentication support for
    testing.
    cOs#||_tjj|||�dS(N(tdigest_auth_handlerRR)R(R
RzR*R+((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�s	cGsdS(N((R
R,R*((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR-scCs�tj|jd�\}}}}}}||_|jj|�r�|jdd�|jdd�|j�|jj	d|j�|jj	d�ndS(Nthttpi�tOKsContent-Types	text/htmlsYou've reached %s!<BR>sFOur apologies, but our server is down due to a sudden zombie invasion.(
turlparseRuRvRzR#R.R/R0R8R9(R
tscmtnetlocRutparamstquerytfragment((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR;s!	
(RRRRR-R;(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyRy�s		tBaseTestCasecBseZd�Zd�ZRS(cCstj�|_dS(N(Rtthreading_setupt_threads(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytsetUpscCstj|j�dS(N(Rtthreading_cleanupR�(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttearDowns(RRR�R�(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�s	tBasicAuthTestscBsDeZdZdZdZdZd�Zd�Zd�Zd�Z	RS(R&R't	IncorrectR(cCs_tt|�j�d�}t|�|_d|jj|_|jj�|jjj	�dS(Nc_s
t||�S(N(R%(R*R+((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt#http_server_with_basic_auth_handler%sshttp://127.0.0.1:%s(
tsuperR�R�RtserverRt
server_urltstartRtwait(R
R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�"s	
cCs$|jj�tt|�j�dS(N(R�R!R�R�R�(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�,s
cCs�tj�}|j|j|j|j|j�tjtj|��y|j	tj
|j��Wn@tjk
r�|jd|j�nt
k
r�}|�nXdS(NsBasic Auth Failed for url: %s(turllib2tHTTPBasicAuthHandlertadd_passwordR2R�R<R=tinstall_openertbuild_openert
assertTrueturlopent	HTTPErrortfailt	Exception(R
tahte((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_basic_auth_success0s"cCsdtj�}|j|j|j|j|j�tjtj|��|j	tj
tj|j�dS(N(R�R�R�R2R�R<tINCORRECT_PASSWDR�R�tassertRaisesR�R�(R
R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_basic_auth_httperror;s

(
RRR<R=R�R2R�R�R�R�(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�s	
		tProxyAuthTestscBsVeZdZdZdZdZd�Zd�Zd�Zd�Z	d�Z
d	�ZRS(
shttp://localhostttesterttest123t	TestRealmcs�tt��j�t��_�jji�j�j6��jj�j	��fd�}t
|��_�jj��jj
j�d�jj}tji|d6�}tj��_tj|�j��_dS(Ncst�j||�S(N(RyRz(R*R+(R
(ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytcreate_fake_proxy_handlerPsshttp://127.0.0.1:%dR{(R�R�R�RARzRKR=R<RMR2RR�R�RR�RR�tProxyHandlertProxyDigestAuthHandlertproxy_digest_handlerR�topener(R
R�t	proxy_urlthandler((R
ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�Js
cCs$|jj�tt|�j�dS(N(R�R!R�R�R�(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�[s
cCs\|jj|j|j|j|jd�|jjd�|jt	j
|jj|j�dS(NtbadRB(
R�R�R2tURLR<R=RzRIR�R�R�R�topen(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt-test_proxy_with_bad_password_raises_httperror_s	cCs3|jjd�|jtj|jj|j�dS(NRB(RzRIR�R�R�R�R�R�(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt,test_proxy_with_no_password_raises_httperrorgs	cCsk|jj|j|j|j|j�|jjd�|jj	|j�}x|j
�r\qMW|j�dS(NRB(R�R�R2R�R<R=RzRIR�R�treadtclose(R
tresult((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_proxy_qop_auth_worksmscCs�|jj|j|j|j|j�|jjd�y|jj	|j�}Wnt
jk
rjd}nX|r�x|j
�r�qtW|j�ndS(Nsauth-int(R�R�R2R�R<R=RzRIR�R�R�tURLErrorR7R�R�(R
R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt0test_proxy_qop_auth_int_works_or_throws_urlerrorvs
(RRR�R<R=R2R�R�R�R�R�R�(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR�Cs						cs&dtjf��fd��Y��S(NtFakeHTTPRequestHandlercsMeZdZgZgZdZd�Zd�Z��fd�Zd�Z	RS(s	TestHTTP/iPcSs)|j�}|r%|jj|�ndS(N(t	send_headR8R9(R
tbody((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR;�scSsC|jd}|jjt|��}|j�|jj|�dS(NsContent-Length(R5trfileR�tintR;trequestsRR(R
tcontent_lengtht	post_data((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytdo_POST�s

cs�|j�_|jj|j��jd�\}}}|j|�x+|D]#\}}|j|||j�qKW|r�|jdd�|j	�|S|j	�dS(NisContent-types
text/plain(
R5theaders_receivedR�RRRutpopR.R/RR0(R
t
response_codeR5R�theaderRb(R�t	responses(ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR��s

cWsdS(N((R
R*((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR-�s(
RRtserver_versionR�R�RR;R�R�R-((R�R�(ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR��s		(RR)(R�((R�R�ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytGetRequestHandler�s"%tTestUrlopencBs�eZdZd�Zdd�Zd�Zdd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(sGTests urllib2.urlopen using the network.

    These tests are not exhaustive.  Assuming that testing using files does a
    good job overall of some of the basic interface features.  There are no
    tests exercising the optional 'data' and 'proxies' arguments.  No tests
    for transparent redirection have been written.
    cCsBtji�}tj|�}tj|�tt|�j�dS(N(R�R�R�R�R�R�R�(R
t
proxy_handlerR�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR��s
cKs�g}tj|||�}zV|j|jd��|j|j��|j|jd��|j|j��Wd|j�Xdj|�S(Ni�it(	R�R�textendt	readlinesRRtreadlineR�R�R (R
turltdataR+tltf((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR��scCsQt|�}t|�|_|jj�|jjj�|jj}||_|S(N(R�RR�R�RR�R(R
R�R�R((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytstart_server�s
	cKs�ttd�s|jd�nddlm}|dkrPdgdfg}nt|�}||d||�}|j|_|S(NtHTTPSHandlersssl support requiredi����(tmake_https_serveri�s
we care a bitt
handler_class(thasattrR�tskipTestttest.ssl_serversR�R7R�R(R
R�R+R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytstart_https_server�scCs�d}dd
gdfdg|fg}|j|�}zYtjd|j�}|j�}|j�|j||�|j|jdd	g�Wd|jj	�XdS(NsWe got here...i.tLocations"http://localhost:%s/somewhere_elseR�i�shttp://localhost:%s/t/s/somewhere_else(R�s"http://localhost:%s/somewhere_else(
R�R�R�RR�R�tassertEqualR�R�R!(R
texpected_responseR�R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_redirection�s
cCs�d}|jdg|fg�}z~ytjd|j�Wntjk
rT}nX|jd�|j�}|j�|j||�|j|j	dg�Wd|j
j�XdS(NsBad bad bad...i�shttp://localhost:%s/weebles404 should raise URLErrors/weeble(R�R�R�RR�R�R�R�R�R�R�R!(R
R�R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_404�s

cCs�d}|jdg|fg�}zVtjd|j�}|j�}|j�|j||�|j|jdg�Wd|jj	�XdS(Ns
pycon 2008...i�shttp://localhost:%s/bizarres/bizarre(
R�R�R�RR�R�R�R�R�R!(R
R�R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_200s
cCs�d}|jdg|fg�}z\tjd|jd�}|j�}|j�|j||�|j|jddg�Wd|jj	�XdS(Ns
pycon 2008...i�shttp://localhost:%s/bizarresget=with_feelings/bizarre(
R�R�R�RR�R�R�R�R�R!(R
R�R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_200_with_parameterss
cCsN|j�}tjdt�}|jd|jd|�}|j|d�dS(Ntcafileshttps://localhost:%s/bizarretcontexts
we care a bit(R�tssltcreate_default_contexttCERT_localhostR�RR�(R
R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt
test_https'sc	Cs�|jdt�}|jd|jdt�}|j|d�|jtj��|jd|jdt�WdQX|jdt�}|jt	j
��|jd|jdt�WdQXdS(Ntcertfileshttps://localhost:%s/bizarreR�s
we care a bit(R�R�R�RR�R�R�R�tCERT_fakehostnameR�tCertificateError(R
R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_https_with_cafile-s	
cCsI|jdt�}|jtj��|jd|jdt�WdQXdS(NR�shttps://localhost:%s/bizarret	cadefault(R�R�R�R�R�R�RR(R
R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_https_with_cadefault=scs�tdkr|jd�ntjs5|jd�ndg��fd�}tjtj�}|j|�|jd|dt�}tj	dt�}|j
d|jd|�|j�dd	�dS(
Nsssl module requiredsSNI support required in OpenSSLcs|�d<dS(Ni((tssl_socktserver_nametinitial_context(tsni_name(ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytcb_sniJsR�R�R�shttps://localhost:%sit	localhost(
R�R7R�tHAS_SNIt
SSLContexttPROTOCOL_TLSv1tset_servername_callbackR�R�R�R�RR�(R
R�R�R�((R�ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_https_sniDs		
cCs{|jdgdfg�}zKtjd|jdidd6�}tj|�|j|jdd�Wd|jj�XdS(Ni�s
we don't careshttp://localhost:%s/R5sbytes=20-39tRange(	R�R�tRequestRR�R�R�R�R!(R
R�treq((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_sending_headersSs
cCs�|jdgdfg�}zptjd|j�}x+d
D]#}|jt||�d|�q;Wz|j|j�d	�Wd|j�XWd|jj	�XdS(Ni�s
we don't careshttp://localhost:%sR�R�tinfotgeturls3object returned from urlopen lacks the %s attributescalling 'read' failed(sreadsclosesinfosgeturl(
R�R�R�RR�R�R�R�R�R!(R
R�topen_urltattr((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt
test_basic^s
cCs�|jdgdfg�}zRtjd|j�}|j�}|j|tjd�|j|j	�d�Wd|j
j�XdS(Ni�s
we don't careshttp://localhost:%ssAobject returned by 'info' is not an instance of mimetools.Messagetplain(R�R�R�RR�tassertIsInstanceRtMessageR�t
getsubtypeR�R!(R
R�R�tinfo_obj((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt	test_infomscCsm|jdgdfg�}z=tjd|j�}|j�}|j|d|j�Wd|jj�XdS(Ni�s
we don't careshttp://localhost:%s(R�R�R�RR�R�R�R!(R
R�R�R�((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_geturlzscCs'tjd�|jttjd�dS(Ntnetworkshttp://sadflkjsasf.i.nvali.d./(RtrequiresR�tIOErrorR�R�(R
((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_bad_address�s
	cCsqd}|jdg|fg�}z;tjd|j�}x|D]}|j||�qAWWd|jj�XdS(Ns
pycon 2008...i�shttp://localhost:%s(R�R�R�RR�R�R!(R
R�R�R�tline((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyttest_iteration�s
c	Cs�ddddddg}dj|�}|jdg|fg�}zktjd	|j�}xNt|�D]@\}}|j|||d
|t||�t|�f�qjWWd|jj	�X|j|dt|��dS(NsWe
sgot
shere
s	verylong i s
R�i�shttp://localhost:%ssQFetched line number %s doesn't match expected:
    Expected length was %s, got %si(
R R�R�R�Rt	enumerateR�RrR�R!(R
tlinesR�R�R�tindexR((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pytztest_line_iteration�s)N(RRRR�R7R�R�R�R�R�R�R�R�R�R�R�R�RRRRR
R(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyR��s(	
	
											
			
cCstjttt�dS(N(Rtrun_unittestR�R�R�(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt	test_main�st__main__('tosR?R}R�RtunittestRNttestRt
import_moduleRRRR�tImportErrorR7Rutdirnamet__file__thereR R�R�RRRRR)R%RARytTestCaseR�R�R�R�R�RR(((ss/builddir/build/BUILDROOT/imh-python-2.7.12-1.el7.x86_64/opt/imh-python/lib/python2.7/test/test_urllib2_localnet.pyt<module>s<

'z 'D	*�