Your IP : 216.73.216.52


Current Path : /opt/alt/python36/lib64/python3.6/test/__pycache__/
Upload File :
Current File : //opt/alt/python36/lib64/python3.6/test/__pycache__/test_wsgiref.cpython-36.opt-2.pyc

3

��2aWl�@s�ddlmZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
mZddlmZdd	lmZdd
lmZmZddlmZddlmZdd
lmZmZmZddlmZddlm Z ddl!Z!ddl"Z"ddl#Z#ddl$Z$ddlZGdd�de�Z%Gdd�de�Z&dd�Z'dd�Z(e'dfdd�Z)dd�Z*Gdd�de�Z+Gd d!�d!e�Z,Gd"d#�d#e�Z-Gd$d%�d%e
�Z.Gd&d'�d'e.�Z/Gd(d)�d)e�Z0e1d*k�r�ej2�dS)+�)�mock)�support)�NoLogRequestHandler)�TestCase)�setup_testing_defaults)�Headers)�BaseHandler�BaseCGIHandler�
SimpleHandler)�util)�	validator)�
WSGIServer�WSGIRequestHandler)�make_server)�HTTPConnection)�StringIO�BytesIO�BufferedReader)�
BaseServer)�python_implementationNc@seZdZdd�Zdd�ZdS)�
MockServercCstj|||�|j�dS)N)r�__init__�server_bind)�self�server_addressZRequestHandlerClass�r�1/opt/alt/python36/lib64/python3.6/test_wsgiref.pyrszMockServer.__init__cCs"|j\}}||_||_|j�dS)N)rZserver_nameZserver_port�
setup_environ)r�hostZportrrrrs
zMockServer.server_bindN)�__name__�
__module__�__qualname__rrrrrrrsrc@seZdZdd�Zdd�ZdS)�MockHandlercCs|j|_|j\|_|_dS)N)�requestZ
connectionZrfileZwfile)rrrr�setup(szMockHandler.setupcCsdS)Nr)rrrr�finish,szMockHandler.finishN)rr r!r$r%rrrrr"&sr"cCs|dddg�dgS)	Nz200 OK�Content-Type�
text/plain�Date�Mon, 05 Jun 2006 18:49:54 GMTs
Hello, world!)r&r')r(r)r)�environ�start_responserrr�	hello_app0sr,cCs2|dddg�dj|d|d|d	g�jd
�gS)
Nz200 OK�Content-Type�
text/plainr(�Mon, 05 Jun 2006 18:49:54 GMT�;ZHTTP_X_TEST_HEADER�QUERY_STRING�	PATH_INFOz
iso-8859-1)r-r.)r(r/)�join�encode)r*r+rrr�
header_app8sr5sGET / HTTP/1.0

cCsbtdd|tt�}tt|��}t�}tj}t�}t_z|j||fd�Wd|t_X|j	�|j	�fS)N��P�	127.0.0.1�")r8r9)
rrr"rr�sys�stderrrZfinish_request�getvalue)�app�data�serverZinp�outZolderr�errrrr�	run_amockCsrBcCs�|�}d}x$|D]}|||ks$t�|d7}qWy||Wntk
rPYnXtd|��yttfWntk
r|YnbX|�}t|�|k	r�t�x|D]}t|�|ks�t�q�Wyt|�Wntk
r�YnXtd|��dS)Nr�zToo many items from __getitem__zToo many items from .__next__())�AssertionError�
IndexError�iter�
StopIteration�	NameError�next)�make_it�match�it�n�itemrrr�compare_generic_iterQs4


rOc@sfeZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�IntegrationTestsTcCsFt�dtjj�d}|j|d|d|r0dp2ddjd��dS)	N�/rz(HTTP/1.0 200 OK
Server: WSGIServer/0.2 zA
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
zContent-Length: 13
r6z
Hello, world!z
iso-8859-1)rr:�version�split�assertEqualr4)rr@�
has_length�pyverrrr�check_helloxszIntegrationTests.check_hellocCst�\}}|j|�dS)N)rBrW)rr@rArrr�test_plain_hello�s
z!IntegrationTests.test_plain_hellocCs*d}tt|�\}}|j|j�dd�dS)NsmGET /p%61th/?query=test HTTP/1.0
X-Test-Header: Python test 
X-Test-Header: Python test 2
Content-Length: 0

rCs+Python test,Python test 2;query=test;/path/���)rBr5rT�
splitlines)rr#r@rArrr�test_environ�s

zIntegrationTests.test_environcCs2tddddd�\}}|j|j�dd�dS)NsGET �xis HTTP/1.0

)r>rs!HTTP/1.0 414 Request-URI Too Long)rBrTrZ)rr@rArrr�test_request_length�sz$IntegrationTests.test_request_lengthcCs"ttt��\}}|j|dd�dS)NF)rU)rBrr,rW)rr@rArrr�test_validated_hello�sz%IntegrationTests.test_validated_hellocCs@dd�}tt|��\}}|j|jd��|j|j�dd�dS)NcSs|dd�dgS)Nz200 OK�Content-Type�
text/plainz
Hello, world!)r_r`r)r*r+rrr�bad_app�s
z>IntegrationTests.test_simple_validation_error.<locals>.bad_apps;A server error occurred.  Please contact the administrator.�z^AssertionError: Headers (('Content-Type', 'text/plain')) must be of type list: <class 'tuple'>���)rBr�
assertTrue�endswithrTrZ)rrar@rArrr�test_simple_validation_error�s
z-IntegrationTests.test_simple_validation_errorcCstdd�}dd
dg}x\|D]T\}}|j|d	��:t||��\}}|j|jd
��|j|j�d|�WdQRXqWdS)Ncs�fdd�}|S)Ncs|�dg�dgS)N�Content-Type�text/plain; charset=utf-8s
Hello, world!)rgrhr)r*r+)�statusrrra�szWIntegrationTests.test_status_validation_errors.<locals>.create_bad_app.<locals>.bad_appr)rirar)rir�create_bad_app�szFIntegrationTests.test_status_validation_errors.<locals>.create_bad_app�200�4AssertionError: Status must be at least 4 characters�20X OK�8AssertionError: Status message must begin w/3-digit code�200OK�;AssertionError: Status message must have a space after code)ris;A server error occurred.  Please contact the administrator.rb)rkrl)rmrn)rorprc)ZsubTestrBrdrerTrZ)rrjZtestsriZexc_messager@rArrr�test_status_validation_errors�sz.IntegrationTests.test_status_validation_errorscCs@dd�}tt|��\}}|j|jd��|j|j�dd�dS)NcSs|dj�|ddg�dgS)Nz
wsgi.inputz200 OK�Content-Type�text/plain; charset=utf-8sdata)rrrs)�read)�e�srrrra�sz1IntegrationTests.test_wsgi_input.<locals>.bad_apps;A server error occurred.  Please contact the administrator.rbrDrc)rBrrdrerTrZ)rrar@rArrr�test_wsgi_input�sz IntegrationTests.test_wsgi_inputcCsldd�}tt|��\}}|j|jd��tjj�djd�}t�jd�}|d|}|j	d|d|�dS)	NcSs|dddg�dgS)	Nz200 OK�Content-Type�text/plain; charset=utf-8r(�Wed, 24 Dec 2008 13:29:32 GMTsdata)rxry)r(rzr)rurvrrrr=�sz3IntegrationTests.test_bytes_validation.<locals>.appz"GET / HTTP/1.0" 200 4
r�ascii�/s(HTTP/1.0 200 OK
Server: WSGIServer/0.2 sV
Content-Type: text/plain; charset=utf-8
Date: Wed, 24 Dec 2008 13:29:32 GMT

data)
rBrrdrer:rRrSr4rrT)rr=r@rAZver�pyrVrrr�test_bytes_validation�s
z&IntegrationTests.test_bytes_validationcCs>dd�}tt|�dd�\}}|jdtjdddd	g|j��dS)
NcSs|ddd	g�|djd�gS)
Nz200 OK�Content-Type�
text/plainr(�Wed, 24 Dec 2008 13:29:32 GMTr2�latin1)rr�)r(r�)r4)rurvrrrr=�sz-IntegrationTests.test_cp1252_url.<locals>.appsGET /�%80 HTTP/1.0)r>sHTTP/1.0 200 OKsContent-Type: text/plains#Date: Wed, 24 Dec 2008 13:29:32 GMT�s/��)rBrrTr�ANYrZ)rr=r@rArrr�test_cp1252_url�s	z IntegrationTests.test_cp1252_urlcs�tjd�}tjtd��dd�}Gdd�dtt�}ttjd||d��|j�j	�|j
���fd	d
�}tjtj|�}|jtjtj|�d�|j�������fdd�}|j
|d
�}|j��j�|j�|j�tjd�dS)N�	threading�pthread_killcSs|dg�dtjgS)Nz200 OK�)r�
SOCK_MAX_SIZE)r*r+rrrr=s
z4IntegrationTests.test_interrupted_write.<locals>.appc@seZdZdS)z<IntegrationTests.test_interrupted_write.<locals>.WsgiHandlerN)rr r!rrrr�WsgiHandlersr�r)Z
handler_classcs�j�dS)N)�set)Zsignum�frame)�interruptedrr�signal_handlersz?IntegrationTests.test_interrupted_write.<locals>.signal_handlerc
spt�j�}|jdd�|j��@}|jd�x"��tj��jtd�d�r,Pq,Wt	|j���WdQRX|j
�dS)N�GETrQ�drC)Ztimeout)rrr#Zgetresponsert�signal�SIGUSR1�wait�float�len�close)�httpZresponse)r��main_threadr��receivedr?rr�
run_clients


z;IntegrationTests.test_interrupted_write.<locals>.run_client)�targetr�)r�
import_moduleZ
get_attributer�rrrZHOSTZ
addCleanupZserver_closeZEventr��	get_identZThread�startZhandle_requestr3rTr�)rr�r=r�r�Zoriginalr�Z
backgroundr)r�r�r�r�r?r�test_interrupted_write�s$
z'IntegrationTests.test_interrupted_writeN)T)rr r!rWrXr[r]r^rfrqrwr~r�r�rrrrrPvs



rPc@s�eZdZdd�Zd!dd�Zdd�Zdd	�Zd"dd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �ZdS)#�UtilityTestscCsJ||d�}tj|�|jtj|�|�|j|d|�|j|d|�|S)N)�SCRIPT_NAMEr2r2r�)rrrTZshift_path_info)rZsn_inZpi_in�partZsn_outZpi_out�envrrr�
checkShift1s

zUtilityTests.checkShiftNcCs|i}tj|�t|t�r*|j||t�n,t|t�rF|j||t�n|j|||�||i}tj|�|j|||�dS)N)rr�
isinstancerZassertIsInstancerrTZassertIs)r�key�value�altr�rrr�checkDefault9s



zUtilityTests.checkDefaultcKstj|�|j|||�dS)N)rrrT)rr�r��kwrrr�checkCrossDefaultIs
zUtilityTests.checkCrossDefaultcKs tj|�|jtj|�|�dS)N)rrrTZapplication_uri)r�urir�rrr�checkAppURIMs
zUtilityTests.checkAppURIrCcKs"tj|�|jtj||�|�dS)N)rrrTZrequest_uri)rr�Zqueryr�rrr�checkReqURIQs
zUtilityTests.checkReqURIcCsb||fdd�}t||�|�}|j|jj�x|D]}q2W|j|jj�|j�|j|jj�dS)NcSstjt|�|�S)N)rZFileWrapperr)�text�sizerrrrJWsz%UtilityTests.checkFW.<locals>.make_it)rO�assertFalseZfilelike�closedr�rd)rr�r�rKrJrLrNrrr�checkFWUs

zUtilityTests.checkFWcCs^|jddddd�|jddddd�|jddddd�|jddddd�|jdd	ddd�dS)
Nr6rQz/x�xz/az/x/yz/a/xz/yz/x/)r�)rrrr�testSimpleShiftsgs
zUtilityTests.testSimpleShiftscCs�|jddddd�|jddddd�|jdddd	d�|jdd
dd	d�|jdddd	d�|jdd
dd	d�|jddddd�|jddddd�|jddddd�|jddddd�|jddddd�dS)Nz/a/bz/../yz..z/az/yr6z//y�yz/a/b/yz//y/rQz/./yz/./y/z///./..//y/.//z/y/z///z/a/b/z/.//z/x//r�z/a/b/xz/.)r�)rrrr�testNormalizedShiftsnsz!UtilityTests.testNormalizedShiftscCsJxDdddddddd d!d"d#dt�fdt�fd$gD]\}}|j||�q.WdS)%N�SERVER_NAME�	127.0.0.1�SERVER_PORT�80�SERVER_PROTOCOL�HTTP/1.0�	HTTP_HOST�REQUEST_METHODr�r�r6r2rQ�wsgi.versionrCr�
wsgi.run_once�wsgi.multithread�wsgi.multiprocessz
wsgi.inputzwsgi.errors�wsgi.url_schemer�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r6)r2rQ�rCr)r�r�)r�r)r�r)r�r)r�r�)rrr�)rr�r�rrr�testDefaults{s zUtilityTests.testDefaultscCst|jdddd�|jdddd�|jdddd�|jddd	d�|jdd
dd�|jdd
dd�|jdddd�dS)Nr�zfoo.bar)r�zwsgi.url_scheme�https�on)�HTTPS�1�yesr��foor�r�Z443)r�)rrrr�testCrossDefaults�szUtilityTests.testCrossDefaultscCsn|jtji�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�dS)Nr�r�r�r�r�r�r�)rTrZguess_scheme)rrrr�testGuessScheme�s
zUtilityTests.testGuessSchemecCsv|jd�|jddd�|jddd�|jddd	d
�|jddd
�|jdddd�|jddd�|jdddd�dS)Nzhttp://127.0.0.1/zhttp://127.0.0.1/spamz/spam)r�zhttp://127.0.0.1/sp%E4mu/spämzhttp://spam.example.com:2071/zspam.example.com:2071Z2071)r�r�zhttp://spam.example.com/zspam.example.com)r�z	127.0.0.1)r�r�zhttps://127.0.0.1/r�)r�zhttp://127.0.0.1:8000/Z8000)r�r�)r�)rrrr�testAppURIs�s


zUtilityTests.testAppURIscCs�|jd�|jddd�|jddd�|jdddd	�|jd
ddd	�|jdddd	�|jd
ddd	�|jddddd�|jddddd�|jdddddd�dS)Nzhttp://127.0.0.1/zhttp://127.0.0.1/spamz/spam)r�zhttp://127.0.0.1/sp%E4mu/spämzhttp://127.0.0.1/spammity/spamz	/spammity)r�r2z http://127.0.0.1/spammity/sp%E4mz"http://127.0.0.1/spammity/spam;hamz	/spam;hamz/http://127.0.0.1/spammity/spam;cookie=1234,5678z/spam;cookie=1234,5678z%http://127.0.0.1/spammity/spam?say=nizsay=ni)r�r2r1z'http://127.0.0.1/spammity/spam?s%E4y=nizs%E4y=nir)r�)rrrr�testReqURIs�s"




zUtilityTests.testReqURIscCs"|jdddddddg�dS)NZxyz�2�x�(�
)r�)rrrr�testFileWrapper�szUtilityTests.testFileWrappercCs�xBdj�D]6}x0||j�|j�|j�fD]}|jtj|��q(Wq
WxBdj�D]6}x0||j�|j�|j�fD]}|jtj|��qlWqNWdS)NzbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgradez4Accept Cache-Control Date Pragma Trailer Via Warning)rS�title�upper�lowerrdrZ
is_hop_by_hopr�)rZhopr�rrr�testHopByHop�szUtilityTests.testHopByHop)N)rC)rr r!r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�/s


	r�c@s$eZdZdd�Zdd�Zdd�ZdS)�HeaderTestscCs�dg}|jtt��d�|jttg��d�|jtt|dd���d�|jt|dd��j�dg�|jt|dd��j�dg�|jt|dd��j�|�|jt|�j�|�t�}|d=d|d<xT|j|j|j	|j
fD]<}|j|d��|j|d��|j|d��|j|d��q�W|j|dd�d	|d<|j|dd	�|j|j	d�d	g�|j|jdd
�d	�|j|jdd
�d
�|j|j
dd
�d	�|j|j
dd
�d
�|j|dd	�|j|dd
�dS)
Nr�r�rrCr��bar�FooZFOO�bazZwheeZzoo)r�r�)rTr�r�keys�values�itemsZassertIsNot�__contains__�get�get_all�__getitem__rdr��
setdefault)r�test�h�mrrr�testMappingInterface�s4z HeaderTests.testMappingInterfacecCs|jttd�dS)Nr�)�assertRaises�	TypeErrorr)rrrr�testRequireList�szHeaderTests.testRequireListcCs�t�}|jt|�d�|jdddd�|j|dd�|jt|�d�|jdddd	�|j|jd�dd
g�|jt|�d�dS)Nz
r�r�Zspam)r�zbar; baz="spam"zfoo: bar; baz="spam"

r�)Zcheesezbar; cheesez*foo: bar; baz="spam"
Foo: bar; cheese

)rrT�strZ
add_headerr�)rr�rrr�
testExtras�s

zHeaderTests.testExtrasN)rr r!r�r�r�rrrrr��s r�c@s"eZdZeejj��Zdd�ZdS)�ErrorHandlerc	Ks*t|�tj|t�t�t�|ddd�dS)NT)�multithread�multiprocess)rr	rrr)rr�rrrrszErrorHandler.__init__N)	rr r!�dict�osr*r�Z
os_environrrrrrr�sr�c@seZdZdd�ZdS)�TestHandlercCs�dS)Nr)rrrr�handle_errorszTestHandler.handle_errorN)rr r!r�rrrrr�sr�c@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�HandlerTestscCsJ|j}x>dD]6}|dkr$|jdkr$q|jt|d|�|d|�qWdS)	NrRr�r��run_once�file_wrapperZwsgi_zwsgi.)rRr�r�r�r�)r*Zwsgi_file_wrapperrT�getattr)r�handlerr��attrrrr�checkEnvironAttrs szHandlerTests.checkEnvironAttrscCsri}t|�|j}ddlm}x,|j�D] \}}||kr(|j|||�q(Wx |j�D]\}}|j||�qVWdS)Nr)r*)rr*r�r�rT�assertIn)rr��emptyr�r*�k�vrrr�checkOSEnviron)szHandlerTests.checkOSEnvironcCs<tdd�}|j�|j|�|j|�|j|jdd�dS)N�Y)�Xr)r�rr�rrTr*)rr�rrr�testEnviron3s



zHandlerTests.testEnvironcCs6tdddi�}|j�xdD]}|j||j�qWdS)N�wsgi.url_scheme�
wsgi.input�wsgi.errors)rrr)r	rr�r*)rr�r�rrr�testCGIEnviron:s
zHandlerTests.testCGIEnvironcCsHtdd�}|j�|j|jdd�t�}|j�|j|jdd�dS)Nr�)r�zwsgi.url_schemer�r�)r�rrTr*)rr�rrr�
testScheme@s
zHandlerTests.testSchemecCs:t�}xdD]}|jtt||��qW|jt|jd�dS)N�_flush�	get_stdin�
get_stderr�add_cgi_varsr�)r
rrr
)rr��NotImplementedErrorr�Z_write)rr��namerrr�testAbstractMethodsFs
z HandlerTests.testAbstractMethodscCs�dd�}dd�}dd�}dd�}t�}|j|�|j|jj�d	jd
��t�}|j|�|j|jj�djd
��t�}|j|�|j|jj�d�t�}|j|�|j|jj�d
�dS)NcSs|dg�|djd�gS)Nz200 OKzwsgi.url_schemez
iso-8859-1)r4)rurvrrr�trivial_app1Qs
z4HandlerTests.testContentLength.<locals>.trivial_app1cSs|dg�|djd��gS)Nz200 OKzwsgi.url_schemez
iso-8859-1)r4)rurvrrr�trivial_app2Usz4HandlerTests.testContentLength.<locals>.trivial_app2cSs|dg�djd�gS)Nz200 OKuтестzutf-8)r4)rurvrrr�trivial_app3Ys
z4HandlerTests.testContentLength.<locals>.trivial_app3cSs|ddg�gS)Nz200 OK�Content-Length�12345)rrr)rurvrrr�trivial_app4]sz4HandlerTests.testContentLength.<locals>.trivial_app4z)Status: 200 OK
Content-Length: 4

httpz
iso-8859-1zStatus: 200 OK

https-Status: 200 OK
Content-Length: 8

тестs)Status: 200 OK
Content-Length: 12345

)r��runrT�stdoutr<r4)rrrrrr�rrr�testContentLengthNs,



zHandlerTests.testContentLengthcCs�dd�}dd�}t�}|j|�|j|jj�djd��|j|jj�d�t�}|j|�|j|jj�d|jt|j	�fjd�|j	�|j
d	|jj��dS)
NcSs|dg�gS)Nz200 OKr)rurvrrr�
non_error_app�s
z8HandlerTests.testBasicErrorOutput.<locals>.non_error_appcSstd��dS)Nz This should be caught by handler)rD)rurvrrr�	error_app�sz4HandlerTests.testBasicErrorOutput.<locals>.error_appz%Status: 200 OK
Content-Length: 0

z
iso-8859-1r6z<Status: %s
Content-Type: text/plain
Content-Length: %d

rD)r�rrTrr<r4r;Zerror_statusr�Z
error_bodyr�)rrrr�rrr�testBasicErrorOutput�s


z!HandlerTests.testBasicErrorOutputcsRd��fdd�}t�}|j|�|j|jj�djd���|jd|jj��dS)NsSome output has been sentcs|dg���td��dS)Nz200 OKz This should be caught by handler)rD)rurv)�MSGrrr�sz4HandlerTests.testErrorAfterOutput.<locals>.error_appzStatus: 200 OK

z
iso-8859-1rD)r�rrTrr<r4r�r;)rrr�r)rr�testErrorAfterOutput�s
z!HandlerTests.testErrorAfterOutputc	Csdd�}d}djd�}�x�dD]�}|r.d|p0d}x�dD]�}x�dD]�}t|d�}d|_||_||_|j|�|j||jj��t|d�}d|_||_||_|j|�|dkr�|j|jj�d�qB|j	t
j|||fjd�|jj��|||fjd�|jj�f�qBWq8WqWdS)NcSs|dg�gS)Nz200 OKr)rurvrrrr�s
z5HandlerTests.testHeaderFormats.<locals>.non_error_appzfHTTP/%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\nz%Status: 200 OK
Content-Length: 0

z
iso-8859-1�
FooBar/1.0zServer: %s
r6�1.0�1.1�HTTP/0.9�HTTP/1.0�HTTP/1.1)r�FTr�)rN)r r!)r"r#r$)r4r�Z
origin_serverZhttp_versionZserver_softwarerrTrr<rd�rerK)	rrZstdpatZshortpatZssw�swrR�protor�rrr�testHeaderFormats�s4






zHandlerTests.testHeaderFormatscCs.dd�}t�}|j|�|jd|jj��dS)NcSs|ddg�dgS)Nz200 OK�Content-Type�text/plain; charset=utf-8sdata)r)r*r)rurvrrrr=�sz'HandlerTests.testBytesData.<locals>.appsRStatus: 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4

data)r�rrTrr<)rr=r�rrr�
testBytesData�s

zHandlerTests.testBytesDatacs>ddi�d���fdd�}t�}|j|�|j�dd�dS)N�close_calledFsSome output has been sentcs(|dg���G�fdd�dt�}|�S)Nz200 OKcs eZdZdd�Z�fdd�ZdS)zHHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterablecssxdVtd��qWdS)Nsblahz This should be caught by handler)rD)rrrr�__iter__�szQHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.__iter__csd�d<dS)NTr,r)r)�side_effectsrrr��szNHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.closeN)rr r!r-r�r)r.rr�CrashyIterable�sr/)�object)rurvr/)rr.rrr�sz0HandlerTests.testCloseOnError.<locals>.error_appT)r�rrT)rrr�r)rr.r�testCloseOnError�s
zHandlerTests.testCloseOnErrorc
sjt��G�fdd�d�}ddi}tt�|�tj|�}d}|jt|��|jt�WdQRX|j	d��dS)Ncs eZdZ�fdd�Zdd�ZdS)z4HandlerTests.testPartialWrite.<locals>.PartialWritercs|dd�}�j|�t|�S)N�)�extendr�)r�b�partial)�writtenrr�write�s
z:HandlerTests.testPartialWrite.<locals>.PartialWriter.writecSsdS)Nr)rrrr�flush�sz:HandlerTests.testPartialWrite.<locals>.PartialWriter.flushN)rr r!r7r8r)r6rr�
PartialWriter�sr9r�zHTTP/1.0zshould not do partial writesssHTTP/1.0 200 OK
Content-Type: text/plain
Date: Mon, 05 Jun 2006 18:49:54 GMT
Content-Length: 13

Hello, world!)
�	bytearrayr
rr:r;ZassertWarnsRegex�DeprecationWarningrr,rT)rr9r*r��msgr)r6r�testPartialWrite�s	zHandlerTests.testPartialWriteN)rr r!r�rrrr	rrrrr(r+r1r=rrrrr�s	
2
+r��__main__)3Zunittestrr�rZtest.test_httpserversrrZwsgiref.utilrZwsgiref.headersrZwsgiref.handlersrr	r
ZwsgirefrZwsgiref.validaterZwsgiref.simple_serverr
rrZhttp.clientr�iorrrZsocketserverr�platformrr�r%r�r:rr"r,r5rBrOrPr�r�r�r�r�r�mainrrrr�<module>sH
%:#7s