Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/test_wsgiref.cpython-35.opt-2.pyc



���]Vl�@sJddlmZddlmZddlmZddlmZddlmZddl	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'ddd�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*krFej2�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@s(eZdZdd�Zdd�ZdS)�
MockServercCs!tj|||�|j�dS)N)r�__init__�server_bind)�self�server_addressZRequestHandlerClass�r�1/opt/alt/python35/lib64/python3.5/test_wsgiref.pyrszMockServer.__init__cCs/|j\}}||_||_|j�dS)N)rZserver_nameZserver_port�
setup_environ)r�host�portrrrrs		zMockServer.server_bindN)�__name__�
__module__�__qualname__rrrrrrrsrc@s(eZdZdd�Zdd�ZdS)�MockHandlercCs%|j|_|j\|_|_dS)N)�request�
connectionZrfileZwfile)rrrr�setup(szMockHandler.setupcCsdS)Nr)rrrr�finish,szMockHandler.finishN)r r!r"r&r'rrrrr#&sr#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_app0s
r.cCsA|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/r0)r*r1)�join�encode)r,r-rrr�
header_app8s
r7sGET / HTTP/1.0

cCs�tdd|tt�}tt|��}t�}tj}t�}t_z|j||fd�Wd|t_X|j	�|j	�fS)N��P�	127.0.0.1�")r:r;)
rrr#rr�sys�stderrrZfinish_request�getvalue)�app�data�serverZinp�outZolderr�errrrr�	run_amockCs		
rDcCs|�}d}x.|D]&}|||ks2t�|d7}qWy||Wntk
r`YnXtd|��yttfWntk
r�Yn}X|�}t|�|k	r�t�x&|D]}t|�|ks�t�q�Wyt|�Wntk
r�YnXtd|��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	


	


rQc@s�eZdZddd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�IntegrationTestsTcCsWt�dtjj�d}|j|d|d|r>dpAddjd��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
r8z
Hello, world!z
iso-8859-1)rr<�version�split�assertEqualr6)rrB�
has_length�pyverrrr�check_helloxs
	zIntegrationTests.check_hellocCs t�\}}|j|�dS)N)rDrY)rrBrCrrr�test_plain_hello�sz!IntegrationTests.test_plain_hellocCs9d}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

rEs+Python test,Python test 2;query=test;/path/���)rDr7rV�
splitlines)rr$rBrCrrr�test_environ�s

zIntegrationTests.test_environcCs?tddddd�\}}|j|j�dd�dS)Nr@sGET �xis HTTP/1.0

rs!HTTP/1.0 414 Request-URI Too Long)rDrVr\)rrBrCrrr�test_request_length�s!z$IntegrationTests.test_request_lengthcCs/ttt��\}}|j|dd�dS)NrWF)rDrr.rY)rrBrCrrr�test_validated_hello�sz%IntegrationTests.test_validated_hellocCsXdd�}tt|��\}}|j|jd��|j|j�dd�dS)NcSs|dd�dgS)Nz200 OK�Content-Type�
text/plainz
Hello, world!)rarbr)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'>���)rDr�
assertTrue�endswithrVr\)rrcrBrCrrr�test_simple_validation_error�s

z-IntegrationTests.test_simple_validation_errorcCs�dd�}dd
dg}xv|D]n\}}|jd	|��Mt||��\}}|j|jd
��|j|j�d|�WdQRXq"WdS)Ncs�fdd�}|S)Ncs|�dg�dgS)N�Content-Type�text/plain; charset=utf-8s
Hello, world!)rirjr)r,r-)�statusrrrc�szWIntegrationTests.test_status_validation_errors.<locals>.create_bad_app.<locals>.bad_appr)rkrcr)rkr�create_bad_app�szFIntegrationTests.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 coderks;A server error occurred.  Please contact the administrator.rd)rmrn)rorp)rqrrre)ZsubTestrDrfrgrVr\)rrlZtestsrkZexc_messagerBrCrrr�test_status_validation_errors�s	
z.IntegrationTests.test_status_validation_errorscCsXdd�}tt|��\}}|j|jd��|j|j�dd�dS)NcSs%|dj�|ddg�dgS)Nz
wsgi.inputz200 OK�Content-Type�text/plain; charset=utf-8sdata)rtru)�read)�e�srrrrc�sz1IntegrationTests.test_wsgi_input.<locals>.bad_apps;A server error occurred.  Please contact the administrator.rdrFre)rDrrfrgrVr\)rrcrBrCrrr�test_wsgi_input�s
z IntegrationTests.test_wsgi_inputcCs�dd�}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)rzr{)r*r|r)rwrxrrrr?�s
z3IntegrationTests.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)
rDrrfrgr<rTrUr6rrV)rr?rBrCZver�pyrXrrr�test_bytes_validation�sz&IntegrationTests.test_bytes_validationcCsYdd�}tt|�dd�\}}|jdtjdddd	g|j��dS)
NcSs'|ddd	g�|djd�gS)
Nz200 OK�Content-Type�
text/plainr*�Wed, 24 Dec 2008 13:29:32 GMTr4�latin1)r�r�)r*r�)r6)rwrxrrrr?�s
z-IntegrationTests.test_cp1252_url.<locals>.appr@sGET /�%80 HTTP/1.0sHTTP/1.0 200 OKsContent-Type: text/plains#Date: Wed, 24 Dec 2008 13:29:32 GMT�s/��)rDrrVr�ANYr\)rr?rBrCrrr�test_cp1252_url�s	z IntegrationTests.test_cp1252_urlcs8tjd�}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�ttj�gS)Nz200 OK)�bytesr�
SOCK_MAX_SIZE)r,r-rrrr?s
z4IntegrationTests.test_interrupted_write.<locals>.appc@seZdZdS)z<IntegrationTests.test_interrupted_write.<locals>.WsgiHandlerN)r r!r"rrrr�WsgiHandlersr�rZ
handler_classcs�j�dS)N)�set)�signum�frame)�interruptedrr�signal_handlersz?IntegrationTests.test_interrupted_write.<locals>.signal_handlercs�t�j�}|jdd�|j��V}|jd�x-��tj��jdtd��r>Pq>Wt	|j���WdQRX|j
�dS)N�GETrS�d�timeoutrE)rrr$Zgetresponserv�signal�SIGUSR1�wait�float�len�close)�http�response)r��main_threadr��receivedrArr�
run_clients
z;IntegrationTests.test_interrupted_write.<locals>.run_client�targetr�)r�
import_moduleZ
get_attributer�rrrZHOSTZ
addCleanupZserver_close�Eventr��	get_ident�Thread�startZhandle_requestr5rVr�)rr�r?r�r�Zoriginalr�Z
backgroundr)r�r�r�r�rAr�test_interrupted_write�s$


z'IntegrationTests.test_interrupted_writeN)r r!r"rYrZr]r_r`rhrsryr�r�r�rrrrrRvs


rRc@s�eZdZdd�Zddd�Zdd�Zdd	�Zd
dd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �ZdS)!�UtilityTestscCsdd|d|i}tj|�|jtj|�|�|j|d|�|j|d|�|S)N�SCRIPT_NAMEr4)rrrVZshift_path_info)rZsn_inZpi_in�partZsn_outZpi_out�envrrr�
checkShift1s
zUtilityTests.checkShiftNcCs�i}tj|�t|t�r9|j||t�n:t|t�r_|j||t�n|j|||�||i}tj|�|j|||�dS)N)rr�
isinstancerZassertIsInstancerrVZassertIs)r�key�value�altr�rrr�checkDefault9s

zUtilityTests.checkDefaultcKs%tj|�|j|||�dS)N)rrrV)rr�r��kwrrr�checkCrossDefaultIs
zUtilityTests.checkCrossDefaultcKs*tj|�|jtj|�|�dS)N)rrrVZapplication_uri)r�urir�rrr�checkAppURIMs
zUtilityTests.checkAppURIrEcKs-tj|�|jtj||�|�dS)N)rrrVZrequest_uri)rr�Zqueryr�rrr�checkReqURIQs
zUtilityTests.checkReqURIcCs�||dd�}t||�|�}|j|jj�x|D]}qBW|j|jj�|j�|j|jj�dS)NcSstjt|�|�S)N)rZFileWrapperr)�text�sizerrrrLWsz%UtilityTests.checkFW.<locals>.make_it)rQ�assertFalseZfilelike�closedr�rf)rr�r�rMrLrNrPrrr�checkFWUs
	

zUtilityTests.checkFWcCs�|jddddd�|jddddd�|jddddd�|jddddd�|jdd	ddd�dS)
Nr8rSz/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/yr8z//y�yz/a/b/yz//y/rSz/./yz/./y/z///./..//y/.//z/y/z///z/a/b/z/.//z/x//r�z/a/b/xz/.)r�)rrrr�testNormalizedShiftsnsz!UtilityTests.testNormalizedShiftscCsgx`dddddddd d!d"d#dt�fdt�fd$gD]\}}|j||�qCWdS)%N�SERVER_NAME�	127.0.0.1�SERVER_PORT�80�SERVER_PROTOCOL�HTTP/1.0�	HTTP_HOST�REQUEST_METHODr�r�r8r4rS�wsgi.versionrEr�
wsgi.run_once�wsgi.multithread�wsgi.multiprocessz
wsgi.inputzwsgi.errors�wsgi.url_schemer�)r�r�)r�r�)r�r�)r�r�)r�r�)r�r8)r4rS�rEr)r�r�)r�r)r�r)r�r)r�r�)rrr�)rr�r�rrr�testDefaults{s zUtilityTests.testDefaultscCs�|jdddd�|jdddd�|jdddd�|jdddd	�|jdd
dd�|jdd
dd�|jdddd�dS)Nr�zfoo.barr�zwsgi.url_scheme�https�HTTPS�on�1�yesr��foor�r�Z443)r�)rrrr�testCrossDefaults�szUtilityTests.testCrossDefaultscCs�|jtji�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�|jtjddi�d�dS)Nr�r�r�r�r�r�r�)rVrZguess_scheme)rrrr�testGuessScheme�s
zUtilityTests.testGuessSchemecCs�|jd�|jddd�|jddd�|jddd	d
d�|jdd
d�|jdddd
d�|jddd�|jdd
ddd�dS)Nzhttp://127.0.0.1/zhttp://127.0.0.1/spamr�z/spamzhttp://127.0.0.1/sp%E4mu/spämzhttp://spam.example.com:2071/r�zspam.example.com:2071r�Z2071zhttp://spam.example.com/r�zspam.example.comz	127.0.0.1zhttps://127.0.0.1/r�r�zhttp://127.0.0.1:8000/Z8000)r�)rrrr�testAppURIs�s


zUtilityTests.testAppURIsc	Cs�|jd�|jddd�|jddd�|jdddd	d�|jd
ddd	d�|jdddd	d�|jd
ddd	d�|jdddd	ddd�|jdddd	ddd�|jddddd	ddd�dS)Nzhttp://127.0.0.1/zhttp://127.0.0.1/spamr�z/spamzhttp://127.0.0.1/sp%E4mu/spämzhttp://127.0.0.1/spammity/spamz	/spammityr4z 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=nir3zsay=niz'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�xYdj�D]K}xB||j�|j�|j�fD]}|jtj|��q8Wq
WxYdj�D]K}xB||j�|j�|j�fD]}|jtj|��q�WqiWdS)NzbConnection Keep-Alive Proxy-Authenticate Proxy-Authorization TE Trailers Transfer-Encoding Upgradez4Accept Cache-Control Date Pragma Trailer Via Warning)rU�title�upper�lowerrfrZ
is_hop_by_hopr�)rZhopr�rrr�testHopByHop�s++zUtilityTests.testHopByHop)r r!r"r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr�/s
	r�c@s4eZdZdd�Zdd�Zdd�ZdS)�HeaderTestscCsqd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<xr|j|j|j	|j
fD]R}|j|d��|j|d��|j|d��|j|d��q1W|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�rrEr��bar�FooZFOO�bazZwheeZzoo)r�r�)rVr�r�keys�values�itemsZassertIsNot�__contains__�get�get_all�__getitem__rfr��
setdefault)r�test�h�mrrr�testMappingInterface�s4	&))&	
%
z HeaderTests.testMappingInterfacecCs|jttd�dS)Nr�)�assertRaises�	TypeErrorr)rrrr�testRequireList�szHeaderTests.testRequireListcCs�t�}|jt|�d�|jdddd�|j|dd�|jt|�d�|jddd	d�|j|jd�dd
g�|jt|�d�dS)Nz
r�r�r�Zspamzbar; baz="spam"zfoo: bar; baz="spam"

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

)rrV�strZ
add_headerr�)rr�rrr�
testExtras�s	
zHeaderTests.testExtrasN)r r!r"r�r�r�rrrrr��s r�c@s1eZdZeejj��Zdd�ZdS)�ErrorHandlerc
Ks<t|�tj|t�t�t�|dddd�dS)N�multithreadT�multiprocess)rr	rrr)rr�rrrrs
zErrorHandler.__init__N)	r r!r"�dict�osr,r�Z
os_environrrrrrr�sr�c@seZdZdd�ZdS)�TestHandlercCs�dS)Nr)rrrr�handle_errorszTestHandler.handle_errorN)r r!r"r�rrrrr�sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�HandlerTestscCsp|j}x`dddddgD]I}|dkrC|jdkrCq|jt|d|�|d|�qWdS)NrTr�r�Zrun_onceZfile_wrapperZwsgi_zwsgi.)r,Zwsgi_file_wrapperrV�getattr)r�handlerr��attrrrr�checkEnvironAttrs s	zHandlerTests.checkEnvironAttrscCs�i}t|�|j}ddlm}x:|j�D],\}}||kr6|j|||�q6Wx*|j�D]\}}|j||�qsWdS)Nr)r,)rr,r�r�rV�assertIn)rr��emptyr�r,�k�vrrr�checkOSEnviron)s
	zHandlerTests.checkOSEnvironcCsNtdd�}|j�|j|�|j|�|j|jdd�dS)N�X�Y)r�rrrrVr,)rr�rrr�testEnviron3s



zHandlerTests.testEnvironcCsGtdddi�}|j�x!dD]}|j||j�q&WdS)N�wsgi.url_scheme�
wsgi.input�wsgi.errors)r
rr)r	rrr,)rr�r�rrr�testCGIEnviron:s

zHandlerTests.testCGIEnvironcCs^tdd�}|j�|j|jdd�t�}|j�|j|jdd�dS)Nr�r�zwsgi.url_schemer�r�)r�rrVr,)rr�rrr�
testScheme@s
	
zHandlerTests.testSchemecCsYt�}x3ddddgD]}|jtt||��qW|jt|jd�dS)NZ_flushZ	get_stdinZ
get_stderrZadd_cgi_varsr�)rr��NotImplementedErrorr��_write)rr��namerrr�testAbstractMethodsFs
	z HandlerTests.testAbstractMethodscCsdd�}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)r6)rwrxrrr�trivial_app1Qs
z4HandlerTests.testContentLength.<locals>.trivial_app1cSs$|dg�|djd��gS)Nz200 OKzwsgi.url_schemez
iso-8859-1)r6)rwrxrrr�trivial_app2Us z4HandlerTests.testContentLength.<locals>.trivial_app2cSs|dg�djd�gS)Nz200 OKuтестzutf-8)r6)rwrxrrr�trivial_app3Ys
z4HandlerTests.testContentLength.<locals>.trivial_app3cSs|ddg�gS)Nz200 OK�Content-Length�12345)rrr)rwrxrrr�trivial_app4]sz4HandlerTests.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��runrV�stdoutr>r6)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)rwrxrrr�
non_error_app�s
z8HandlerTests.testBasicErrorOutput.<locals>.non_error_appcSstd��dS)Nz This should be caught by handler)rF)rwrxrrr�	error_app�sz4HandlerTests.testBasicErrorOutput.<locals>.error_appz%Status: 200 OK
Content-Length: 0

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

rF)r�rrVrr>r6r=Zerror_statusr�Z
error_bodyr)rrrr�rrr�testBasicErrorOutput�s	

	
z!HandlerTests.testBasicErrorOutputcsqd��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)rF)rwrx)�MSGrrr�sz4HandlerTests.testErrorAfterOutput.<locals>.error_appzStatus: 200 OK

z
iso-8859-1rF)r�rrVrr>r6rr=)rrr�r)rr�testErrorAfterOutput�s	
z!HandlerTests.testErrorAfterOutputc	Cswdd�}d}djd�}xOdD]G}|r>d|pAd}x(dD] }xdD]}td|�}d|_||_||_|j|�|j||jj��td|�}d|_||_||_|j|�|dkr
|j|jj�d�qX|j	t
j|||fjd�|jj��|||fjd�|jj�f�qXWqKWq(WdS)NcSs|dg�gS)Nz200 OKr)rwrxrrrr�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
r8�1.0�1.1�HTTP/0.9�HTTP/1.0�HTTP/1.1r�FTr�)r!N)r"r#)r$r%r&)r6r�Z
origin_serverZhttp_versionZserver_softwarerrVrr>rf�rerM)	rrZstdpatZshortpatZsswZswrT�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)rwrxrrrr?�s
z'HandlerTests.testBytesData.<locals>.appsRStatus: 200 OK
Content-Type: text/plain; charset=utf-8
Content-Length: 4

data)r�rrVrr>)rr?r�rrr�
testBytesData�s
	
	zHandlerTests.testBytesDatacsUddi�d���fdd�}t�}|j|�|j�dd�dS)N�close_calledFsSome output has been sentcs6|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)rF)rrrr�__iter__�szQHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.__iter__csd�d<dS)NTr-r)r)�side_effectsrrr��szNHandlerTests.testCloseOnError.<locals>.error_app.<locals>.CrashyIterable.closeN)r r!r"r.r�r)r/rr�CrashyIterable�sr0)�object)rwrxr0)rr/rrr�sz0HandlerTests.testCloseOnError.<locals>.error_appT)r�rrV)rrr�r)rr/r�testCloseOnError�s	
zHandlerTests.testCloseOnErrorc
s�t��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)r r!r"r8r9r)r7rr�
PartialWriter�sr:r�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.rV)rr:r,r��msgr)r7r�testPartialWrite�s			zHandlerTests.testPartialWriteN)r r!r"rrr	r
rrrrr r)r,r2r>rrrrr�s	
2
+r��__main__)3Zunittestrr�rZtest.test_httpserversrrZwsgiref.utilrZwsgiref.headersrZwsgiref.handlersrr	r
ZwsgirefrZwsgiref.validaterZwsgiref.simple_serverr
rrZhttp.clientr�iorrr�socketserverr�platformrr�r'r�r<rr#r.r7rDrQrRr�r�r�r�r�r �mainrrrr�<module>sB
%��7�