%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_wsgiref.pyc


Nac@sddlmZddlmZddlmZddlmZmZddl	m
Z
ddlmZddl
mZmZddl
mZdd	lmZdd
lmZddlZddlZddlZddlmZd
efdYZdefdYZdZeddZdZdefdYZdefdYZdefdYZ defdYZ!de!fdYZ"defd YZ#d!Z$e%d"kre$ndS(#i(tTestCase(tsetup_testing_defaults(tHeaders(tBaseHandlertBaseCGIHandler(tutil(t	validator(t
WSGIServertWSGIRequestHandler(tmake_server(tStringIO(t
BaseServerN(tsupportt
MockServercBs eZdZdZdZRS(sNon-socket HTTP servercCs!tj||||jdS(N(Rt__init__tserver_bind(tselftserver_addresstRequestHandlerClass((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRscCs/|j\}}||_||_|jdS(N(Rtserver_nametserver_portt
setup_environ(Rthosttport((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRs		(t__name__t
__module__t__doc__RR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR
s	tMockHandlercBs eZdZdZdZRS(sNon-socket HTTP handlercCs%|j|_|j\|_|_dS(N(trequestt
connectiontrfiletwfile(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pytsetup"scCsdS(N((R((s-/usr/local/lib/python2.7/test/test_wsgiref.pytfinish&s(RRRR R!(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR s	cCs|dddgdgS(	Ns200 OKsContent-Types
text/plaintDatesMon, 05 Jun 2006 18:49:54 GMTs
Hello, world!(sContent-Types
text/plain(R"sMon, 05 Jun 2006 18:49:54 GMT((tenvirontstart_response((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt	hello_app*s
sGET / HTTP/1.0

cCstdd|tt}t|tttjf\}}}}|t_z|j||fdWd|t_X|j|jfS(NtiPs	127.0.0.1i"(s	127.0.0.1i"(R	R
RR
tsyststderrtfinish_requesttgetvalue(tapptdatatservertinptoutterrtolderr((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt	run_amock1s-	
cCs|}d}x1|D])}|||ks5tn|d7}qWy||Wntk
rbnXtd|yttfWntk
rnX|}t||k	rtnx)|D]!}|j|kstqqWy|jWntk
rnXtd|dS(sUtility to compare a generic 2.1/2.2+ iterator with an iterable

    If running under Python 2.2+, this tests the iterator using iter()/next(),
    as well as __getitem__.  'make_it' must be a function returning a fresh
    iterator to be tested (since this may test the iterator twice).iisToo many items from __getitem__sToo many items from .next()N(tAssertionErrort
IndexErrortitert
StopIterationt	NameErrortnext(tmake_ittmatchtittntitem((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcompare_generic_iter>s4	
	

		


tIntegrationTestscBs8eZedZdZdZdZdZRS(cCs=|j|dtjjdd|r-dp0dddS(Ns/HTTP/1.0 200 OK
Server: WSGIServer/0.1 Python/isA
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
sContent-Length: 13
R&s
Hello, world!(tassertEqualR'tversiontsplit(RR/t
has_length((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheck_helloes	(cCs t\}}|j|dS(N(R2RD(RR/R0((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttest_plain_hellopscCs?tddddd\}}|j|jdddS(NR,sGET txis HTTP/1.0

is!HTTP/1.0 414 Request-URI Too Long(R2R@t
splitlines(RR/R0((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttest_request_lengthts!cCs/ttt\}}|j|dtdS(NRC(R2RR%RDtFalse(RR/R0((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttest_validated_helloyscCsUd}tt|\}}|j|jd|j|jdddS(NcSs|dddgS(Ns200 OKsContent-Types
text/plains
Hello, world!(sContent-Types
text/plain((R#R$((s-/usr/local/lib/python2.7/test/test_wsgiref.pytbad_apps
s;A server error occurred.  Please contact the administrator.is]AssertionError: Headers (('Content-Type', 'text/plain')) must be of type list: <type 'tuple'>(R2Rt
assertTruetendswithR@RG(RRKR/R0((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttest_simple_validation_error~s	

(RRtTrueRDRERHRJRN(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR?cs
			tUtilityTestscBseZdZddZdZdZddZdZdZ	dZ
d	Zd
ZdZ
dZd
ZdZdZRS(cCsfi|d6|d6}tj||jtj|||j|d||j|d||S(NtSCRIPT_NAMEt	PATH_INFO(RRR@tshift_path_info(Rtsn_intpi_intparttsn_outtpi_outtenv((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt
checkShifts
cCsi}tj|t|tr9|j||tn|j|||i||6}tj||j|||dS(N(RRt
isinstanceR
tassertIsInstanceR@tassertIs(RtkeytvaluetaltRY((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheckDefaults


cKs%tj||j|||dS(N(RRR@(RR^R_tkw((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheckCrossDefaults
cKs*tj||jtj||dS(N(RRR@tapplication_uri(RturiRb((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheckAppURIs
icKs-tj||jtj|||dS(N(RRR@trequest_uri(RRetqueryRb((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheckReqURIs
cCs}||d}t|||}|j|jjx|D]}q?W|j|jj|j|j|jjdS(NcSstjt||S(N(RtFileWrapperR
(ttexttsize((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR9s(R>tassertFalsetfileliketclosedtcloseRL(RRkRlR:R9R;R=((s-/usr/local/lib/python2.7/test/test_wsgiref.pytcheckFWs
	

cCs|jddddd|jddddd|jddddd|jddddd|jdd	ddddS(
NR&t/s/xRFs/as/x/ys/a/xs/ys/x/(RZtNone(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestSimpleShiftss
cCs|jddddd|jddddd|jdddd	d|jdd
dd	d|jdddd	d|jdd
dd	d|jddddd|jddddd|jddddd|jddddd|jddddddS(Ns/a/bs/../ys..s/as/yR&s//ytys/a/b/ys//y/Rrs/./ys/./y/s///./..//y/.//s/y/s///s/a/b/s/.//s/x//RFs/a/b/xs/.(RZRs(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestNormalizedShiftsscCspxidddddddddfd d!d"dtdfdtfd#gD]\}}|j||qLWdS($NtSERVER_NAMEs	127.0.0.1tSERVER_PORTt80tSERVER_PROTOCOLsHTTP/1.0t	HTTP_HOSTtREQUEST_METHODtGETRQR&RRRrswsgi.versioniis
wsgi.run_onceswsgi.multithreadswsgi.multiprocesss
wsgi.inputswsgi.errorsswsgi.url_schemethttp(Rws	127.0.0.1(RxRy(RzsHTTP/1.0(R{s	127.0.0.1(R|R}(RQR&(RRRr(ii(s
wsgi.run_oncei(swsgi.multithreadi(swsgi.multiprocessi(swsgi.url_schemeR~(R
Ra(RR^R_((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestDefaultss 	cCs|jdddd|jdddd|jdddd|jdddd	|jdd
dd|jdd
dd|jdddddS(NR{sfoo.barRwswsgi.url_schemethttpstHTTPStont1tyesR~tfooRxRyt443(Rc(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestCrossDefaultsscCs|jtjid|jtjidd6d|jtjidd6d|jtjidd6d|jtjidd6ddS(NR~RRRRRR(R@Rtguess_scheme(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestGuessSchemes
   cCs|jd|jddd|jddd|jddd	d
d|jdd
d|jdddd
d|jddd|jdd
ddddS(Nshttp://127.0.0.1/shttp://127.0.0.1/spamRQs/spamshttp://127.0.0.1/sp%E4ms/spmshttp://spam.example.com:2071/R{sspam.example.com:2071Rxt2071shttp://spam.example.com/Rwsspam.example.coms	127.0.0.1shttps://127.0.0.1/RRshttp://127.0.0.1:8000/t8000(RfRs(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestAppURIss


c	Cs|jd|jddd|jddd|jdddd	d|jd
ddd	d|jdddd	d|jd
ddd	d|jdddd	ddd|jdddd	ddd|jddddd	ddddS(Nshttp://127.0.0.1/shttp://127.0.0.1/spamRQs/spamshttp://127.0.0.1/sp%E4ms/spmshttp://127.0.0.1/spammity/spams	/spammityRRs http://127.0.0.1/spammity/sp%E4ms"http://127.0.0.1/spammity/spam;hams	/spam;hams/http://127.0.0.1/spammity/spam;cookie=1234,5678s/spam;cookie=1234,5678s%http://127.0.0.1/spammity/spam?say=nitQUERY_STRINGssay=nis'http://127.0.0.1/spammity/spam?s%E4y=niss%E4y=nii(Ri(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestReqURIss"




cCs)|jdddddddgdS(Ntxyzi2ixi(i
(Rq(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestFileWrapperscCsxYdjD]K}xB||j|j|jfD]}|jtj|q8Wq
WxYdjD]K}xB||j|j|jfD]}|jtj|qWqiWdS(NsbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgrades4Accept Cache-Control Date Pragma Trailer Via Warning(RBttitletuppertlowerRLRt
is_hop_by_hopRm(RthopR`((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestHopByHops++N(RRRZRsRaRcRfRiRqRtRvRRRRRRR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRPs						
							tHeaderTestscBs#eZdZdZdZRS(cCs=dg}|jttgd|jtt|d|jt|jdg|jt|jdg|jt|j||jt|j|tg}|d=d|d<xx|j|j|j	|j
|jfD]R}|j|d|j|d|j|d|j
|dqW|j|ddd	|d<|j|dd	|j|j
dd	g|j|j	dd
d	|j|j	dd
d
|j|jdd
d	|j|jdd
d
|j|dd	|j|dd
dS(
NRFRuiiRtbartFootFOOtbaztwheetzoo(RFRu(R@tlenRtkeystvaluestitemstassertIsNotthas_keyt__contains__tgettget_allt__getitem__RLRmt
setdefault(Rttestthtm((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestMappingInterface/s2	  
+
cCs|jttddS(NR(tassertRaisest	TypeErrorR(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestRequireListNscCstg}|jt|d|jdddd|j|dd|jt|d|jddd	d|j|jddd
g|jt|ddS(Ns
RRRtspamsbar; baz="spam"sfoo: bar; baz="spam"

Rtcheesesbar; cheeses*foo: bar; baz="spam"
Foo: bar; cheese

(RR@tstrt
add_headerRsR(RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt
testExtrasRs
(RRRRR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR-s		tErrorHandlercBs,eZdZeejjZdZRS(s/Simple handler subclass for testing BaseHandlerc
Ks?t|tj|tdtt|dtdtdS(NR&tmultithreadtmultiprocess(RRRR
RO(RRb((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRms
(	RRRtdicttosR#Rt
os_environR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRestTestHandlercBseZdZdZRS(sASimple handler subclass for testing BaseHandler, w/error passthrucCsdS(N((R((s-/usr/local/lib/python2.7/test/test_wsgiref.pythandle_errorws(RRRR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRtstHandlerTestscBs_eZdZdZdZdZdZdZdZdZ	d	Z
d
ZRS(iPi2c	Csjidd6dd6dd6dd6d	d
6}tjtd|$tdd
dd}|jWdQXx6d#D].}|jt|d||jd|qkWi}t|x3|jD]%\}}||kr|||<qqW|j	id
d6dd6dd6dd
6|j
d6|jd6d$d6td6dd6t
d 6t
d!6tjd"6|j|j|dS(%Ns/my/hometHOMEs/my/pathtPATHsfr_FR.UTF-8tLANGttest_script_nameRQttest_server_nameRwRtXtYs/override/homeRARRtrun_oncetfile_wrappertwsgi_swsgi.R&s	127.0.0.1s
wsgi.inputswsgi.errorsiiswsgi.versions
wsgi.run_onceR~swsgi.url_schemeswsgi.multithreadswsgi.multiprocessswsgi.file_wrapper(RARRRR(ii(Rt	swap_attrRRR@tgetattrR#RRtupdatet	get_stdint
get_stderrRIRORRjtassertDictEqual(RRthandlertattrtexpectedR^R_((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestEnvirons@


	

cCsGtdddi}|jx!dD]}|j||jq&WdS(Nswsgi.url_schemes
wsgi.inputswsgi.errors(swsgi.url_schemes
wsgi.inputswsgi.errors(RRsRtassertInR#(RRR^((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestCGIEnvirons

cCs^tdd}|j|j|jddt}|j|j|jdddS(NRRswsgi.url_schemeRR~(RRR@R#(RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt
testSchemes
	
cCsYt}x3ddddgD]}|jtt||qW|jt|jddS(Nt_flushRRtadd_cgi_varsR(RRtNotImplementedErrorRt_write(RRtname((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestAbstractMethodss
	cCsd}d}d}t}|j||j|jjdt}|j||j|jjdt}|j||j|jjddS(NcSs|dg|dgS(Ns200 OKswsgi.url_scheme((tets((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttrivial_app1s
cSs|dg|dgS(Ns200 OKswsgi.url_scheme((RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttrivial_app2scSs|ddggS(Ns200 OKsContent-Lengtht12345(sContent-LengthR((RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttrivial_app4ss)Status: 200 OK
Content-Length: 4

httpsStatus: 200 OK

https)Status: 200 OK
Content-Length: 12345

(RtrunR@tstdoutR*(RRRRR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestContentLengths				
	
	
cCsd}d}t}|j||j|jjd|j|jjdt}|j||j|jjd|jt|j|jf|j	|jjj
dddS(NcSs|dggS(Ns200 OK((RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt
non_error_apps
cSstddS(Ns This should be caught by handler(R3(RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt	error_appss%Status: 200 OK
Content-Length: 0

R&s>Status: %s
Content-Type: text/plain
Content-Length: %d

%sR3i(RRR@RR*R(terror_statusRt
error_bodytassertNotEqualtfind(RRRR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestBasicErrorOutputs			
	
 csndfd}t}|j||j|jjd|j|jjjdddS(NsSome output has been sentcs#|dgtddS(Ns200 OKs This should be caught by handler(R3(RR(tMSG(s-/usr/local/lib/python2.7/test/test_wsgiref.pyR
ssStatus: 200 OK

R3i(RRR@RR*RR(R(RRR((Rs-/usr/local/lib/python2.7/test/test_wsgiref.pyttestErrorAfterOutputs	
c	CsYd}d}d}x=d
D]5}|r2d|p5d}xdD]}xdD]}td|}t|_||_||_|j||j||jj	td|}t
|_||_||_|j||d	kr|j|jj	dqL|jtj
|||f|jj	|||f|jj	fqLWq?WqWdS(NcSs|dggS(Ns200 OK((RR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyRs
sfHTTP/%s 200 OK\r\nDate: \w{3}, [ 0123]\d \w{3} \d{4} \d\d:\d\d:\d\d GMT\r\n%sContent-Length: 0\r\n\r\ns%Status: 200 OK
Content-Length: 0

s
FooBar/1.0sServer: %s
R&s1.0s1.1sHTTP/0.9sHTTP/1.0sHTTP/1.1Rz(s
FooBar/1.0N(s1.0s1.1(sHTTP/0.9sHTTP/1.0sHTTP/1.1(RsRRIt
origin_serverthttp_versiontserver_softwareRR@RR*RORLtreR:(	RRtstdpattshortpattsswtswRAtprotoR((s-/usr/local/lib/python2.7/test/test_wsgiref.pyttestHeaderFormatss.	


			
			
"csSitd6dfd}t}|j||jdtdS(Ntclose_calledsSome output has been sentcs6|dgdtffdY}|S(Ns200 OKtCrashyIterablecs eZdZfdZRS(css"xtrdVtdqWdS(Ntblahs This should be caught by handler(ROR3(R((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt__iter__Gs	cstd<dS(NR(RO(R(tside_effects(s-/usr/local/lib/python2.7/test/test_wsgiref.pyRpLs(RRRRp((R(s-/usr/local/lib/python2.7/test/test_wsgiref.pyRFs	(tobject(RRR(RR(s-/usr/local/lib/python2.7/test/test_wsgiref.pyRDs(RIRRR@RO(RRR((RRs-/usr/local/lib/python2.7/test/test_wsgiref.pyttestCloseOnErrorAs
	
i(RRtmaxDiffRRRRRRRRR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyR{s	6				'		
	)cCstjtdS(N(Rtrun_unittestR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt	test_mainUst__main__(&tunittestRtwsgiref.utilRtwsgiref.headersRtwsgiref.handlersRRtwsgirefRtwsgiref.validateRtwsgiref.simple_serverRRR	R
tSocketServerRRRR'RRR
RR%R2R>R?RPRRRRRR(((s-/usr/local/lib/python2.7/test/test_wsgiref.pyt<module>s6
	
	%*8	

Zerion Mini Shell 1.0