ó
    ×›‘h¼) ã                   óð  • S r SSKrSSKrSSKrSSKJr  SSKJr  SSK	J
r
  SSKJr  SSKJrJr  SSKJrJr  SS	KJr  SS
KJr  SSKJrJr  SSKJr  SSKJr  SSKJr  SSK J!r!  SSK"J#r#  SSK$J%r%J&r&  SSK'J(r(J)r)J*r*  SSK+J,r,  SSK-J.r.   " S S5      r/ " S S5      r0 " S S\!5      r1 " S S5      r2 " S S\2\!5      r3 " S S \25      r4 " S! S"\4\!5      r5 " S# S$\4\!5      r6 " S% S&\2\!5      r7 " S' S(\2\!5      r8g))z 
Tests for L{twisted.web.wsgi}.
é    N)Úexc_info)Úquote)ÚverifyObject)Úreactor)ÚIPv4AddressÚIPv6Address)ÚDeferredÚgatherResults)ÚConnectionLost)ÚEventLoggingObserver)ÚLoggerÚglobalLogPublisher)ÚFailure)ÚgetThreadID)Ú
ThreadPool)ÚTestCase)Úserver)Ú	IResourceÚResource)ÚRequestÚSiteÚversion)ÚDummyChannel)ÚWSGIResourcec                   ó,   • \ rS rSrSr\" 5       rS rSrg)ÚSynchronousThreadPoolé!   a  
A single-threaded implementation of part of the L{ThreadPool} interface.
This implementation calls functions synchronously rather than running
them in a thread pool.  It is used to make the tests which are not
directly for thread-related behavior deterministic.
c                 ól   •  U" U0 UD6  g! [          a    U R                  R                  S5         gf = f)zX
Call C{f(*a, **kw)} in this thread rather than scheduling it to be
called in a thread.
z<Callable passed to SynchronousThreadPool.callInThread failedN)ÚBaseExceptionÚ_logÚfailure©ÚselfÚfÚaÚkws       Ú^C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/web/test/test_wsgi.pyÚcallInThreadÚ"SynchronousThreadPool.callInThread+   s8   € ð
	ÙˆqˆK�B‹KøÜó 	ð �I‰I×ÑØNöð		ús   ‚ ‹%3²3© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r    r(   Ú__static_attributes__r*   ó    r'   r   r   !   s   † ññ ‹8€Dõr1   r   c                   ó   • \ rS rSrSrS rSrg)ÚSynchronousReactorThreadsé;   a•  
A single-threaded implementation of part of the L{IReactorThreads}
interface.  This implementation assumes that it will only be invoked
from the reactor thread, so it calls functions synchronously rather than
trying to schedule them to run in the reactor thread.  It is used in
conjunction with L{SynchronousThreadPool} to make the tests which are
not directly for thread-related behavior deterministic.
c                 ó   • U" U0 UD6  g)zM
Call C{f(*a, **kw)} in this thread which should also be the reactor
thread.
Nr*   r"   s       r'   ÚcallFromThreadÚ(SynchronousReactorThreads.callFromThreadE   s   € ñ
 	
ˆ1ˆ�‹r1   r*   N©r+   r,   r-   r.   r/   r6   r0   r*   r1   r'   r3   r3   ;   s   † ñõr1   r3   c                   ó,   • \ rS rSrS rS rS rS rSrg)ÚWSGIResourceTestséM   c                 óJ   • [        [        5       [        5       S 5      U l        g)zÇ
Create a L{WSGIResource} with synchronous threading objects and a no-op
application object.  This is useful for testing certain things about
the resource implementation which are unrelated to WSGI.
c                 ó   • g ©Nr*   ©ÚenvironÚstartResponses     r'   Ú<lambda>Ú)WSGIResourceTests.setUp.<locals>.<lambda>W   s   € ¨4r1   N)r   r3   r   Úresource©r#   s    r'   ÚsetUpÚWSGIResourceTests.setUpN   s   € ô %Ü%Ó'Ü!Ó#Ù/ó
ˆ�r1   c                 ó‚   • [        [        U R                  5        U R                  U R                  R                  5        g)zG
L{WSGIResource} implements L{IResource} and stops resource traversal.
N)r   r   rD   Ú
assertTrueÚisLeafrE   s    r'   Útest_interfacesÚ!WSGIResourceTests.test_interfacesZ   s(   € ô 	”Y §¡Ô.Ø�‰˜Ÿ™×,Ñ,Õ-r1   c           	      óè   • U R                  [        U R                  R                  S[	        [        5       S5      5        U R                  [        U R                  R                  S[        5       5        g)z�
A L{WSGIResource} cannot have L{IResource} children.  Its
C{getChildWithDefault} and C{putChild} methods raise L{RuntimeError}.
ó   fooFN)ÚassertRaisesÚRuntimeErrorrD   ÚgetChildWithDefaultr   r   ÚputChildr   rE   s    r'   Útest_unsupportedÚ"WSGIResourceTests.test_unsupporteda   sS   € ð
 	×ÑÜØ�M‰M×-Ñ-ØÜ”L“N EÓ*ô		
ð 	×Ñœ,¨¯©×(>Ñ(>ÀÌË
ÕSr1   c                 óÐ  ^• [         R                  " U [        5      n " S S[        5      m " S S[        5      nU4S jn " U4S jS5      n[        U" 5       [        5       U5      U l        U R                  R                  U" [        5       S5      5        U R                  S	[        U5      5        US
   S   nU R                  UR                  T5        U R                  T5        g)z–
If an exception is thrown by the application, and then in the
exception handling code, verify it should be propagated to the
provided L{ThreadPool}.
c                   ó   • \ rS rSrSrSrg)ÚIWSGIResourceTests.test_applicationAndRequestThrow.<locals>.ArbitraryErrorév   z#
An arbitrary error for this class
r*   N)r+   r,   r-   r.   r/   r0   r*   r1   r'   ÚArbitraryErrorrW   v   s   † ôr1   rY   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚPWSGIResourceTests.test_applicationAndRequestThrow.<locals>.FinishThrowingRequesté{   z4
An L{IRequest} request whose finish method throws.
c                 ób   • [         R                  " U /UQ70 UD6  SU l        SU l        SU l        g )NÚ s   www.example.com/stuff)r   Ú__init__ÚprepathÚpostpathÚuri)r#   ÚargsÚkwargss      r'   r_   ÚYWSGIResourceTests.test_applicationAndRequestThrow.<locals>.FinishThrowingRequest.__init__€   s/   € Ü× Ò  Ð7¨Ò7°Ò7Ø!�”Ø "�”Ø3�•r1   c                 ó   • g)z9
Return loopback address.

@return: loopback ip address.
ú	127.0.0.1r*   rE   s    r'   ÚgetClientIPÚ\WSGIResourceTests.test_applicationAndRequestThrow.<locals>.FinishThrowingRequest.getClientIP†   s   € ð #r1   c                 ó   • [        SSS5      $ )z0
Return a fake Address

@return: A fake address
ÚTCPrg   i0u  )r   rE   s    r'   ÚgetHostÚXWSGIResourceTests.test_applicationAndRequestThrow.<locals>.FinishThrowingRequest.getHostŽ   s   € ô # 5¨+°uÓ=Ð=r1   )ra   r`   rb   N)	r+   r,   r-   r.   r/   r_   rh   rl   r0   r*   r1   r'   ÚFinishThrowingRequestr[   {   s   † ñò4ò#õ>r1   rn   c                 ó   >• T" 5       e)zg
An application object that throws an exception.

@param environ: unused

@param startResponse: unused
r*   )r@   rA   rY   s     €r'   ÚapplicationÚFWSGIResourceTests.test_applicationAndRequestThrow.<locals>.application–   s   ø€ ñ !Ó"Ð"r1   c                   ó&   >• \ rS rSrSrU 4S jrSrg)ÚQWSGIResourceTests.test_applicationAndRequestThrow.<locals>.ThrowingReactorThreadsé    zP
An L{IReactorThreads} implementation whose callFromThread raises
an exception.
c                 ó   >• T" 5       e)zZ
Raise an exception to the caller.

@param f: unused

@param a: unused

@param kw: unused
r*   )r#   r$   r%   r&   rY   s       €r'   r6   Ú`WSGIResourceTests.test_applicationAndRequestThrow.<locals>.ThrowingReactorThreads.callFromThread¦   s   ø€ ñ %Ó&Ð&r1   r*   Nr8   )rY   s   €r'   ÚThrowingReactorThreadsrs       s   ø† ñ÷

'ð 
'r1   rw   Fé   r   Úlog_failureN)r   ÚcreateWithCleanupr   Ú	Exceptionr   r   r   rD   Úrenderr   ÚassertEqualsÚlenÚassertIsInstanceÚvalueÚflushLoggedErrors)r#   ÚlogObserverrn   rp   rw   r$   rY   s         @r'   Útest_applicationAndRequestThrowÚ1WSGIResourceTests.test_applicationAndRequestThrown   s¾   ø€ ô +×<Ò<¸TÔCUÓVˆô	œYô 	ô
	>¤Gô 	>õ6	#÷	'ô 	'ô$ %Ù"Ó$Ô&;Ó&=¸{ó
ˆŒð 	�‰×ÑÑ2´<³>À5ÓIÔJØ×Ñ˜!œS Ó-Ô.Ø˜‰N˜=Ñ)ˆØ×Ñ˜aŸg™g ~Ô6Ø×Ñ˜~Õ.r1   )rD   N)	r+   r,   r-   r.   rF   rK   rS   rƒ   r0   r*   r1   r'   r:   r:   M   s   † ò

ò.òTõL/r1   r:   c                   óV   • \ rS rSrSr\rS rS/ SS4S jrS r	\
4S jrS	 rSS
 jrSrg)ÚWSGITestsMixiné½   zˆ
@ivar channelFactory: A no-argument callable which will be invoked to
    create a new HTTP channel to associate with request objects.
c                 ó@   • [        5       U l        [        5       U l        g r>   )r   Ú
threadpoolr3   r   rE   s    r'   rF   ÚWSGITestsMixin.setUpÅ   s   € Ü/Ó1ˆŒÜ0Ó2ˆ�r1   Nr^   c                 ó‚  • S n[        U R                  U R                  U" 5       5      nUR                  5         U H'  n[	        5       nUR                  U" U5      U5        UnM)     U" 5       n[        U5      Ul        U" US5      nU	 H.  u  nnUR                  R                  U" U5      U" U5      5        M0     UR                  S5        U
(       a6  UR                  R                  U
5        UR                  R                  S5        SSR                  U Vs/ s H  n[        Xë5      PM     sn5      -   nUbR  USSR                  U VVs/ s H-  u  nnSR                  [        UU5      [        UU5      /5      PM/     snn5      -   -  nUR!                  U" U5      U" U5      SU" U5      -   5        U$ s  snf s  snnf )	a  
@param method: A C{str} giving the request method to use.

@param version: A C{str} like C{'1.1'} giving the request version.

@param resourceSegments: A C{list} of unencoded path segments which
    specifies the location in the resource hierarchy at which the
    L{WSGIResource} will be placed, eg C{['']} for I{/}, C{['foo',
    'bar', '']} for I{/foo/bar/}, etc.

@param requestSegments: A C{list} of unencoded path segments giving the
    request URI.

@param query: A C{list} of two-tuples of C{str} giving unencoded query
    argument keys and values.

@param headers: A C{list} of two-tuples of C{str} giving request header
    names and corresponding values.

@param safe: A C{str} giving the bytes which are to be considered
    I{safe} for inclusion in the request URI and not quoted.

@return: A L{Deferred} which will be called back with a two-tuple of
    the arguments passed which would be passed to the WSGI application
    object for this configuration and request (ie, the environment and
    start_response callable).
c                 óR   • [        U [        5      (       a  U $ U R                  S5      $ )Nz
iso-8859-1)Ú
isinstanceÚbytesÚencode)Ústrings    r'   Ú_toByteStringÚ4WSGITestsMixin.lowLevelRender.<locals>._toByteStringó   s%   € ô ˜&¤%×(Ñ(Ø�à—}‘} \Ó2Ð2r1   Fr   Ú/Ú?Ú&Ú=s   HTTP/)r   r   r‰   Úreverser   rR   r   ÚsiteÚrequestHeadersÚaddRawHeaderÚ	gotLengthÚcontentÚwriteÚseekÚjoinÚurlquoteÚrequestReceived)r#   ÚrequestFactoryÚapplicationFactoryÚchannelFactoryÚmethodr   ÚresourceSegmentsÚrequestSegmentsÚqueryÚheadersÚbodyÚsafer‘   ÚrootÚsegÚtmpÚchannelÚrequestÚkÚvrb   s                        r'   ÚlowLevelRenderÚWSGITestsMixin.lowLevelRenderÉ   sš  € òT	3ô ˜DŸL™L¨$¯/©/Ñ;MÓ;OÓPˆØ× Ñ Ô"Û#ˆCÜ“*ˆCØ�L‰L™ sÓ+¨TÔ2ØŠDñ $ñ
 !Ó"ˆÜ˜D“zˆŒÙ  ¨%Ó0ˆÛ‰DˆAˆqØ×"Ñ"×/Ñ/±¸aÓ0@Á-ÐPQÓBRÖSñ à×Ñ˜!ÔÞØ�O‰O×!Ñ! $Ô'Ø�O‰O× Ñ  Ô#Ø�C—H‘H¹_ÓMº_°cœh sÖ1¹_ÑMÓNÑNˆØÑØ�3˜Ÿ™ÙPUÔVÒPUÁfÀqÈ!�—‘œ8 A tÓ,¬h°q¸$Ó.?Ð@ÖAÑPUÒVóñ ñ ˆCð 	×ÑÙ˜&Ó!¡=°Ó#5°xÁ-ÐPWÓBXÑ7Xô	
ð ˆùò Nùó Ws   ÄF6
Å4F;c                 ó–   ^• [        5       mU4S jnUR                  SU R                  5      nU R                  " [        X4/UQ70 UD6  T$ )Nc                  ó   >• U4S jn U $ )Nc                  óV   >• U u  pTR                  U 5        U" S/ 5        [        S5      $ ©Nú200 OKr*   ©ÚcallbackÚiter)rc   r@   rA   Úresults      €r'   rp   ÚFWSGITestsMixin.render.<locals>.applicationFactory.<locals>.application  s*   ø€ Ø)-Ñ&�Ø—‘ Ô%Ù˜h¨Ô+Ü˜B“x�r1   r*   ©rp   r½   s    €r'   r£   Ú1WSGITestsMixin.render.<locals>.applicationFactory  s   ø€ õ ð Ðr1   r¤   )r	   Úpopr¤   r³   r   )r#   r%   r&   r£   r¤   r½   s        @r'   r|   ÚWSGITestsMixin.render  sH   ø€ Ü“ˆõ	ð Ÿ™Ð 0°$×2EÑ2EÓFˆØ×ÒœGÐ%7ÐRÈ!ÒRÈrÒRØˆr1   c                 ó0   ^^• [        5       mUU4S jnTU4$ )Nc                  óV   >• T" U 0 UD6nUR                  5       R                  T5        U$ r>   )ÚnotifyFinishÚchainDeferred)r%   r&   r°   ÚdÚrequestClasss      €€r'   r¢   Ú<WSGITestsMixin.requestFactoryFactory.<locals>.requestFactory)  s0   ø€ Ù" AÐ,¨Ñ,ˆGð
 × Ñ Ó"×0Ñ0°Ô3ØˆNr1   ©r	   )r#   rÈ   r¢   rÇ   s    ` @r'   ÚrequestFactoryFactoryÚ$WSGITestsMixin.requestFactoryFactory&  s   ù€ Ü‹Jˆö	ð �.Ð Ð r1   c                 ó,   • UR                  SS5      S   $ )Nó   

rx   )Úsplit)r#   Úresponses     r'   ÚgetContentFromResponseÚ%WSGITestsMixin.getContentFromResponse4  s   € Ø�~‰~˜k¨1Ó-¨aÑ0Ð0r1   c                 ó8  ^^• [        5       mUU4S jn[        U R                  U R                  U5      n[	        5       nUR                  SU5        U R                  5       n[        U5      Ul         " S S[        5      nU" USS9nUR                  S5        UT4$ )a  
Prepare a L{Request} which, when a request is received, captures the
C{environ} and C{start_response} callable passed to a WSGI app.

@param application: An optional WSGI application callable that accepts
    the familiar C{environ} and C{start_response} args and returns an
    iterable of body content. If not supplied, C{start_response} will
    be called with a "200 OK" status and no headers, and no content
    will be yielded.

@return: A two-tuple of (C{request}, C{deferred}). The former is a
    Twisted L{Request}. The latter is a L{Deferred} which will be
    called back with a two-tuple of the arguments passed to a WSGI
    application (i.e. the C{environ} and C{start_response} callable),
    or will errback with any error arising within the WSGI app.
c                 óÖ   >•  Tc  U" S/ 5        [        S5      nOT" X5      nTR                  X45        U$ ! [         a'    TR                  5         U" S/ 5        [        S5      s $ f = f)Nr¹   r*   z	500 Error)r¼   r»   r   Úerrback)r@   rA   rœ   rp   r½   s      €€r'   ÚouterApplicationÚ7WSGITestsMixin.prepareRequest.<locals>.outerApplicationJ  so   ø€ ðØÑ&Ù! (¨BÔ/Ü" 2›h‘Gá)¨'ÓA�Gð —‘ Ð 8Ô9Ø�øô !ó  Ø—‘Ô Ù˜k¨2Ô.Ü˜B“x’ð ús   ƒ 7 ·.A(Á'A(s   resc                   ó"   • \ rS rSrSrSS jrSrg)Ú4WSGITestsMixin.prepareRequest.<locals>.CannedRequestia  ze
Convenient L{Request} derivative which has canned values for all
of C{requestReceived}'s arguments.
c                 ó,   • [         R                  " XX#S9$ )N)ÚcommandÚpathr   )r   r¡   )r#   rÛ   rÜ   r   s       r'   r¡   ÚDWSGITestsMixin.prepareRequest.<locals>.CannedRequest.requestReceivedg  s   € Ü×.Ò.Ø°ñð r1   r*   N)ó   GETó   /resó   1.1)r+   r,   r-   r.   r/   r¡   r0   r*   r1   r'   ÚCannedRequestrÙ   a  s   † ñ÷
r1   rá   F)Úqueuedr   )r	   r   r   r‰   r   rR   r¤   r   r˜   r   r›   )	r#   rp   rÖ   rD   r¬   r¯   rá   r°   r½   s	    `      @r'   ÚprepareRequestÚWSGITestsMixin.prepareRequest7  sŠ   ù€ ô" “ˆö	ô   §¡¨d¯o©oÐ?OÓPˆä‹zˆØ�‰�f˜hÔ'à×%Ñ%Ó'ˆÜ˜D“zˆŒô		œGô 		ñ   °Ñ6ˆØ×Ñ˜!Ôà˜ˆÐr1   )r   r‰   r>   )r+   r,   r-   r.   r/   r   r¤   rF   r³   r|   r   rË   rÑ   rã   r0   r*   r1   r'   r†   r†   ½   sA   † ñð
 "€Nò3ð ØØØôKòZð  29ô !ò1÷8r1   r†   c                   óÒ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S r!S  r"S! r#S"r$g#)$ÚEnvironTestsir  zv
Tests for the values in the C{environ} C{dict} passed to the application
object by L{twisted.web.wsgi.WSGIResource}.
c                 ó   ^ ^^• UU U4S jnU$ )Nc                 ó:   >• U u  pTR                  UT   T5        T$ r>   ©ÚassertEqual)r½   r@   rA   Úkeyr#   r€   s      €€€r'   ÚassertEnvironKeyEqualÚ;EnvironTests.environKeyEqual.<locals>.assertEnvironKeyEqualy  s$   ø€ Ø%+Ñ"ˆGØ×Ñ˜W S™\¨5Ô1ØˆLr1   r*   )r#   rë   r€   rì   s   ``` r'   ÚenvironKeyEqualÚEnvironTests.environKeyEqualx  s   ú€ ÷	ð
 %Ð$r1   c                 ó`   ^ • T R                  SS/ S/5      nU 4S jnUR                  U5        U$ )zm
L{WSGIResource} calls the application object with an C{environ}
parameter which is exactly of type C{dict}.
ÚGETú1.1r^   c                 óŠ   >• U u  pTR                  [        U5      [        5        U H  nTR                  U[        5        M     g r>   )ÚassertIdenticalÚtypeÚdictr   Ústr)r½   r@   rA   Únamer#   s       €r'   Ú
cbRenderedÚ3EnvironTests.test_environIsDict.<locals>.cbRendered‡  s9   ø€ Ø%+Ñ"ˆGØ× Ñ ¤ g£´Ô5ã�Ø×%Ñ% d¬CÖ0ò  r1   )r|   ÚaddCallback)r#   rÇ   rù   s   `  r'   Útest_environIsDictÚEnvironTests.test_environIsDict€  s3   ø€ ð
 �K‰K˜˜u b¨2¨$Ó/ˆõ	1ð 	
�‰�jÔ!Øˆr1   c                 óò   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SS/ S/5      nUR                  U R                  SS5      5        [        X/5      $ )z•
The C{'REQUEST_METHOD'} key of the C{environ} C{dict} passed to the
application contains the HTTP method in the request (RFC 3875, section
4.1.12).
rñ   rò   r^   ÚREQUEST_METHODÚPOST©r|   rû   rî   r
   )r#   ÚgetÚposts      r'   Útest_requestMethodÚEnvironTests.test_requestMethod‘  su   € ð �k‰k˜% ¨¨R¨DÓ1ˆØ�‰˜×,Ñ,Ð-=¸uÓEÔFð �{‰{˜6 5¨"¨r¨dÓ3ˆØ×Ñ˜×-Ñ-Ð.>ÀÓGÔHä˜c˜[Ó)Ð)r1   c                 óè   • S Hl  nU R                  5       u  p#UR                  U5        UR                  U R                  SS5      5        U R	                  U R                  U5      [        5        Mn     g)zl
The C{'REQUEST_METHOD'} key of the C{environ} C{dict} passed to the
application is always a native string.
)rÞ   rñ   rÿ   rñ   N©rã   r¡   rû   rî   r   ÚsuccessResultOfr÷   )r#   r¥   r°   r½   s       r'   Ú test_requestMethodIsNativeStringÚ-EnvironTests.test_requestMethodIsNativeString¡  sc   € ó
 $ˆFØ"×1Ñ1Ó3‰OˆGØ×#Ñ# FÔ+Ø×Ñ˜t×3Ñ3Ð4DÀeÓLÔMØ×!Ñ! $×"6Ñ"6°vÓ">ÄÖDò	 $r1   c                 óº  • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SSS/S/5      nUR                  U R                  SS5      5        U R                  SSS/S/5      nUR                  U R                  SS5      5        U R                  SSSS/SS/5      nUR                  U R                  SS5      5        U R                  SSS/SS	/5      nUR                  U R                  SS5      5        U R                  SS/ S
Q/ S
Q5      nUR                  U R                  SS5      5        [        XX4XV/5      $ )zª
The C{'SCRIPT_NAME'} key of the C{environ} C{dict} passed to the
application contains the I{abs_path} (RFC 2396, section 3) to this
resource (RFC 3875, section 4.1.13).
rñ   rò   r^   ÚSCRIPT_NAMEr“   Úfooz/fooz/foo/Úbar©r  r“   s   barÿõ   /foo///barÃ¿r  )r#   r¬   Ú
emptyChildÚleafÚ	containerÚinternalÚ	unencodeds          r'   Útest_scriptNameÚEnvironTests.test_scriptName¬  sP  € ð �{‰{˜5 %¨¨b¨TÓ2ˆØ×Ñ˜×-Ñ-¨m¸RÓ@ÔAà—[‘[ ¨°¨t°b°TÓ:ˆ
Ø×Ñ˜t×3Ñ3°MÀ3ÓGÔHà�{‰{˜5 %¨%¨°5°'Ó:ˆØ×Ñ˜×-Ñ-¨m¸VÓDÔEà—K‘K  u¨u°b¨k¸EÀ2¸;ÓGˆ	Ø×Ñ˜d×2Ñ2°=À'ÓJÔKà—;‘;˜u e¨e¨W°u¸e°nÓEˆØ×Ñ˜T×1Ñ1°-ÀÓHÔIà—K‘KØ�5Ò2Ò4Ló
ˆ	ð
 	×Ñ˜d×2Ñ2°=ÐBRÓSÔTä˜d°ÀÐUÓVÐVr1   c                 ó4  • U R                  5       u  pUR                  SS9  UR                  U R                  SS5      5        U R	                  U R                  U5      [        5        U R                  5       u  pU R                  [        UR                  SS9  g)zi
The C{'SCRIPT_NAME'} key of the C{environ} C{dict} passed to the
application is always a native string.
rß   ©rÜ   r  z/resN©	rã   r¡   rû   rî   r   r  r÷   rO   Ú	TypeError©r#   r°   r½   s      r'   Útest_scriptNameIsNativeStringÚ*EnvironTests.test_scriptNameIsNativeStringÊ  sˆ   € ð
 ×-Ñ-Ó/‰ˆØ×Ñ WÐÑ-Ø×Ñ˜4×/Ñ/°¸vÓFÔGØ×Ñ˜d×2Ñ2°6Ó:¼CÔ@ð ×-Ñ-Ó/‰ˆØ×Ñœ) W×%<Ñ%<À6ÐÒJr1   c                 óê  • U R                  SS5      nU R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SSS/S/5      nUR                  U5        U R                  SSS/S/5      nUR                  U5        U R                  SSSS/SS/5      nUR                  U5        U R                  SSS/SS/5      nUR                  U R                  SS5      5        U R                  SSS/SS/5      nUR                  U R                  SS5      5        U R                  SS/ / S	Q5      nUR                  U R                  SS
5      5        [        X$XVXx/5      $ )zÓ
The C{'PATH_INFO'} key of the C{environ} C{dict} passed to the
application contains the suffix of the request URI path which is not
included in the value for the C{'SCRIPT_NAME'} key (RFC 3875, section
4.1.5).
Ú	PATH_INFOr^   rñ   rò   r“   r  r  z/barr  r  )rî   r|   rû   r
   )	r#   ÚassertKeyEmptyr¬   r  r  r  ÚinternalLeafÚinternalContainerr  s	            r'   Útest_pathInfoÚEnvironTests.test_pathInfoÙ  sq  € ð ×-Ñ-¨k¸2Ó>ˆà�{‰{˜5 %¨¨b¨TÓ2ˆØ×Ñ˜×-Ñ-¨k¸3Ó?Ô@à—[‘[ ¨°¨t°b°TÓ:ˆ
Ø×Ñ˜~Ô.à�{‰{˜5 %¨%¨°5°'Ó:ˆØ×Ñ˜Ô(à—K‘K  u¨u°b¨k¸EÀ2¸;ÓGˆ	Ø×Ñ˜nÔ-à—{‘{ 5¨%°%°¸5À%¸.ÓIˆØ× Ñ  ×!5Ñ!5°kÀ6Ó!JÔKà ŸK™K¨¨u°u°gÀÀr¸{ÓKÐØ×%Ñ% d×&:Ñ&:¸;ÈÓ&LÔMà—K‘K  u¨bÒ2JÓKˆ	Ø×Ñ˜d×2Ñ2°;Ð@PÓQÔRäØ˜Ð2CÐOó
ð 	
r1   c                 ó4  • U R                  5       u  pUR                  SS9  UR                  U R                  SS5      5        U R	                  U R                  U5      [        5        U R                  5       u  pU R                  [        UR                  SS9  g)zg
The C{'PATH_INFO'} key of the C{environ} C{dict} passed to the
application is always a native string.
s   /res/foo/barr  r   z/foo/barz/res/foo/barNr  r  s      r'   Útest_pathInfoIsNativeStringÚ(EnvironTests.test_pathInfoIsNativeStringû  sˆ   € ð
 ×-Ñ-Ó/‰ˆØ×Ñ _ÐÑ5Ø×Ñ˜4×/Ñ/°¸ZÓHÔIØ×Ñ˜d×2Ñ2°6Ó:¼CÔ@ð ×-Ñ-Ó/‰ˆØ×Ñœ) W×%<Ñ%<À>ÐÒRr1   c           	      óH  • U R                  SS/ S/S5      nUR                  U R                  SS5      5        U R                  SS/ S// 5      nUR                  U R                  SS5      5        U R                  SS/ S/S/5      nUR                  U R                  SS5      5        U R                  SS/ S/S/5      nUR                  U R                  SS	5      5        U R                  SS/ S/S
/SS9nUR                  U R                  SS5      5        [        XX4U/5      $ )z§
The C{'QUERY_STRING'} key of the C{environ} C{dict} passed to the
application contains the portion of the request URI after the first
I{?} (RFC 3875, section 4.1.7).
rñ   rò   r^   NÚQUERY_STRING©r  r  úfoo=bar)r“   r“   z%2F=%2F)r  z?barr”   )r«   zfoo=?barr  )r#   ÚmissingÚemptyÚpresentr  ÚdoubleQuestions         r'   Útest_queryStringÚEnvironTests.test_queryString
  s+  € ð —+‘+˜e U¨B°°°dÓ;ˆØ×Ñ˜D×0Ñ0°ÀÓDÔEà—‘˜E 5¨"¨r¨d°BÓ7ˆØ×Ñ˜$×.Ñ.¨~¸rÓBÔCà—+‘+˜e U¨B°°°~Ð6FÓGˆØ×Ñ˜D×0Ñ0°ÀÓKÔLà—K‘K  u¨b°2°$¸¸ÓEˆ	Ø×Ñ˜d×2Ñ2°>À9ÓMÔNð
 Ÿ™Ø�5˜"˜r˜d _Ð$5¸Cð %ð 
ˆð 	×"Ñ" 4×#7Ñ#7¸È
Ó#SÔTä˜g¨gÀ.ÐQÓRÐRr1   c                 ó4  • U R                  5       u  pUR                  SS9  UR                  U R                  SS5      5        U R	                  U R                  U5      [        5        U R                  5       u  pU R                  [        UR                  SS9  g)zj
The C{'QUERY_STRING'} key of the C{environ} C{dict} passed to the
application is always a native string.
s   /res?foo=barr  r*  r,  z/res?foo=barNr  r  s      r'   Útest_queryStringIsNativeStringÚ+EnvironTests.test_queryStringIsNativeString&  sˆ   € ð
 ×-Ñ-Ó/‰ˆØ×Ñ _ÐÑ5Ø×Ñ˜4×/Ñ/°À	ÓJÔKØ×Ñ˜d×2Ñ2°6Ó:¼CÔ@ð ×-Ñ-Ó/‰ˆØ×Ñœ) W×%<Ñ%<À>ÐÒRr1   c                 óø   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SS/ S/SS/5      nUR                  U R                  SS5      5        [        X/5      $ )z£
The C{'CONTENT_TYPE'} key of the C{environ} C{dict} passed to the
application contains the value of the I{Content-Type} request header
(RFC 3875, section 4.1.3).
rñ   rò   r^   ÚCONTENT_TYPEN)úcontent-typeú	x-foo/barr9  r  ©r#   r-  r/  s      r'   Útest_contentTypeÚEnvironTests.test_contentType5  s�   € ð —+‘+˜e U¨B°°Ó5ˆØ×Ñ˜D×0Ñ0°ÀÓDÔEà—+‘+Ø�5˜"˜r˜d DÐ+HÐ*Ió
ˆð 	×Ñ˜D×0Ñ0°ÀÓMÔNä˜gÐ/Ó0Ð0r1   c                 ó  • S H‡  nU R                  5       u  p#UR                  R                  SU5        UR                  5         UR	                  U R                  SS5      5        U R                  U R                  U5      [        5        M‰     g)zj
The C{'CONTENT_TYPE'} key of the C{environ} C{dict} passed to the
application is always a native string.
)s	   x-foo/barr9  s   Content-Typer7  r9  N©	rã   r™   rš   r¡   rû   rî   r   r  r÷   )r#   ÚcontentTyper°   r½   s       r'   Útest_contentTypeIsNativeStringÚ+EnvironTests.test_contentTypeIsNativeStringE  sv   € ó
 5ˆKØ"×1Ñ1Ó3‰OˆGØ×"Ñ"×/Ñ/°ÀÔMØ×#Ñ#Ô%Ø×Ñ˜t×3Ñ3°NÀKÓPÔQØ×!Ñ! $×"6Ñ"6°vÓ">ÄÖDò 5r1   c                 óø   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SS/ S/SS/5      nUR                  U R                  SS5      5        [        X/5      $ )z§
The C{'CONTENT_LENGTH'} key of the C{environ} C{dict} passed to the
application contains the value of the I{Content-Length} request header
(RFC 3875, section 4.1.2).
rñ   rò   r^   ÚCONTENT_LENGTHN)úcontent-lengthÚ1234rE  r  r:  s      r'   Útest_contentLengthÚEnvironTests.test_contentLengthQ  sƒ   € ð —+‘+˜e U¨B°°Ó5ˆØ×Ñ˜D×0Ñ0Ð1AÀ2ÓFÔGà—+‘+Ø�5˜"˜r˜d DÐ+EÐ*Fó
ˆð 	×Ñ˜D×0Ñ0Ð1AÀ6ÓJÔKä˜gÐ/Ó0Ð0r1   c                 ó  • S H‡  nU R                  5       u  p#UR                  R                  SU5        UR                  5         UR	                  U R                  SS5      5        U R                  U R                  U5      [        5        M‰     g)zl
The C{'CONTENT_LENGTH'} key of the C{environ} C{dict} passed to the
application is always a native string.
)s   1234rE  s   Content-LengthrC  rE  Nr>  )r#   ÚcontentLengthr°   r½   s       r'   Ú test_contentLengthIsNativeStringÚ-EnvironTests.test_contentLengthIsNativeStringa  sx   € ó
 -ˆMØ"×1Ñ1Ó3‰OˆGØ×"Ñ"×/Ñ/Ð0AÀ=ÔQØ×#Ñ#Ô%Ø×Ñ˜t×3Ñ3Ð4DÀfÓMÔNØ×!Ñ! $×"6Ñ"6°vÓ">ÄÖDò -r1   c                 óø   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SS/ S/SS/5      nUR                  U R                  SS5      5        [        X/5      $ )	a/  
The C{'SERVER_NAME'} key of the C{environ} C{dict} passed to the
application contains the best determination of the server hostname
possible, using either the value of the I{Host} header in the request
or the address the server is listening on if that header is not
present (RFC 3875, section 4.1.14).
rñ   rò   r^   ÚSERVER_NAMEz10.0.0.1N)Úhostúexample.orgrO  r  r:  s      r'   Útest_serverNameÚEnvironTests.test_serverNamem  s~   € ð —+‘+˜e U¨B°°Ó5ˆð 	×Ñ˜D×0Ñ0°À
ÓKÔLà—+‘+˜e U¨B°°°dÐ=TÐ<UÓVˆØ×Ñ˜D×0Ñ0°ÀÓNÔOä˜gÐ/Ó0Ð0r1   c                 óþ   ^• S Hv  mU R                  5       u  pU4S jUl        UR                  5         UR                  U R	                  SS5      5        U R                  U R                  U5      [        5        Mx     g)zi
The C{'SERVER_NAME'} key of the C{environ} C{dict} passed to the
application is always a native string.
)s   host.example.comúhost.example.comc                  ó   >• T $ r>   r*   )Ú
serverNames   €r'   rB   Ú<EnvironTests.test_serverNameIsNativeString.<locals>.<lambda>‰  s   ø€ ±r1   rM  rS  N)rã   ÚgetRequestHostnamer¡   rû   rî   r   r  r÷   )r#   r°   r½   rU  s      @r'   Útest_serverNameIsNativeStringÚ*EnvironTests.test_serverNameIsNativeString  sn   ø€ ó
 BˆJØ"×1Ñ1Ó3‰OˆGô *<ˆGÔ&Ø×#Ñ#Ô%Ø×Ñ˜t×3Ñ3°MÐCUÓVÔWØ×!Ñ! $×"6Ñ"6°vÓ">ÄÖDò Br1   c                 ó¢   ^• SmU4S jnXl         U R                  SS/ S/5      nUR                  U R                  S[	        T5      5      5        U$ )z¬
The C{'SERVER_PORT'} key of the C{environ} C{dict} passed to the
application contains the port number of the server which received the
request (RFC 3875, section 4.1.15).
iB0  c                  ór   >• [        5       n [         R                  " 5       U l        TU R                  l        U $ r>   )r   rk   Ú	transportÚport)r¯   Ú
portNumbers    €r'   ÚmakeChannelÚ1EnvironTests.test_serverPort.<locals>.makeChannel–  s.   ø€ Ü"“nˆGÜ ,× 0Ò 0Ó 2ˆGÔØ%/ˆG×ÑÔ"ØˆNr1   rñ   rò   r^   ÚSERVER_PORT)r¤   r|   rû   rî   r÷   )r#   r_  rÇ   r^  s      @r'   Útest_serverPortÚEnvironTests.test_serverPortŽ  sO   ø€ ð ˆ
õ	ð *Ôà�K‰K˜˜u b¨2¨$Ó/ˆØ	�‰�d×*Ñ*¨=¼#¸j»/ÓJÔKØˆr1   c                 óÔ   • U R                  5       u  pUR                  5         UR                  U R                  SS5      5        U R	                  U R                  U5      [        5        g)zi
The C{'SERVER_PORT'} key of the C{environ} C{dict} passed to the
application is always a native string.
ra  Ú80Nr  r  s      r'   Útest_serverPortIsNativeStringÚ*EnvironTests.test_serverPortIsNativeString¢  sV   € ð
 ×-Ñ-Ó/‰ˆØ×ÑÔ!Ø×Ñ˜4×/Ñ/°¸tÓDÔEØ×Ñ˜d×2Ñ2°6Ó:¼CÕ@r1   c                 óò   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U R                  SS/ S/5      nUR                  U R                  SS5      5        [        X/5      $ )z§
The C{'SERVER_PROTOCOL'} key of the C{environ} C{dict} passed to the
application contains the HTTP version number received in the request
(RFC 3875, section 4.1.16).
rñ   z1.0r^   ÚSERVER_PROTOCOLzHTTP/1.0rò   zHTTP/1.1r  )r#   ÚoldÚnews      r'   Útest_serverProtocolÚ EnvironTests.test_serverProtocol¬  sq   € ð �k‰k˜% ¨¨R¨DÓ1ˆØ�‰˜×,Ñ,Ð->À
ÓKÔLà�k‰k˜% ¨¨R¨DÓ1ˆØ�‰˜×,Ñ,Ð->À
ÓKÔLä˜c˜ZÓ(Ð(r1   c                 óô   • S Hr  nU R                  5       u  p#S Ul        UR                  SS9  UR                  U R	                  SS5      5        U R                  U R                  U5      [        5        Mt     g)zm
The C{'SERVER_PROTOCOL'} key of the C{environ} C{dict} passed to the
application is always a native string.
)rà   rò   c                 ó   • g r>   r*   )Údatas    r'   rB   Ú@EnvironTests.test_serverProtocolIsNativeString.<locals>.<lambda>Ä  s   € ¨r1   rà   )r   ri  rò   N)rã   r�   r¡   rû   rî   r   r  r÷   )r#   ÚserverProtocolr°   r½   s       r'   Ú!test_serverProtocolIsNativeStringÚ.EnvironTests.test_serverProtocolIsNativeStringº  so   € ó
 ,ˆNØ"×1Ñ1Ó3‰OˆGñ .ˆGŒMØ×#Ñ#¨FÐ#Ñ3Ø×Ñ˜t×3Ñ3Ð4EÀuÓMÔNØ×!Ñ! $×"6Ñ"6°vÓ">ÄÖDò ,r1   c                 óv   • S nU R                  SS/ S/US9nUR                  U R                  SS5      5        U$ )z…
The C{'REMOTE_ADDR'} key of the C{environ} C{dict} passed to the
application contains the address of the client making the request.
c                  ó*   • [        [        SSS5      S9$ ©Nrk   ú192.168.1.1i80  ©Úpeer©r   r   r*   r1   r'   r¤   Ú4EnvironTests.test_remoteAddr.<locals>.channelFactoryÏ  ó   € Ü¤[°¸ÀuÓ%MÑNÐNr1   rñ   rò   r^   ©r¤   ÚREMOTE_ADDRrx  ©r|   rû   rî   ©r#   r¤   rÇ   s      r'   Útest_remoteAddrÚEnvironTests.test_remoteAddrÉ  sB   € ò	Oð �K‰K˜˜u b¨2¨$¸~ˆKÐNˆØ	�‰�d×*Ñ*¨=¸-ÓHÔIàˆr1   c                 óv   • S nU R                  SS/ S/US9nUR                  U R                  SS5      5        U$ )zŸ
The C{'REMOTE_ADDR'} key of the C{environ} C{dict} passed to
the application contains the address of the client making the
request when connecting over IPv6.
c                  ó*   • [        [        SSS5      S9$ )Nrk   ú::1iÒ  ry  )r   r   r*   r1   r'   r¤   Ú8EnvironTests.test_remoteAddrIPv6.<locals>.channelFactoryÞ  s   € Ü¤[°¸¸tÓ%DÑEÐEr1   rñ   rò   r^   r~  r  r†  r€  r�  s      r'   Útest_remoteAddrIPv6Ú EnvironTests.test_remoteAddrIPv6×  sB   € ò	Fð �K‰K˜˜u b¨2¨$¸~ˆKÐNˆØ	�‰�d×*Ñ*¨=¸%Ó@ÔAàˆr1   c                 óv   • S nU R                  SS/ S/US9nUR                  U R                  SS5      5        U$ )z‚
The C{'REMOTE_PORT'} key of the C{environ} C{dict} passed to the
application contains the port of the client making the request.
c                  ó*   • [        [        SSS5      S9$ rw  r{  r*   r1   r'   r¤   Ú4EnvironTests.test_remotePort.<locals>.channelFactoryì  r}  r1   rñ   rò   r^   r~  ÚREMOTE_PORTÚ12344r€  r�  s      r'   Útest_remotePortÚEnvironTests.test_remotePortæ  sB   € ò	Oð �K‰K˜˜u b¨2¨$¸~ˆKÐNˆØ	�‰�d×*Ñ*¨=¸'ÓBÔCàˆr1   c           	      óÖ  ^ • T R                  SS/ S/SSS/5      nU 4S jnUR                  U5        T R                  SS/ S/SSS/5      nUR                  T R                  S	S
5      5        T R                  SS/ S/SS/5      nUR                  T R                  SS5      5        T R                  SS/ S/SS/5      nUR                  T R                  S	S5      5        [        XXE/5      $ )z„
HTTP request headers are copied into the C{environ} C{dict} passed to
the application with a C{HTTP_} prefix added to their names.
rñ   rò   r^   Nr+  ©ÚbazÚquuxc                 ób   >• U u  pTR                  US   S5        TR                  US   S5        g )NÚHTTP_FOOr  ÚHTTP_BAZr”  ré   )r½   r@   rA   r#   s      €r'   rù   Ú-EnvironTests.test_headers.<locals>.cbRenderedý  s5   ø€ Ø%+Ñ"ˆGØ×Ñ˜W ZÑ0°%Ô8Ø×Ñ˜W ZÑ0°&Õ9r1   )r  r“  r–  zbar,baz)zfoo-barr“  ÚHTTP_FOO_BARr“  )r  zbar
	bazzbar 	bazr  )r#   ÚsingleValuerù   Ú
multiValueÚ
withHyphenÚ	multiLines   `     r'   Útest_headersÚEnvironTests.test_headersô  sý   ø€ ð
 —k‘kØ�5˜"˜r˜d D¨>¸?Ð*Kó
ˆõ	:ð
 	×Ñ 
Ô+à—[‘[Ø�5˜"˜r˜d D¨>¸>Ð*Jó
ˆ
ð 	×Ñ˜t×3Ñ3°JÀ	ÓJÔKà—[‘[ ¨¨r°B°4¸Ð@RÐ?SÓTˆ
Ø×Ñ˜t×3Ñ3°NÀEÓJÔKà—K‘K  u¨b°2°$¸Ð?TÐ>UÓVˆ	Ø×Ñ˜d×2Ñ2°:¸{ÓKÔLä˜k°zÐMÓNÐNr1   c                 ór   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U$ )z•
The C{'wsgi.version'} key of the C{environ} C{dict} passed to the
application has the value C{(1, 0)} indicating that this is a WSGI 1.0
container.
rñ   rò   r^   zwsgi.version)rx   r   r€  )r#   ÚversionDeferreds     r'   Útest_wsgiVersionÚEnvironTests.test_wsgiVersion  s;   € ð Ÿ+™+ e¨U°B¸¸Ó=ˆØ×#Ñ# D×$8Ñ$8¸ÈÓ$PÔQØÐr1   c                 ór   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U$ )zd
The C{'wsgi.run_once'} key of the C{environ} C{dict} passed to the
application is set to C{False}.
rñ   rò   r^   zwsgi.run_onceFr€  )r#   Úonces     r'   Útest_wsgiRunOnceÚEnvironTests.test_wsgiRunOnce  s:   € ð
 �{‰{˜5 %¨¨b¨TÓ2ˆØ×Ñ˜×-Ñ-¨o¸uÓEÔFØˆr1   c                 ór   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U$ )zf
The C{'wsgi.multithread'} key of the C{environ} C{dict} passed to the
application is set to C{True}.
rñ   rò   r^   zwsgi.multithreadTr€  )r#   Úthreads     r'   Útest_wsgiMultithreadÚ!EnvironTests.test_wsgiMultithread$  s;   € ð
 —‘˜U E¨2°¨tÓ4ˆØ×Ñ˜4×/Ñ/Ð0BÀDÓIÔJØˆr1   c                 ór   • U R                  SS/ S/5      nUR                  U R                  SS5      5        U$ )zh
The C{'wsgi.multiprocess'} key of the C{environ} C{dict} passed to the
application is set to C{False}.
rñ   rò   r^   zwsgi.multiprocessFr€  )r#   Úprocesss     r'   Útest_wsgiMultiprocessÚ"EnvironTests.test_wsgiMultiprocess-  s;   € ð
 —+‘+˜e U¨B°°Ó5ˆØ×Ñ˜D×0Ñ0Ð1DÀeÓLÔMØˆr1   c                 ó  • S n[         U l        U R                  SS/ S/5      nUR                  U R	                  SS5      5        Xl        U R                  SS/ S/5      nUR                  U R	                  SS5      5        [        X#/5      $ )zn
The C{'wsgi.url_scheme'} key of the C{environ} C{dict} passed to the
application has the request URL scheme.
c                  óN   • [        5       n [         R                  " 5       U l        U $ r>   )r   ÚSSLr\  ©r¯   s    r'   r¤   Ú7EnvironTests.test_wsgiURLScheme.<locals>.channelFactory>  s   € Ü"“nˆGÜ ,× 0Ò 0Ó 2ˆGÔØˆNr1   rñ   rò   r^   zwsgi.url_schemeÚhttpÚhttps)r   r¤   r|   rû   rî   r
   )r#   r¤   ÚhttpDeferredÚhttpsDeferreds       r'   Útest_wsgiURLSchemeÚEnvironTests.test_wsgiURLScheme6  s‰   € ò	ô
 +ˆÔØ—{‘{ 5¨%°°b°TÓ:ˆØ× Ñ  ×!5Ñ!5Ð6GÈÓ!PÔQà,ÔØŸ™ E¨5°"°r°dÓ;ˆØ×!Ñ! $×"6Ñ"6Ð7HÈ'Ó"RÔSä˜lÐ:Ó;Ð;r1   c                 óš   ^ ^• [         R                  " T [        5      mT R                  SS/ S/5      nUU 4S jnUR	                  U5        U$ )a0  
The C{'wsgi.errors'} key of the C{environ} C{dict} passed to the
application is a file-like object (as defined in the U{Input and Errors
Streams<http://www.python.org/dev/peps/pep-0333/#input-and-error-streams>}
section of PEP 333) which converts bytes written to it into events for
the logging system.
rñ   rò   r^   c                 óÐ  >• U u  pUS   nUR                  S5        UR                  S/5        UR                  5         TR                  TS   S   S5        TR                  TS   S   S5        TR	                  TS   S	   5        TR                  TS
   S   S5        TR                  TS
   S   S5        TR	                  TS
   S	   5        TR                  [        T5      S5        g )Núwsgi.errorsúsome message
úanother
message
r   Úmessage)r¾  ÚsystemÚwsgiÚisErrorrx   )r¿  é   )r�   Ú
writelinesÚflushrê   rI   r~   )r½   r@   ÚstartApplicationÚerrorsÚeventsr#   s       €€r'   ÚcbErrorsÚ.EnvironTests.test_wsgiErrors.<locals>.cbErrorsY  sá   ø€ Ø(.Ñ%ˆGØ˜]Ñ+ˆFØ�L‰LÐ)Ô*Ø×ÑÐ3Ð4Ô5Ø�L‰LŒNØ×Ñ˜V A™Y yÑ1Ð3FÔGØ×Ñ˜V A™Y xÑ0°&Ô9Ø�O‰O˜F 1™I iÑ0Ô1Ø×Ñ˜V A™Y yÑ1Ð3JÔKØ×Ñ˜V A™Y xÑ0°&Ô9Ø�O‰O˜F 1™I iÑ0Ô1Ø×ÑœS ›[¨!Õ,r1   )r   rz   r   r|   rû   )r#   rÈ  rÊ  rÉ  s   `  @r'   Útest_wsgiErrorsÚEnvironTests.test_wsgiErrorsM  sH   ù€ ô &×7Ò7¸Ô>PÓQˆà—‘˜U E¨2°¨tÓ4ˆö	-ð 	×Ñ˜8Ô$Øˆr1   c                 óð   • U R                  5       u  pUR                  5         U R                  U5      u  p4US   nU R                  [        UR
                  S5      nU R                  S[        U5      5        g)z°
The C{'wsgi.errors'} file-like object from the C{environ} C{dict}
permits writes of only native strings in Python 3, and raises
C{TypeError} for writes of non-native strings.
r½  s   fredz1write() argument must be str, not b'fred' (bytes)N)rã   r¡   r  rO   r  r�   rê   r÷   )r#   r°   r½   r@   Ú_rÈ  Úerrors          r'   Ú0test_wsgiErrorsAcceptsOnlyNativeStringsInPython3Ú=EnvironTests.test_wsgiErrorsAcceptsOnlyNativeStringsInPython3j  sk   € ð ×-Ñ-Ó/‰ˆØ×ÑÔ!Ø×)Ñ)¨&Ó1‰
ˆØ˜Ñ'ˆà×!Ñ!¤)¨V¯\©\¸7ÓCˆØ×ÑØ?ÄÀUÃõ	
r1   r~  N)%r+   r,   r-   r.   r/   rî   rü   r  r	  r  r  r$  r'  r1  r4  r;  r@  rF  rJ  rP  rX  rb  rf  rl  rs  r‚  rˆ  r�  rž  r¢  r¦  rª  r®  r¹  rÌ  rÑ  r0   r*   r1   r'   ræ   ræ   r  s¯   † ñò
%òò"*ò 	EòWò<Kò 
òDSòSò8Sò1ò 
Eò1ò 
Eò1ò$Eòò(Aò)òEòòòòOò:òòòò<ò.õ:
r1   ræ   c                   óœ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)ÚInputStreamTestMixini{  zÄ
A mixin for L{TestCase} subclasses which defines a number of tests against
L{_InputStream}.  The subclass is expected to create a file-like object to
be wrapped by an L{_InputStream} under test.
c                 óF   • [        U R                  R                   S35      e)Nz.getFile must be implemented)ÚNotImplementedErrorÚ	__class__r+   rE   s    r'   ÚgetFileTypeÚ InputStreamTestMixin.getFileType‚  s%   € Ü!Ø�~‰~×&Ñ&Ð'Ð'CÐDó
ð 	
r1   c                 ó¤   ^• U R                  5       m " U4S jS[        5      nS nU" U5      u  pVU R                  UU[        SS/ S/S / U5
        U$ )Nc                   ó"   >• \ rS rSrU 4S jrSrg)ÚLInputStreamTestMixin._renderAndReturnReaderResult.<locals>.CustomizedRequestiŠ  c                 ó   >• T" 5       U l         g r>   ©rœ   )r#   Úlengthr?  s     €r'   r›   ÚVInputStreamTestMixin._renderAndReturnReaderResult.<locals>.CustomizedRequest.gotLength‹  s   ø€ ñ  +›}�•r1   rÞ  N)r+   r,   r-   r.   r›   r0   )r?  s   €r'   ÚCustomizedRequestrÜ  Š  s   ø† ÷-ð -r1   rá  c                 ó0   ^ ^• [        5       mU U4S jnTU4$ )Nc                  ó   >• UU4S jn U $ )Nc                  óh   >• U u  pTR                  T" US   5      5        U" S/ 5        [        S5      $ )Nz
wsgi.inputr¹   r*   rº   )rc   r@   rA   Úreaderr½   s      €€r'   rp   Ú}InputStreamTestMixin._renderAndReturnReaderResult.<locals>.appFactoryFactory.<locals>.applicationFactory.<locals>.application•  s4   ø€ Ø-1Ñ*�GØ—O‘O¡F¨7°<Ñ+@Ó$AÔBÙ! (¨BÔ/Ü ›8�Or1   r*   )rp   rå  r½   s    €€r'   r£   ÚhInputStreamTestMixin._renderAndReturnReaderResult.<locals>.appFactoryFactory.<locals>.applicationFactory”  s   ø€ ö$ð #Ð"r1   rÊ   )rå  r£   r½   s   ` @r'   ÚappFactoryFactoryÚLInputStreamTestMixin._renderAndReturnReaderResult.<locals>.appFactoryFactory‘  s   ù€ Ü“ZˆFö#ð Ð-Ð-Ð-r1   ÚPUTrò   r^   )rØ  r   r³   r   )r#   rå  rœ   rá  rè  rÇ   Ú
appFactoryr?  s          @r'   Ú_renderAndReturnReaderResultÚ1InputStreamTestMixin._renderAndReturnReaderResult‡  se   ø€ Ø×&Ñ&Ó(ˆ÷	-¤ô 	-ò	.ñ *¨&Ó1‰ˆØ×ÑØØÜØØØØˆDØØØô	
ð ˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  U5        U$ )zQ
Calling L{_InputStream.read} with no arguments returns the entire input
stream.
ó   some bytes are herec                 ó"   • U R                  5       $ r>   ©Úread©Úinputs    r'   rB   Ú3InputStreamTestMixin.test_readAll.<locals>.<lambda>´  s
   € ¸E¿J¹J¼Lr1   ©rì  rû   rê   ©r#   rŽ   rÇ   s      r'   Útest_readAllÚ!InputStreamTestMixin.test_readAll®  s5   € ð
 'ˆØ×-Ñ-Ñ.HÈ%ÓPˆØ	�‰�d×&Ñ&¨Ô.Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )z©
Calling L{_InputStream.read} with an integer returns that many bytes
from the input stream, as long as it is less than or equal to the total
number of bytes available.
s   hello, world.c                 ó$   • U R                  S5      $ ©Né   rñ  ró  s    r'   rB   Ú4InputStreamTestMixin.test_readSome.<locals>.<lambda>¿  s   € ¸E¿J¹JÀq¼Mr1   s   helrö  r÷  s      r'   Útest_readSomeÚ"InputStreamTestMixin.test_readSome¸  s5   € ð !ˆØ×-Ñ-Ñ.IÈ5ÓQˆØ	�‰�d×&Ñ&¨Ô/Øˆr1   c                 óp   ^• SmU R                  U4S jT5      nUR                  U R                  T5        U$ )z˜
Calling L{_InputStream.read} with an integer that is greater than the
total number of bytes in the input stream returns all bytes in the
input stream.
rï  c                 ó>   >• U R                  [        T5      S-   5      $ rü  )rò  r~   )rô  rŽ   s    €r'   rB   Ú8InputStreamTestMixin.test_readMoreThan.<locals>.<lambda>Ë  s   ø€ ˜%Ÿ*™*¤S¨£Z°!¡^Ô4r1   rö  )r#   rÇ   rŽ   s     @r'   Útest_readMoreThanÚ&InputStreamTestMixin.test_readMoreThanÃ  s:   ø€ ð 'ˆØ×-Ñ-Ü4°eó
ˆð 	
�‰�d×&Ñ&¨Ô.Øˆr1   c                 óp   • SnS nU R                  X!5      nUR                  U R                  USS 5        U$ )zˆ
Calling L{_InputStream.read} a second time returns bytes starting from
the position after the last byte returned by the previous read.
s   some bytes, helloc                 óD   • U R                  S5        U R                  5       $ rü  rñ  ró  s    r'   rò  Ú1InputStreamTestMixin.test_readTwice.<locals>.read×  s   € Ø�J‰J�qŒMØ—:‘:“<Ðr1   rý  Nrö  )r#   rŽ   rò  rÇ   s       r'   Útest_readTwiceÚ#InputStreamTestMixin.test_readTwiceÐ  s?   € ð
 %ˆò	 ð ×-Ñ-¨dÓ:ˆØ	�‰�d×&Ñ&¨¨a¨b¨	Ô2Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  U5        U$ )za
Calling L{_InputStream.read} with L{None} as an argument returns all
bytes in the input stream.
s   the entire streamc                 ó$   • U R                  S 5      $ r>   rñ  ró  s    r'   rB   Ú4InputStreamTestMixin.test_readNone.<locals>.<lambda>å  s   € ¸E¿J¹JÀtÔ<Lr1   rö  r÷  s      r'   Útest_readNoneÚ"InputStreamTestMixin.test_readNoneß  s5   € ð
 %ˆØ×-Ñ-Ñ.LÈeÓTˆØ	�‰�d×&Ñ&¨Ô.Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  U5        U$ )zl
Calling L{_InputStream.read} with a negative integer as an argument
returns all bytes in the input stream.
s   all of the inputc                 ó$   • U R                  S5      $ ©Néÿÿÿÿrñ  ró  s    r'   rB   Ú8InputStreamTestMixin.test_readNegative.<locals>.<lambda>ï  s   € ¸E¿J¹JÀr¼Nr1   rö  r÷  s      r'   Útest_readNegativeÚ&InputStreamTestMixin.test_readNegativeé  s5   € ð
 $ˆØ×-Ñ-Ñ.JÈEÓRˆØ	�‰�d×&Ñ&¨Ô.Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )z[
Calling L{_InputStream.readline} with no argument returns one line from
the input stream.
s   hello
worldc                 ó"   • U R                  5       $ r>   ©Úreadlineró  s    r'   rB   Ú4InputStreamTestMixin.test_readline.<locals>.<lambda>ù  s   € ¸E¿N¹NÔ<Lr1   s   hello
rö  r÷  s      r'   Útest_readlineÚ"InputStreamTestMixin.test_readlineó  s5   € ð
  ˆØ×-Ñ-Ñ.LÈeÓTˆØ	�‰�d×&Ñ&¨
Ô3Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )aØ  
Calling L{_InputStream.readline} with an integer returns at most that
many bytes, even if it is not enough to make up a complete line.

COMPATIBILITY NOTE: the size argument is excluded from the WSGI
specification, but is provided here anyhow, because useful libraries
such as python stdlib's cgi.py assume their input file-like-object
supports readline with a size argument. If you use it, be aware your
application may not be portable to other conformant WSGI servers.
s   goodbye
worldc                 ó$   • U R                  S5      $ rü  r  ró  s    r'   rB   Ú8InputStreamTestMixin.test_readlineSome.<locals>.<lambda>	  s   € ¸E¿N¹NÈ1Ô<Mr1   s   goorö  r÷  s      r'   Útest_readlineSomeÚ&InputStreamTestMixin.test_readlineSomeý  s5   € ð "ˆØ×-Ñ-Ñ.MÈuÓUˆØ	�‰�d×&Ñ&¨Ô/Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )z‰
Calling L{_InputStream.readline} with an integer which is greater than
the number of bytes in the next line returns only the next line.
s   some lines
of textc                 ó$   • U R                  S5      $ )Né   r  ró  s    r'   rB   Ú<InputStreamTestMixin.test_readlineMoreThan.<locals>.<lambda>  ó   € ¸E¿N¹NÈ2Ô<Nr1   s   some lines
rö  r÷  s      r'   Útest_readlineMoreThanÚ*InputStreamTestMixin.test_readlineMoreThan  s6   € ð
 'ˆØ×-Ñ-Ñ.NÐPUÓVˆØ	�‰�d×&Ñ&¨Ô8Øˆr1   c                 ój   • SnS nU R                  X!5      nUR                  U R                  S5        U$ )zp
Calling L{_InputStream.readline} a second time returns the line
following the line returned by the first call.
s    first line
second line
last linec                 óB   • U R                  5         U R                  5       $ r>   r  ró  s    r'   r  Ú9InputStreamTestMixin.test_readlineTwice.<locals>.readline  s   € Ø�N‰NÔØ—>‘>Ó#Ð#r1   s   second line
rö  )r#   rŽ   r  rÇ   s       r'   Útest_readlineTwiceÚ'InputStreamTestMixin.test_readlineTwice  s:   € ð
 6ˆò	$ð ×-Ñ-¨hÓ>ˆØ	�‰�d×&Ñ&Ð(8Ô9Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )zf
Calling L{_InputStream.readline} with L{None} as an argument returns
one line from the input stream.
s%   this is one line
this is another linec                 ó$   • U R                  S 5      $ r>   r  ró  s    r'   rB   Ú8InputStreamTestMixin.test_readlineNone.<locals>.<lambda>,  s   € ¸E¿N¹NÈ4Ô<Pr1   s   this is one line
rö  r÷  s      r'   Útest_readlineNoneÚ&InputStreamTestMixin.test_readlineNone&  s7   € ð
 :ˆØ×-Ñ-Ñ.PÐRWÓXˆØ	�‰�d×&Ñ&Ð(=Ô>Øˆr1   c                 óh   • SnU R                  S U5      nUR                  U R                  S5        U$ )zq
Calling L{_InputStream.readline} with a negative integer as an argument
returns one line from the input stream.
s   input stream line one
line twoc                 ó$   • U R                  S5      $ r  r  ró  s    r'   rB   Ú<InputStreamTestMixin.test_readlineNegative.<locals>.<lambda>6  r'  r1   s   input stream line one
rö  r÷  s      r'   Útest_readlineNegativeÚ*InputStreamTestMixin.test_readlineNegative0  s7   € ð
 3ˆØ×-Ñ-Ñ.NÐPUÓVˆØ	�‰�d×&Ñ&Ð(BÔCØˆr1   c                 ól   • SnU R                  S U5      nUR                  U R                  / SQ5        U$ )zh
Calling L{_InputStream.readlines} with no arguments returns a list of
all lines from the input stream.
s   alice
bob
carolc                 ó"   • U R                  5       $ r>   ©Ú	readlinesró  s    r'   rB   Ú5InputStreamTestMixin.test_readlines.<locals>.<lambda>@  s   € ¸E¿O¹OÔ<Mr1   )s   alice
s   bob
s   carolrö  r÷  s      r'   Útest_readlinesÚ#InputStreamTestMixin.test_readlines:  s6   € ð
 %ˆØ×-Ñ-Ñ.MÈuÓUˆØ	�‰�d×&Ñ&Ò(HÔIØˆr1   c                 ó`   ^ • SnT R                  S U5      nU 4S jnUR                  U5        U$ )zÈ
Calling L{_InputStream.readlines} with an integer as an argument
returns a list of lines from the input stream with the argument serving
as an approximate bound on the total number of bytes to read.
s   123
456
789
0c                 ó$   • U R                  S5      $ )Né   r;  ró  s    r'   rB   Ú9InputStreamTestMixin.test_readlinesSome.<locals>.<lambda>K  s   € ¸E¿O¹OÈAÔ<Nr1   c                 ó4   >• TR                  U S S SS/5        g )NrÄ  s   123
s   456
ré   )Úlinesr#   s    €r'   ÚcbLinesÚ8InputStreamTestMixin.test_readlinesSome.<locals>.cbLinesM  s    ø€ ð ×Ñ˜U 2 A˜Y¨°8Ð(<Õ=r1   )rì  rû   )r#   rŽ   rÇ   rF  s   `   r'   Útest_readlinesSomeÚ'InputStreamTestMixin.test_readlinesSomeD  s6   ø€ ð $ˆØ×-Ñ-Ñ.NÐPUÓVˆõ	>ð
 	
�‰�gÔØˆr1   c                 ól   • SnU R                  S U5      nUR                  U R                  / SQ5        U$ )z£
Calling L{_InputStream.readlines} with an integer which is greater than
the total number of bytes in the input stream returns a list of all
lines from the input.
s"   one potato
two potato
three potatoc                 ó$   • U R                  S5      $ )Néd   r;  ró  s    r'   rB   Ú=InputStreamTestMixin.test_readlinesMoreThan.<locals>.<lambda>\  s   € ¸E¿O¹OÈCÔ<Pr1   )s   one potato
s   two potato
s   three potatorö  r÷  s      r'   Útest_readlinesMoreThanÚ+InputStreamTestMixin.test_readlinesMoreThanU  s<   € ð 8ˆØ×-Ñ-Ñ.PÐRWÓXˆØ	�‰Ø×ÑÒQô	
ð ˆr1   c                 ón   • SnS nU R                  X!5      nUR                  U R                  SS/5        U$ )z�
Calling L{_InputStream.readlines} after a call to L{_InputStream.read}
returns lines starting at the byte after the last byte returned by the
C{read} call.
s   hello
world
fooc                 óD   • U R                  S5        U R                  5       $ )Né   )rò  r<  ró  s    r'   r<  Ú?InputStreamTestMixin.test_readlinesAfterRead.<locals>.readlinesj  s   € Ø�J‰J�qŒMØ—?‘?Ó$Ð$r1   s   orld
rN   rö  )r#   rŽ   r<  rÇ   s       r'   Útest_readlinesAfterReadÚ,InputStreamTestMixin.test_readlinesAfterReadb  s>   € ð %ˆò	%ð ×-Ñ-¨iÓ?ˆØ	�‰�d×&Ñ&¨°FÐ(;Ô<Øˆr1   c                 ól   • SnU R                  S U5      nUR                  U R                  SS/5        U$ )za
Calling L{_InputStream.readlines} with L{None} as an argument returns
all lines from the input.
s   one fish
two fish
c                 ó$   • U R                  S 5      $ r>   r;  ró  s    r'   rB   Ú9InputStreamTestMixin.test_readlinesNone.<locals>.<lambda>y  s   € ˜%Ÿ/™/¨$Ô/r1   s	   one fish
s	   two fish
rö  r÷  s      r'   Útest_readlinesNoneÚ'InputStreamTestMixin.test_readlinesNoner  s>   € ð
 (ˆØ×-Ñ-Ù/°ó
ˆð 	
�‰�d×&Ñ&¨¸Ð(FÔGØˆr1   c                 ól   • SnU R                  S U5      nUR                  U R                  SS/5        U$ )zv
Calling L{_InputStream.readlines} with a negative integer as an
argument returns a list of all lines from the input.
s   red fish
blue fish
c                 ó$   • U R                  S5      $ r  r;  ró  s    r'   rB   Ú=InputStreamTestMixin.test_readlinesNegative.<locals>.<lambda>„  s   € ¸E¿O¹OÈBÔ<Or1   s	   red fish
s
   blue fish
rö  r÷  s      r'   Útest_readlinesNegativeÚ+InputStreamTestMixin.test_readlinesNegative~  s;   € ð
 )ˆØ×-Ñ-Ñ.OÐQVÓWˆØ	�‰�d×&Ñ&¨¸Ð(GÔHØˆr1   c                 ól   • SnU R                  S U5      nUR                  U R                  SS/5        U$ )zF
Iterating over L{_InputStream} produces lines from the input stream.
ó   green eggs
and ham
c                 ó   • [        U 5      $ r>   )Úlistró  s    r'   rB   Ú4InputStreamTestMixin.test_iterable.<locals>.<lambda>�  s   € ¼DÀ¼Kr1   s   green eggs
ó   and ham
rö  r÷  s      r'   Útest_iterableÚ"InputStreamTestMixin.test_iterableˆ  s:   € ð )ˆØ×-Ñ-Ñ.GÈÓOˆØ	�‰�d×&Ñ&¨¸,Ð(GÔHØˆr1   c                 ón   • SnS nU R                  X!5      nUR                  U R                  SS/5        U$ )z·
Iterating over L{_InputStream} after calling L{_InputStream.read}
produces lines from the input stream starting from the first byte after
the last byte returned by the C{read} call.
ra  c                 ó:   • U R                  S5        [        U 5      $ rü  )rò  rc  ró  s    r'   ÚiterateÚ<InputStreamTestMixin.test_iterableAfterRead.<locals>.iterate™  s   € Ø�J‰J�qŒMÜ˜“;Ðr1   s   en eggs
re  rö  )r#   rŽ   rj  rÇ   s       r'   Útest_iterableAfterReadÚ+InputStreamTestMixin.test_iterableAfterRead‘  s>   € ð )ˆò	ð ×-Ñ-¨gÓ=ˆØ	�‰�d×&Ñ&¨°|Ð(DÔEØˆr1   r*   N)r+   r,   r-   r.   r/   rØ  rì  rø  rÿ  r  r	  r  r  r  r!  r(  r-  r2  r7  r>  rH  rN  rT  rY  r^  rf  rl  r0   r*   r1   r'   rÔ  rÔ  {  sv   † ñò
ò
%òNò	òòòòòòò òòòòòò"òò 
òòõr1   rÔ  c                   ó   • \ rS rSrSrS rSrg)ÚInputStreamBytesIOTestsi¢  zG
Tests for L{_InputStream} when it is wrapped around an L{io.BytesIO}.
c                 ó   • SSK Jn  U$ )Nr   )ÚBytesIO)Úiorq  )r#   rq  s     r'   rØ  Ú#InputStreamBytesIOTests.getFileType§  s
   € Ýàˆr1   r*   N©r+   r,   r-   r.   r/   rØ  r0   r*   r1   r'   ro  ro  ¢  s   † ñõr1   ro  c                   ó   • \ rS rSrSrS rSrg)ÚInputStreamTemporaryFileTestsi­  zR
Tests for L{_InputStream} when it is wrapped around a L{tempfile.TemporaryFile}.
c                 ó"   • [         R                  $ r>   )ÚtempfileÚTemporaryFilerE   s    r'   rØ  Ú)InputStreamTemporaryFileTests.getFileType²  s   € Ü×%Ñ%Ð%r1   r*   Nrt  r*   r1   r'   rv  rv  ­  s   † ñõ&r1   rv  c                   ó–   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)ÚStartResponseTestsi¶  z`
Tests for the I{start_response} parameter passed to the application object
by L{WSGIResource}.
c                 ó´   ^ ^• [        5       mS nT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )zw
The response status passed to the I{start_response} callable is written
as the status of the response to the request.
c                  ó   • S n U $ )Nc                 ó*   • U" S/ 5        [        S5      $ )Nz107 Strange messager*   ©r¼   r?   s     r'   rp   ÚOStartResponseTests.test_status.<locals>.applicationFactory.<locals>.applicationÄ  s   € ÙÐ3°RÔ8Ü˜B“x�r1   r*   ©rp   s    r'   r£   Ú:StartResponseTests.test_status.<locals>.applicationFactoryÃ  ó   € ò ð Ðr1   c                 óŠ   >• TR                  TR                  R                  R                  5       R	                  S5      5        g )Ns   HTTP/1.1 107 Strange message©rI   r\  ÚwrittenÚgetvalueÚ
startswith©Úignoredr¯   r#   s    €€r'   rù   Ú2StartResponseTests.test_status.<locals>.cbRenderedÌ  s5   ø€ Ø�O‰OØ×!Ñ!×)Ñ)×2Ñ2Ó4×?Ñ?Ø3óõr1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú0StartResponseTests.test_status.<locals>.<lambda>Ø  ó   ø€ ‘Gr1   rñ   rò   r^   N©r   rË   rû   r³   ©r#   r£   rÇ   r¢   rù   r¯   s   `    @r'   Útest_statusÚStartResponseTests.test_status¼  si   ù€ ô
 “.ˆò	ð !×6Ñ6Ó8Ñˆö	ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó²   ^ ^• SmU4S jnT R                  U5      u  p#UR                  5         U 4S jnT R                  U[        5      R	                  U5      $ )zp
The response status passed to the I{start_response} callable MUST be a
native string in Python 2 and Python 3.
s   200 OKc                 ó,   >• U" T/ 5        [        S5      $ )Nr*   r€  )r@   rA   Ústatuss     €r'   rp   ÚEStartResponseTests.test_statusMustBeNativeString.<locals>.applicationê  s   ø€ Ù˜& "Ô%Ü˜“8ˆOr1   c                 ó<   >• TR                  S[        U 5      5        g )Nz)status must be str, not b'200 OK' (bytes)©rê   r÷   ©rÐ  r#   s    €r'   ÚcheckMessageÚFStartResponseTests.test_statusMustBeNativeString.<locals>.checkMessageñ  s   ø€ Ø×ÑÐHÌ#ÈeË*ÕUr1   ©rã   r¡   ÚassertFailurer  rû   )r#   rp   r°   r½   r›  r–  s   `    @r'   Útest_statusMustBeNativeStringÚ0StartResponseTests.test_statusMustBeNativeStringã  sU   ù€ ð
 ˆõ	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!õ	Vð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 óð   ^ ^^^• T R                  [        SS 5        [        5       mU4S jnT R                  5       u  pEUUU 4S jnUR	                  U5        T R                  UUU4S jSS/ S/S	/ 5	        U$ )
zë
Verify that if the response headers given by C{appHeaders} are passed
to the I{start_response} callable, then the response header lines given
by C{expectedHeaders} plus I{Server} and I{Date} header lines are
included in the response.
ÚdatetimeToStringc                  ó   • g)NÚTuesdayr*   r*   r1   r'   rB   Ú1StartResponseTests._headersTest.<locals>.<lambda>þ  s   € °yr1   c                  ó   >• U4S jn U $ )Nc                 ó,   >• U" ST5        [        S5      $ r¸   r€  )r@   rA   Ú
appHeaderss     €r'   rp   ÚPStartResponseTests._headersTest.<locals>.applicationFactory.<locals>.application  s   ø€ Ù˜h¨
Ô3Ü˜B“x�r1   r*   )rp   r¨  s    €r'   r£   Ú;StartResponseTests._headersTest.<locals>.applicationFactory  s   ø€ õ ð Ðr1   c                 ó  >• TR                   R                  R                  5       nUR                  SS5      u  p#UR                  S5      SS  nUR	                  5         TSS[
        -   S/-   nUR	                  5         TR                  XE5        g )NrÎ   rx   s   
s   Date: Tuesdays   Server: s   Transfer-Encoding: chunked)r\  r‡  rˆ  rÏ   Úsortr   rê   )	r‹  rÐ   r©   ÚrestÚheaderLinesÚallExpectedHeadersr¯   ÚexpectedHeadersr#   s	         €€€r'   rù   Ú3StartResponseTests._headersTest.<locals>.cbRendered  sŠ   ø€ Ø×(Ñ(×0Ñ0×9Ñ9Ó;ˆHØ$ŸN™N¨;¸Ó:‰MˆGØ!Ÿ-™-¨Ó0°°Ð4ˆKØ×ÑÔØ!0Ø ØœgÑ%Ø-ð4ñ "Ðð
 ×#Ñ#Ô%Ø×Ñ˜[Õ=r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   r¥    r�  r1   rñ   rò   r^   N)Úpatchr   r   rË   rû   r³   )r#   r¨  r°  r£   rÇ   r¢   rù   r¯   s   ```    @r'   Ú_headersTestÚStartResponseTests._headersTestö  s{   û€ ð 	�
‰
”6Ð-Ñ/@ÔAä“.ˆõ	ð !×6Ñ6Ó8Ñˆ÷	>ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó.   • U R                  SS/SS/5      $ )zÌ
The headers passed to the I{start_response} callable are included in
the response as are the required I{Date} and I{Server} headers and the
necessary connection (hop to hop) header I{Transfer-Encoding}.
r+  r’  s	   Baz: quuxs   Foo: bar©r´  rE   s    r'   rž  ÚStartResponseTests.test_headers'  s&   € ð × Ñ Ø˜_Ð-°¸kÐ/Jó
ð 	
r1   c                 ó´   ^ ^• S/mU4S jnT R                  U5      u  p#UR                  5         U 4S jnT R                  U[        5      R	                  U5      $ )zJ
The headers passed to the I{start_response} callable MUST be a
sequence.
©rë   r€   c                 ó>   >• U" S[        T5      5        [        S5      $ r¸   r€  )r@   rA   r©   s     €r'   rp   ÚBStartResponseTests.test_headersMustBeSequence.<locals>.application8  s   ø€ Ù˜(¤D¨£MÔ2Ü˜“8ˆOr1   c                 ó<   >• TR                  [        U 5      S5        g )NzKheaders must be a list, not <(list_?|sequence)iterator .+> [(]\1iterator[)]©ÚassertRegexr÷   rš  s    €r'   r›  ÚCStartResponseTests.test_headersMustBeSequence.<locals>.checkMessage?  s   ø€ Ø×ÑÜ�E“
ðCõr1   r�  )r#   rp   r°   r½   r›  r©   s   `    @r'   Útest_headersMustBeSequenceÚ-StartResponseTests.test_headersMustBeSequence1  sW   ù€ ð
 $Ð$ˆõ	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!õ	ð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 óš  • S nU R                  U5      u  p#[        R                  " SS9 nUR                  5         U R	                  U5      nSSS5        U R                  S[        W5      5        U R                  [        US   R                  5        U R                  S[        US   R                  5      5        g! , (       d  f       Nu= f)an  
According to PEP-3333, the headers passed to the I{start_response}
callable MUST be a plain list:

  The response_headers argument ... must be a Python list; i.e.
  type(response_headers) is ListType

However, for bug-compatibility, any sequence is accepted. In both
Python 2 and Python 3, only a warning is issued when a sequence other
than a list is encountered.
c                 ó*   • U" SS5        [        S5      $ )Nr¹   ))Únotrc  r*   r€  r?   s     r'   rp   ÚEStartResponseTests.test_headersShouldBePlainList.<locals>.applicationU  s   € Ù˜(Ð$6Ô7Ü˜“8ˆOr1   T©ÚrecordNrx   r   z8headers should be a list, not (('not', 'list'),) (tuple)©rã   ÚwarningsÚcatch_warningsr¡   r  rê   r~   ÚRuntimeWarningÚcategoryr÷   rÀ  ©r#   rp   r°   r½   Úcaughts        r'   Útest_headersShouldBePlainListÚ0StartResponseTests.test_headersShouldBePlainListH  s¨   € ò	ð ×-Ñ-¨kÓ:‰ˆä×$Ò$¨DÒ1°VØ×#Ñ#Ô%Ø×)Ñ)¨&Ó1ˆF÷ 2ð 	×Ñ˜œC ›KÔ(Ø×Ñœ¨°©×);Ñ);Ô<Ø×ÑØFÜ��q‘	×!Ñ!Ó"õ	
÷ 2Õ1úó   «"B<Â<
C
c                 ó²   ^ ^• SmU4S jnT R                  U5      u  p#UR                  5         U 4S jnT R                  U[        5      R	                  U5      $ )zJ
Each header passed to the I{start_response} callable MUST be a
sequence.
rº  c                 ó@   >• U" S[        T5      /5        [        S5      $ r¸   r€  )r@   rA   Úheaders     €r'   rp   ÚFStartResponseTests.test_headersMustEachBeSequence.<locals>.applicationl  s   ø€ Ù˜(¤T¨&£\ NÔ3Ü˜“8ˆOr1   c                 ó<   >• TR                  [        U 5      S5        g )Nz[header must be a [(]str, str[)] tuple, not <(tuple_?|sequence)iterator .+> [(]\1iterator[)]r¾  rš  s    €r'   r›  ÚGStartResponseTests.test_headersMustEachBeSequence.<locals>.checkMessages  s   ø€ Ø×ÑÜ�E“
ðDõr1   r�  )r#   rp   r°   r½   r›  rÕ  s   `    @r'   Útest_headersMustEachBeSequenceÚ1StartResponseTests.test_headersMustEachBeSequencee  sT   ù€ ð
 "ˆõ	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!õ	ð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 óš  • S nU R                  U5      u  p#[        R                  " SS9 nUR                  5         U R	                  U5      nSSS5        U R                  S[        W5      5        U R                  [        US   R                  5        U R                  S[        US   R                  5      5        g! , (       d  f       Nu= f)ah  
According to PEP-3333, each header passed to the I{start_response}
callable should be a tuple:

  The response_headers argument is a list of (header_name,
  header_value) tuples

However, for bug-compatibility, any 2 element sequence is also
accepted. In both Python 2 and Python 3, only a warning is issued when
a sequence other than a tuple is encountered.
c                 ó0   • U" SSS//5        [        S5      $ )Nr¹   rÅ  Útupler*   r€  r?   s     r'   rp   ÚEStartResponseTests.test_headersShouldEachBeTuple.<locals>.application‰  s   € Ù˜( e¨WÐ%5Ð$6Ô7Ü˜“8ˆOr1   TrÇ  Nrx   r   z@header should be a (str, str) tuple, not ['not', 'tuple'] (list)rÉ  rÎ  s        r'   Útest_headersShouldEachBeTupleÚ0StartResponseTests.test_headersShouldEachBeTuple|  s¨   € ò	ð ×-Ñ-¨kÓ:‰ˆä×$Ò$¨DÒ1°VØ×#Ñ#Ô%Ø×)Ñ)¨&Ó1ˆF÷ 2ð 	×Ñ˜œC ›KÔ(Ø×Ñœ¨°©×);Ñ);Ô<Ø×ÑØNÜ��q‘	×!Ñ!Ó"õ	
÷ 2Õ1úrÒ  c                 ó¦   ^ • S nT R                  U5      u  p#UR                  5         U 4S jnT R                  U[        5      R	                  U5      $ )zo
Each header passed to the I{start_response} callable MUST hold a key
and a value, and ONLY a key and a value.
c                 ó,   • U" SS/5        [        S5      $ )Nr¹   )ÚtooÚmanyÚcooksr*   r€  r?   s     r'   rp   ÚMStartResponseTests.test_headersShouldEachHaveKeyAndValue.<locals>.applicationŸ  s   € Ù˜(Ð%=Ð$>Ô?Ü˜“8ˆOr1   c                 ó<   >• TR                  S[        U 5      5        g )Nz?header must be a (str, str) tuple, not ('too', 'many', 'cooks')r™  rš  s    €r'   r›  ÚNStartResponseTests.test_headersShouldEachHaveKeyAndValue.<locals>.checkMessage¦  s   ø€ Ø×ÑØTÜ�E“
õr1   r�  ©r#   rp   r°   r½   r›  s   `    r'   Ú%test_headersShouldEachHaveKeyAndValueÚ8StartResponseTests.test_headersShouldEachHaveKeyAndValue™  sM   ø€ ò	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!õ	ð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 ó´   ^ ^• SmU4S jnT R                  U5      u  p#UR                  5         UU 4S jnT R                  U[        5      R	                  U5      $ )zm
Each header key passed to the I{start_response} callable MUST be at
native string in Python 2 and Python 3.
s   keyc                 ó2   >• U" STS4/5        [        S5      $ )Nr¹   r€   r*   r€  )r@   rA   rë   s     €r'   rp   ÚHStartResponseTests.test_headerKeyMustBeNativeString.<locals>.applicationµ  s   ø€ Ù˜( c¨7 ^Ð$4Ô5Ü˜“8ˆOr1   c                 óF   >• TR                  ST< S3[        U 5      5        g )Nz&header must be (str, str) tuple, not (z
, 'value')r™  )rÐ  rë   r#   s    €€r'   r›  ÚIStartResponseTests.test_headerKeyMustBeNativeString.<locals>.checkMessage¼  s$   ø€ Ø×ÑØ8¸¹¸zÐJÜ�E“
õr1   r�  )r#   rp   r°   r½   r›  rë   s   `    @r'   Ú test_headerKeyMustBeNativeStringÚ3StartResponseTests.test_headerKeyMustBeNativeString®  sT   ù€ ð
 ˆõ	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!ö	ð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 ó´   ^ ^• SmU4S jnT R                  U5      u  p#UR                  5         U U4S jnT R                  U[        5      R	                  U5      $ )zo
Each header value passed to the I{start_response} callable MUST be at
native string in Python 2 and Python 3.
s   valuec                 ó2   >• U" SST4/5        [        S5      $ )Nr¹   rë   r*   r€  )r@   rA   r€   s     €r'   rp   ÚJStartResponseTests.test_headerValueMustBeNativeString.<locals>.applicationË  s   ø€ Ù˜( e¨U ^Ð$4Ô5Ü˜“8ˆOr1   c                 óF   >• TR                  ST< S3[        U 5      5        g )Nz-header must be (str, str) tuple, not ('key', Ú)r™  )rÐ  r#   r€   s    €€r'   r›  ÚKStartResponseTests.test_headerValueMustBeNativeString.<locals>.checkMessageÒ  s$   ø€ Ø×ÑØ?À¹yÈÐJÜ�E“
õr1   r�  )r#   rp   r°   r½   r›  r€   s   `    @r'   Ú"test_headerValueMustBeNativeStringÚ5StartResponseTests.test_headerValueMustBeNativeStringÄ  sT   ù€ ð
 ˆõ	ð ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!ö	ð ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   c                 ó*   • U R                  S/S/5      $ )z‘
If I{Content-Type} is included in the headers passed to the
I{start_response} callable, one I{Content-Type} header is included in
the response.
)r8  zmonkeys are greats   Content-Type: monkeys are greatr·  rE   s    r'   Ú#test_applicationProvidedContentTypeÚ6StartResponseTests.test_applicationProvidedContentTypeÚ  s#   € ð × Ñ Ø2Ð3Ø/Ð0ó
ð 	
r1   c                 ó*   • U R                  / SQ/ 5      $ )z{
If either I{Server} or I{Date} is included in the headers passed to the
I{start_response} callable, they are disregarded.
))r   r  )ÚServerr  )Údater  )ÚdATEr  r·  rE   s    r'   Ú%test_applicationProvidedServerAndDateÚ8StartResponseTests.test_applicationProvidedServerAndDateå  s   € ð
 × Ñ ÚTÐVXó
ð 	
r1   c                 óÐ   ^ ^^^• [        5       m/ mUU4S jmU4S jnT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )	zê
Nothing is written in response to a request when the I{start_response}
callable is invoked.  If the iterator returned by the application
object produces only empty strings, the response is written after the
last element is produced.
c                  ól   >• TR                  T R                  R                  R                  5       5        g r>   ©Úappendr\  r‡  rˆ  ©r¯   ÚintermediateValuess   €€r'   rÈ  Ú:StartResponseTests.test_delayedUntilReturn.<locals>.recordù  ó&   ø€ Ø×%Ñ% g×&7Ñ&7×&?Ñ&?×&HÑ&HÓ&JÕKr1   c                  ó   >• U4S jn U $ )Nc              3   ó:   >#   • U" SSS/5        Sv •  T" 5         g 7f)Nr¹   r+  r’  r1   r*   ©r@   rA   rÈ  s     €r'   rp   Ú[StartResponseTests.test_delayedUntilReturn.<locals>.applicationFactory.<locals>.applicationý  s   øé € Ù˜h¨¸Ð(IÔJØ’	Ù•ùs   ƒr*   ©rp   rÈ  s    €r'   r£   ÚFStartResponseTests.test_delayedUntilReturn.<locals>.applicationFactoryü  s   ø€ õð
 Ðr1   c                 ó,   >• TR                  TS/5        g )Nr1   ré   ©r‹  r	  r#   s    €€r'   rù   Ú>StartResponseTests.test_delayedUntilReturn.<locals>.cbRendered  s   ø€ Ø×ÑÐ/°#°Õ7r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú<StartResponseTests.test_delayedUntilReturn.<locals>.<lambda>  r�  r1   rñ   rò   r^   Nr�  ©r#   r£   rÇ   r¢   rù   r¯   r	  rÈ  s   `    @@@r'   Útest_delayedUntilReturnÚ*StartResponseTests.test_delayedUntilReturnî  su   û€ ô “.ˆàÐö	Lõ	ð !×6Ñ6Ó8Ñˆö	8ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 óÐ   ^ ^^^• [        5       m/ mUU4S jmU4S jnT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )	zé
Nothing is written in response to a request when the I{start_response}
callable is invoked.  Once a non-empty string has been produced by the
iterator returned by the application object, the response status and
headers are written.
c                  ól   >• TR                  T R                  R                  R                  5       5        g r>   r  r  s   €€r'   rÈ  Ú;StartResponseTests.test_delayedUntilContent.<locals>.record$  r  r1   c                  ó   >• U4S jn U $ )Nc              3   óN   >#   • U" SS/5        Sv •  T" 5         Sv •  T" 5         g 7f)Nr¹   r+  r1   rN   r*   r  s     €r'   rp   Ú\StartResponseTests.test_delayedUntilContent.<locals>.applicationFactory.<locals>.application(  s'   øé € Ù˜h¨Ð(8Ô9Ø’	Ù”Ø’Ù•ùó   ƒ"%r*   r  s    €r'   r£   ÚGStartResponseTests.test_delayedUntilContent.<locals>.applicationFactory'  ó   ø€ õð Ðr1   c                 óV   >• TR                  TS   5        TR                  TS   5        g )Nr   rx   )ÚassertFalserI   r  s    €€r'   rù   Ú?StartResponseTests.test_delayedUntilContent.<locals>.cbRendered3  s)   ø€ Ø×ÑÐ/°Ñ2Ô3Ø�O‰OÐ.¨qÑ1Õ2r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú=StartResponseTests.test_delayedUntilContent.<locals>.<lambda><  r�  r1   rñ   rò   r^   Nr�  r  s   `    @@@r'   Útest_delayedUntilContentÚ+StartResponseTests.test_delayedUntilContent  su   û€ ô “.ˆàÐö	Lõ	ð !×6Ñ6Ó8Ñˆö	3ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 óÐ   ^ ^^^• [        5       m/ mUU4S jmU4S jnT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )	zr
Content produced by the iterator returned by the application object is
written to the request as it is produced.
c                  ól   >• TR                  T R                  R                  R                  5       5        g r>   r  r  s   €€r'   rÈ  Ú/StartResponseTests.test_content.<locals>.recordP  r  r1   c                  ó   >• U4S jn U $ )Nc              3   óN   >#   • U" SS/5        Sv •  T" 5         Sv •  T" 5         g 7f)Nr¹   ©rD  Ú6rN   ó   barr*   r  s     €r'   rp   ÚPStartResponseTests.test_content.<locals>.applicationFactory.<locals>.applicationT  s(   øé € Ù˜hÐ)@Ð(AÔBØ’Ù”Ø’Ù•ùr   r*   r  s    €r'   r£   Ú;StartResponseTests.test_content.<locals>.applicationFactoryS  r"  r1   c                 ó–   >• TR                  TR                  TS   5      S5        TR                  TR                  TS   5      S5        g ©Nr   rN   rx   s   foobar©rê   rÑ   r  s    €€r'   rù   Ú3StartResponseTests.test_content.<locals>.cbRendered_  óI   ø€ Ø×Ñ˜T×8Ñ8Ð9KÈAÑ9NÓOÐQWÔXØ×ÑØ×+Ñ+Ð,>¸qÑ,AÓBÀIõr1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú1StartResponseTests.test_content.<locals>.<lambda>j  r�  r1   rñ   rò   r^   Nr�  r  s   `    @@@r'   Útest_contentÚStartResponseTests.test_contentG  su   û€ ô
 “.ˆàÐö	Lõ	ð !×6Ñ6Ó8Ñˆö	ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó´   ^ ^• [        5       mS nT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )z–
If the I{start_response} callable is invoked multiple times before a
data for the response body is produced, the values from the last call
are used.
c                  ó   • S n U $ )Nc                 ó<   • U" S/ 5        U" S/ 5        [        S5      $ )Nú100 Fooz200 Barr*   r€  r?   s     r'   rp   Ú^StartResponseTests.test_multipleStartResponse.<locals>.applicationFactory.<locals>.application~  s   € Ù˜i¨Ô,Ù˜i¨Ô,Ü˜B“x�r1   r*   r‚  s    r'   r£   ÚIStartResponseTests.test_multipleStartResponse.<locals>.applicationFactory}  ó   € ò ð
 Ðr1   c                 óŠ   >• TR                  TR                  R                  R                  5       R	                  S5      5        g )Ns   HTTP/1.1 200 Bar
r†  rŠ  s    €€r'   rù   ÚAStartResponseTests.test_multipleStartResponse.<locals>.cbRendered‡  ó3   ø€ Ø�O‰OØ×!Ñ!×)Ñ)×2Ñ2Ó4×?Ñ?Ð@WÓXõr1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú?StartResponseTests.test_multipleStartResponse.<locals>.<lambda>‘  r�  r1   rñ   rò   r^   Nr�  r‘  s   `    @r'   Útest_multipleStartResponseÚ-StartResponseTests.test_multipleStartResponseu  si   ù€ ô “.ˆò	ð !×6Ñ6Ó8Ñˆö	ð
 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó´   ^ ^• [        5       mS nT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )zÉ
If the I{start_response} callable is invoked with a third positional
argument before the status and headers have been written to the
response, the status and headers become the newly supplied values.
c                  ó   • S n U $ )Nc                 óL   • U" S/ [         [        S5      S 45        [        S5      $ )Nr@  r  r*   )r{   r¼   r?   s     r'   rp   ÚcStartResponseTests.test_startResponseWithException.<locals>.applicationFactory.<locals>.application¥  s#   € Ù˜i¨¬i¼À5Ó9IÈ4Ð-PÔQÜ˜B“x�r1   r*   r‚  s    r'   r£   ÚNStartResponseTests.test_startResponseWithException.<locals>.applicationFactory¤  r„  r1   c                 óŠ   >• TR                  TR                  R                  R                  5       R	                  S5      5        g )Ns   HTTP/1.1 100 Foo
r†  rŠ  s    €€r'   rù   ÚFStartResponseTests.test_startResponseWithException.<locals>.cbRendered­  rF  r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   ÚDStartResponseTests.test_startResponseWithException.<locals>.<lambda>·  r�  r1   rñ   rò   r^   Nr�  r‘  s   `    @r'   Útest_startResponseWithExceptionÚ2StartResponseTests.test_startResponseWithExceptionœ  si   ù€ ô “.ˆò	ð !×6Ñ6Ó8Ñˆö	ð
 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó*  ^ ^^^• [        5       m " S S[        5      n U" 5       e! [         a    [        5       m Of = f/ mUU4S jnT R	                  5       u  p4UUUU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S	/ 5	        U$ )
zÑ
If the I{start_response} callable is invoked with a third positional
argument after the status and headers have been written to the
response, the supplied I{exc_info} values are re-raised to the
application.
c                   ó   • \ rS rSrSrg)ÚPStartResponseTests.test_startResponseWithExceptionTooLate.<locals>.SomeExceptioniË  r*   N)r+   r,   r-   r.   r0   r*   r1   r'   ÚSomeExceptionrX  Ë  s   † Úr1   rY  c                  ó   >• UU4S jn U $ )Nc              3   ó�   >#   • U" S/ 5        Sv •   U" S/ T5        g ! [          a    TR                  [        5       5         g f = f7f)Nr¹   rN   z500 ERR)r   r  r   )r@   rA   ÚexcInfoÚreraiseds     €€r'   rp   ÚjStartResponseTests.test_startResponseWithExceptionTooLate.<locals>.applicationFactory.<locals>.applicationÖ  sB   øé € Ù˜h¨Ô+Ø’ð0Ù! )¨R°Õ9øÜ$ó 0Ø—O‘O¤H£JÖ/ð0üs%   ƒA’
 œA�#AÁ AÁAÁAr*   )rp   r\  r]  s    €€r'   r£   ÚUStartResponseTests.test_startResponseWithExceptionTooLate.<locals>.applicationFactoryÕ  s   ø€ ö0ð Ðr1   c                 ó¤  >• TR                  TR                  R                  R                  5       R	                  S5      5        TR                  TS   S   TS   5        TR                  TS   S   TS   5        TS   S   R                  nTS   nTR                  [        R                  " U5      S   [        R                  " U5      S   5        g )Ns   HTTP/1.1 200 OK
r   rx   rÄ  )	rI   r\  r‡  rˆ  r‰  rê   Útb_nextÚ	tracebackÚ
extract_tb)r‹  Útb1Útb2r¯   r\  r]  r#   s      €€€€r'   rù   ÚMStartResponseTests.test_startResponseWithExceptionTooLate.<locals>.cbRenderedâ  s½   ø€ Ø�O‰OØ×!Ñ!×)Ñ)×2Ñ2Ó4×?Ñ?Ð@VÓWôð ×Ñ˜X a™[¨™^¨W°Q©ZÔ8Ø×Ñ˜X a™[¨™^¨W°Q©ZÔ8ð ˜1‘+˜a‘.×(Ñ(ˆCØ˜!‘*ˆCØ×ÑœY×1Ò1°#Ó6°qÑ9¼9×;OÒ;OÐPSÓ;TÐUVÑ;WÕXr1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   ÚKStartResponseTests.test_startResponseWithExceptionTooLate.<locals>.<lambda>ó  r�  r1   rñ   rò   r^   N)r   r{   r   r   rË   rû   r³   )	r#   rY  r£   rÇ   r¢   rù   r¯   r\  r]  s	   `     @@@r'   Ú&test_startResponseWithExceptionTooLateÚ9StartResponseTests.test_startResponseWithExceptionTooLateÂ  s¦   û€ ô “.ˆô	œIô 	ð	!Ù“/Ð!øÜó 	!Ü“jŠGð	!úð ˆö		ð !×6Ñ6Ó8Ñˆ÷
	Yð 
	Yð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆs   Ÿ& ¦=¼=c                 óÐ   ^ ^^^• [        5       m/ mUU4S jmU4S jnT R                  5       u  p#UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S/ 5	        U$ )	zz
I{start_response} returns the I{write} callable which can be used to
write bytes to the response body without buffering.
c                  ól   >• TR                  T R                  R                  R                  5       5        g r>   r  r  s   €€r'   rÈ  Ú-StartResponseTests.test_write.<locals>.record  r  r1   c                  ó   >• U4S jn U $ )Nc                 ój   >• U" SS/5      nU" S5        T" 5         U" S5        T" 5         [        S5      $ )Nr@  r/  rN   r1  r*   r€  )r@   rA   r�   rÈ  s      €r'   rp   ÚNStartResponseTests.test_write.<locals>.applicationFactory.<locals>.application  s4   ø€ Ù% iÐ2IÐ1JÓK�Ù�f”Ù”Ù�f”Ù”Ü˜B“x�r1   r*   r  s    €r'   r£   Ú9StartResponseTests.test_write.<locals>.applicationFactory
  s   ø€ õ ð Ðr1   c                 ó–   >• TR                  TR                  TS   5      S5        TR                  TR                  TS   5      S5        g r5  r6  r  s    €€r'   rù   Ú1StartResponseTests.test_write.<locals>.cbRendered  r8  r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú/StartResponseTests.test_write.<locals>.<lambda>"  r�  r1   rñ   rò   r^   Nr�  r  s   `    @@@r'   Ú
test_writeÚStartResponseTests.test_writeþ  su   û€ ô
 “.ˆàÐö	Lõ		ð !×6Ñ6Ó8Ñˆö	ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó¦   ^ • S nT R                  U5      u  p#UR                  5         U 4S jnT R                  U[        5      R	                  U5      $ )zR
The C{write} callable returned from C{start_response} only accepts
byte strings.
c                 ó:   • U" S/ 5      nU" S5        [        S5      $ )Nr¹   Úbogusr*   r€  ©r@   rA   r�   s      r'   rp   ÚHStartResponseTests.test_writeAcceptsOnlyByteStrings.<locals>.application3  s   € Ù! (¨BÓ/ˆEÙ�'ŒNÜ˜“8ˆOr1   c                 ó<   >• TR                  S[        U 5      5        g )Nz0Can only write bytes to a transport, not 'bogus'r™  rš  s    €r'   r›  ÚIStartResponseTests.test_writeAcceptsOnlyByteStrings.<locals>.checkMessage;  s   ø€ Ø×ÑØBÄCÈÃJõr1   r�  ré  s   `    r'   Ú test_writeAcceptsOnlyByteStringsÚ3StartResponseTests.test_writeAcceptsOnlyByteStrings-  sM   ø€ ò	ð
 ×-Ñ-¨kÓ:‰ˆØ×ÑÔ!õ	ð
 ×!Ñ! &¬)Ó4×@Ñ@ÀÓNÐNr1   r*   N)r+   r,   r-   r.   r/   r’  rŸ  r´  rž  rÁ  rÐ  rÙ  rß  rê  rñ  rù  rü  r  r  r(  r;  rI  rT  ri  rv  r  r0   r*   r1   r'   r|  r|  ¶  s€   † ñò
%òNOò&/òb
òOò.
ò:Oò.
ò:Oò*Oò,Oò,	
ò
ò)òV,ò\,ò\%òN$òL:òx-õ^Or1   r|  c                   óf   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rSrg)ÚApplicationTestsiC  zX
Tests for things which are done to the application object and the iterator
it returns.
c                 ó¶   • [         U l         [        5       U l        U R                  R                  5         U R	                  U R                  R
                  5        g r>   )r   r   r‰   ÚstartÚ
addCleanupÚstoprE   s    r'   ÚenableThreadsÚApplicationTests.enableThreadsI  s8   € ÜˆŒÜ$›,ˆŒØ�‰×ÑÔØ�‰˜Ÿ™×,Ñ,Õ-r1   c           	      óÚ   ^ ^^• [        5       m " S S5      nU" 5       mU4S jnT R                  5       u  p4UUU 4S jnUR                  U5        T R                  XBU4S jSS/ S/5        U$ )	z„
If the application object returns an iterator which also has a I{close}
method, that method is called after iteration is complete.
c                   ó&   • \ rS rSrS rS rS rSrg)Ú+ApplicationTests.test_close.<locals>.ResultiV  c                 ó   • SU l         g )NT©ÚopenrE   s    r'   r_   Ú4ApplicationTests.test_close.<locals>.Result.__init__W  s	   € Ø �•	r1   c              3   óf   #   • [        S5       H  nU R                  (       d  M  SU4-  v •  M      g 7f©Nrý  s   %d)ÚrangerŽ  )r#   Úis     r'   Ú__iter__Ú4ApplicationTests.test_close.<locals>.Result.__iter__Z  s(   é € Ü˜qž�AØ—y—y‘yØ# q d™lÔ*ò "ùs   ‚1¤1c                 ó   • SU l         g )NFr�  rE   s    r'   ÚcloseÚ1ApplicationTests.test_close.<locals>.Result.close_  s	   € Ø!�•	r1   r�  N©r+   r,   r-   r.   r_   r”  r—  r0   r*   r1   r'   ÚResultr‹  V  s   † ò!ò+õ
"r1   rš  c                  ó   >• U4S jn U $ )Nc                 ó   >• U" SS/5        T$ )Nr¹   ©rD  Ú3r*   )r@   rA   r½   s     €r'   rp   ÚLApplicationTests.test_close.<locals>.applicationFactory.<locals>.applicatione  s   ø€ Ù˜hÐ)@Ð(AÔBØ�r1   r*   r¿   s    €r'   r£   Ú7ApplicationTests.test_close.<locals>.applicationFactoryd  s   ø€ õð Ðr1   c                 óÂ   >• TR                  TR                  TR                  R                  R	                  5       5      S5        TR                  TR                  5        g )Ns   012)rê   rÑ   r\  r‡  rˆ  r$  rŽ  )r‹  r¯   r½   r#   s    €€€r'   rù   Ú/ApplicationTests.test_close.<locals>.cbRenderedm  sK   ø€ Ø×ÑØ×+Ñ+¨G×,=Ñ,=×,EÑ,E×,NÑ,NÓ,PÓQØôð ×Ñ˜VŸ[™[Õ)r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú-ApplicationTests.test_close.<locals>.<lambda>w  s   ø€ ¹r1   rñ   rò   r^   r�  )r#   rš  r£   rÇ   r¢   rù   r¯   r½   s   `     @@r'   Ú
test_closeÚApplicationTests.test_closeO  sp   ú€ ô
 “.ˆ÷
	"ñ 
	"ñ “ˆõ	ð !×6Ñ6Ó8Ñˆ÷	*ð 	
�‰�jÔ!à×ÑØ´ÀÈÈrÐTVÐSWô	
ð ˆr1   c           	      óÄ   ^ ^• T R                  5         / mU4S jnT R                  5       u  p#UU 4S jnUR                  U5        T R                  X1[        SS/ S/5        U$ )z]
The application object is invoked and iterated in a thread which is not
the reactor thread.
c                  ó   >• U4S jn U $ )Nc                 ód   >• U4S jnTR                  [        5       5        U" SS/5        U" 5       $ )Nc               3   ót   >#   • [        S5       H$  n TR                  [        5       5        SU 4-  v •  M&     g 7fr‘  )r’  r  r   )r“  Úinvokeds    €r'   r½   ÚpApplicationTests.test_applicationCalledInThread.<locals>.applicationFactory.<locals>.application.<locals>.result†  s.   øé € Ü" 1žX˜ØŸ™¤{£}Ô5Ø# q d™lÔ*ò &ùs   ƒ58r¹   r�  )r  r   )r@   rA   r½   r«  s      €r'   rp   Ú`ApplicationTests.test_applicationCalledInThread.<locals>.applicationFactory.<locals>.application…  s-   ø€ õ+ð
 —‘œ{›}Ô-Ù˜hÐ)@Ð(AÔBÙ“x�r1   r*   )rp   r«  s    €r'   r£   ÚKApplicationTests.test_applicationCalledInThread.<locals>.applicationFactory„  s   ø€ õ ð Ðr1   c                 ó‚   >• TR                  [        5       T5        TR                  [        [	        T5      5      S5        g )Nrx   )ÚassertNotInr   rê   r~   Úset©r‹  r«  r#   s    €€r'   rù   ÚCApplicationTests.test_applicationCalledInThread.<locals>.cbRendered“  s.   ø€ Ø×Ñœ[›]¨GÔ4Ø×ÑœS¤ W£Ó.°Õ2r1   rñ   rò   r^   )r‡  rË   rû   r³   r   )r#   r£   rÇ   r¢   rù   r«  s   `    @r'   Útest_applicationCalledInThreadÚ/ApplicationTests.test_applicationCalledInThread|  sg   ù€ ð
 	×ÑÔØˆõ	ð !×6Ñ6Ó8Ñˆö	3ð 	
�‰�jÔ!à×ÑØ´¸eÀUÈBÐQSÐPTô	
ð ˆr1   c           	      óä   ^ ^• T R                  5         / m " U4S jS[        5      nS nT R                  U5      u  p4UU 4S jnUR                  U5        T R	                  XB[
        SS/ S/5        U$ )zp
The I{write} callable returned by I{start_response} calls the request's
C{write} method in the reactor thread.
c                   ó"   >• \ rS rSrU 4S jrSrg)ÚCApplicationTests.test_writeCalledFromThread.<locals>.ThreadVerifieri§  c                 ób   >• TR                  [        5       5        [        R                  " X5      $ r>   ©r  r   r   r�   ©r#   rŽ   r«  s     €r'   r�   ÚIApplicationTests.test_writeCalledFromThread.<locals>.ThreadVerifier.write¨  ó    ø€ Ø—‘œ{›}Ô-Ü—}’} TÓ1Ð1r1   r*   N©r+   r,   r-   r.   r�   r0   ©r«  s   €r'   ÚThreadVerifierr¸  §  ó   ø† ÷2ð 2r1   rÀ  c                  ó   • S n U $ )Nc                 ó:   • U" S/ 5      nU" S5        [        S5      $ )Nr¹   rN   r*   r€  r{  s      r'   rp   Ú\ApplicationTests.test_writeCalledFromThread.<locals>.applicationFactory.<locals>.application­  s   € Ù% h°Ó3�Ù�f”Ü˜B“x�r1   r*   r‚  s    r'   r£   ÚGApplicationTests.test_writeCalledFromThread.<locals>.applicationFactory¬  rC  r1   c                 óN   >• TR                  [        T5      [        5       15        g r>   ©rê   r±  r   r²  s    €€r'   rù   Ú?ApplicationTests.test_writeCalledFromThread.<locals>.cbRendered¶  ó   ø€ Ø×ÑœS ›\¬K«M¨?Õ;r1   rñ   rò   r^   ©r‡  r   rË   rû   r³   r   ©r#   rÀ  r£   rÇ   r¢   rù   r«  s   `     @r'   Útest_writeCalledFromThreadÚ+ApplicationTests.test_writeCalledFromThreadŸ  su   ù€ ð
 	×ÑÔØˆ÷	2œWô 	2ò
	ð !×6Ñ6°~ÓFÑˆö	<ð 	
�‰�jÔ!à×ÑØ´¸eÀUÈBÐQSÐPTô	
ð ˆr1   c           	      óä   ^ ^• T R                  5         / m " U4S jS[        5      nS nT R                  U5      u  p4UU 4S jnUR                  U5        T R	                  XB[
        SS/ S/5        U$ )zw
Strings produced by the iterator returned by the application object are
written to the request in the reactor thread.
c                   ó"   >• \ rS rSrU 4S jrSrg)ÚMApplicationTests.test_iteratedValuesWrittenFromThread.<locals>.ThreadVerifieriÉ  c                 ób   >• TR                  [        5       5        [        R                  " X5      $ r>   rº  r»  s     €r'   r�   ÚSApplicationTests.test_iteratedValuesWrittenFromThread.<locals>.ThreadVerifier.writeÊ  r½  r1   r*   Nr¾  r¿  s   €r'   rÀ  rÐ  É  rÁ  r1   rÀ  c                  ó   • S n U $ )Nc              3   ó&   #   • U" S/ 5        Sv •  g 7f)Nr¹   rN   r*   r?   s     r'   rp   ÚfApplicationTests.test_iteratedValuesWrittenFromThread.<locals>.applicationFactory.<locals>.applicationÏ  s   é € Ù˜h¨Ô+Ø“ùs   ‚r*   r‚  s    r'   r£   ÚQApplicationTests.test_iteratedValuesWrittenFromThread.<locals>.applicationFactoryÎ  s   € òð Ðr1   c                 óN   >• TR                  [        T5      [        5       15        g r>   rÇ  r²  s    €€r'   rù   ÚIApplicationTests.test_iteratedValuesWrittenFromThread.<locals>.cbRendered×  rÉ  r1   rñ   rò   r^   rÊ  rË  s   `     @r'   Ú$test_iteratedValuesWrittenFromThreadÚ5ApplicationTests.test_iteratedValuesWrittenFromThreadÁ  su   ù€ ð
 	×ÑÔØˆ÷	2œWô 	2ò
	ð !×6Ñ6°~ÓFÑˆö	<ð 	
�‰�jÔ!à×ÑØ´¸eÀUÈBÐQSÐPTô	
ð ˆr1   c           	      óä   ^ ^• T R                  5         / m " U4S jS[        5      nS nT R                  U5      u  p4UU 4S jnUR                  U5        T R	                  XB[
        SS/ S/5        U$ )zI
The response status is set on the request object in the reactor thread.
c                   ó"   >• \ rS rSrU 4S jrSrg)ÚEApplicationTests.test_statusWrittenFromThread.<locals>.ThreadVerifierié  c                 ód   >• TR                  [        5       5        [        R                  " XU5      $ r>   )r  r   r   ÚsetResponseCode)r#   ÚcoderÀ  r«  s      €r'   rß  ÚUApplicationTests.test_statusWrittenFromThread.<locals>.ThreadVerifier.setResponseCodeê  s$   ø€ Ø—‘œ{›}Ô-Ü×.Ò.¨t¸7ÓCÐCr1   r*   N)r+   r,   r-   r.   rß  r0   r¿  s   €r'   rÀ  rÝ  é  s   ø† ÷Dð Dr1   rÀ  c                  ó   • S n U $ )Nc                 ó*   • U" S/ 5        [        S5      $ r¸   r€  r?   s     r'   rp   Ú^ApplicationTests.test_statusWrittenFromThread.<locals>.applicationFactory.<locals>.applicationï  s   € Ù˜h¨Ô+Ü˜B“x�r1   r*   r‚  s    r'   r£   ÚIApplicationTests.test_statusWrittenFromThread.<locals>.applicationFactoryî  r„  r1   c                 óN   >• TR                  [        T5      [        5       15        g r>   rÇ  r²  s    €€r'   rù   ÚAApplicationTests.test_statusWrittenFromThread.<locals>.cbRendered÷  rÉ  r1   rñ   rò   r^   rÊ  rË  s   `     @r'   Útest_statusWrittenFromThreadÚ-ApplicationTests.test_statusWrittenFromThreadâ  sw   ù€ ð 	×ÑÔØˆ÷	DœWô 	Dò
	ð !×6Ñ6°~ÓFÑˆö	<ð 	
�‰�jÔ!à×ÑØ´¸eÀUÈBÐQSÐPTô	
ð ˆr1   c           	      ó   ^ ^•  " S S[         5      nST l        U 4S jmU4S jnT R                  U5      u  p4U 4S jnUR                  U5        T R	                  XB[
        SS/ S	/5        T R                  U[        5      $ )
zi
If the request connection is lost while the application object is being
iterated, iteration is stopped.
c                   ó   • \ rS rSrSrS rSrg)ÚSApplicationTests.test_connectionClosedDuringIteration.<locals>.UnreliableConnectioni  zj
This is a request which pretends its connection is lost immediately
after the first write is done to it.
c                 óJ   • U R                  [        [        S5      5      5        g )NzNo more connection)ÚconnectionLostr   r   )r#   rŽ   s     r'   r�   ÚYApplicationTests.test_connectionClosedDuringIteration.<locals>.UnreliableConnection.write  s   € Ø×#Ñ#¤G¬NÐ;OÓ,PÓ$QÕRr1   r*   N)r+   r,   r-   r.   r/   r�   r0   r*   r1   r'   ÚUnreliableConnectionrì    s   † ñõ
Sr1   rð  Fc               3   ó8   >#   • Sv •  ST l         [        S5      e7f)NrN   TzShould not have gotten here)ÚbadIterr{   rE   s   €r'   ÚappIterÚFApplicationTests.test_connectionClosedDuringIteration.<locals>.appIter  s   øé € ØŠLØˆDŒLÜÐ9Ó:Ð:ùs   ƒc                  ó   >• U4S jn U $ )Nc                 ó$   >• U" S/ 5        T" 5       $ ©Nr¹   r*   )r@   rA   ró  s     €r'   rp   ÚfApplicationTests.test_connectionClosedDuringIteration.<locals>.applicationFactory.<locals>.application  s   ø€ Ù˜h¨Ô+Ù“yÐ r1   r*   )rp   ró  s    €r'   r£   ÚQApplicationTests.test_connectionClosedDuringIteration.<locals>.applicationFactory  s   ø€ õ!ð Ðr1   c                 ó>   >• TR                  TR                  S5        g )Nz!Should not have resumed iteration)r$  rò  )r‹  r#   s    €r'   rù   ÚIApplicationTests.test_connectionClosedDuringIteration.<locals>.cbRendered!  s   ø€ Ø×Ñ˜TŸ\™\Ð+NÕOr1   rñ   rò   r^   )r   rò  rË   rû   r³   r   rž  r   )r#   rð  r£   rÇ   r¢   rù   ró  s   `     @r'   Ú$test_connectionClosedDuringIterationÚ5ApplicationTests.test_connectionClosedDuringIteration  s‚   ù€ ô	S¤7ô 	Sð ˆŒõ	;õ
	ð !×6Ñ6Ð7KÓLÑˆõ	Pð 	
�‰�jÔ!à×ÑØ´¸eÀUÈBÐQSÐPTô	
ð ×!Ñ! !¤^Ó4Ð4r1   c                 ó¼   ^ ^^• [        5       mU4S jnT R                  5       u  p4UU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S / 5	        U$ )Nc                  ó   >• T $ r>   r*   r‚  s   €r'   r£   ÚEApplicationTests._internalServerErrorTest.<locals>.applicationFactory/  ó	   ø€ ØÐr1   c                 óê   >• TR                  [        5      nTR                  [        U5      S5        TR	                  TR
                  R                  R                  5       R                  S5      5        g )Nrx   s"   HTTP/1.1 500 Internal Server Error)	r�   rP   rê   r~   rI   r\  r‡  rˆ  r‰  )r‹  rÈ  r¯   r#   s     €€r'   rù   Ú=ApplicationTests._internalServerErrorTest.<locals>.cbRendered4  sY   ø€ Ø×+Ñ+¬LÓ9ˆFØ×ÑœS ›[¨!Ô,à�O‰OØ×!Ñ!×)Ñ)×2Ñ2Ó4×?Ñ?Ø9óõr1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú;ApplicationTests._internalServerErrorTest.<locals>.<lambda>C  r�  r1   rñ   rò   r^   r�  )r#   rp   r£   rÇ   r¢   rù   r¯   s   ``    @r'   Ú_internalServerErrorTestÚ)ApplicationTests._internalServerErrorTest,  sg   ú€ Ü“.ˆõ	ð !×6Ñ6Ó8Ñˆö	ð 	
�‰�jÔ!à×ÑØØÜØØØØˆDØØô
	
ð ˆr1   c                 ó*   • S nU R                  U5      $ )z‰
If the application raises an exception before calling I{start_response}
then the response status is I{500} and the exception is logged.
c                 ó   • [        S5      e©Nú This application had some error.©rP   r?   s     r'   rp   ÚRApplicationTests.test_applicationExceptionBeforeStartResponse.<locals>.applicationT  s   € ÜÐAÓBÐBr1   ©r  ©r#   rp   s     r'   Ú,test_applicationExceptionBeforeStartResponseÚ=ApplicationTests.test_applicationExceptionBeforeStartResponseN  s   € ò	Cð ×,Ñ,¨[Ó9Ð9r1   c                 ó*   • S nU R                  U5      $ )z´
If the application calls I{start_response} but then raises an exception
before any data is written to the response then the response status is
I{500} and the exception is logged.
c                 ó*   • U" S/ 5        [        S5      e©Nr¹   r  r  r?   s     r'   rp   ÚQApplicationTests.test_applicationExceptionAfterStartResponse.<locals>.application`  s   € Ù˜( BÔ'ÜÐAÓBÐBr1   r  r  s     r'   Ú+test_applicationExceptionAfterStartResponseÚ<ApplicationTests.test_applicationExceptionAfterStartResponseY  s   € ò	Cð ×,Ñ,¨[Ó9Ð9r1   c                 ó¨  ^ ^^^^^	^
• [        5       m[        R                  " T [        5      mU4S jnT R	                  5       u  nm	/ m
U	U
4S jnUUUU 4S jnUR                  U5        T R                  UUU4S jSS/ S/S / 5	        T R                  TR                  R                  5        T
S   R                  [        [        S	5      5      5        U$ )
Nc                  ó   >• T $ r>   r*   r‚  s   €r'   r£   ÚBApplicationTests._connectionClosedTest.<locals>.applicationFactoryk  r  r1   c                  ó<   >• TR                  T" U 0 UD65        TS   $ r  )r  )r%   r&   r¢   Úrequestss     €€r'   ÚrequestFactoryWrapperÚEApplicationTests._connectionClosedTest.<locals>.requestFactoryWrappers  s#   ø€ Ø�O‰O™N¨AÐ4°Ñ4Ô5Ø˜B‘<Ðr1   c                 óf  >• TR                  S[        T5      5        TS   nUS   nTR                  UR                  [        5        TR                  [        5        TR                  R                  R                  5       nTR                  UR                  S5      5        TR                  TU5        g )Nrx   r   ry   s   HTTP/1.1 200 OK)r}   r~   r   r€   rP   r�   r\  r‡  rˆ  rI   r‰  ÚassertIn)r‹  Úeventr$   rÐ   r¯   r‚   ÚresponseContentr#   s       €€€€r'   Ú
ebRenderedÚ:ApplicationTests._connectionClosedTest.<locals>.ebRenderedw  s�   ø€ Ø×Ñ˜a¤ [Ó!1Ô2Ø ‘NˆEØ�mÑ$ˆAØ×!Ñ! !§'¡'¬<Ô8Ø×"Ñ"¤<Ô0à×(Ñ(×0Ñ0×9Ñ9Ó;ˆHØ�O‰O˜H×/Ñ/Ð0BÓCÔDà�M‰M˜/¨8Õ4r1   c                  ó   >• T $ r>   r*   r³  s   €r'   rB   Ú8ApplicationTests._connectionClosedTest.<locals>.<lambda>ˆ  r�  r1   rñ   rò   r^   r   zAll gone)r   r   rz   r   rË   Ú
addErrbackr³   rI   r\  Údisconnectedrî  r   r   )r#   rp   r"  r£   rÇ   r  r#  r¯   r‚   r¢   r  s   ```    @@@@r'   Ú_connectionClosedTestÚ&ApplicationTests._connectionClosedTestf  sÁ   þ€ Ü“.ˆä*×<Ò<¸TÔCUÓVˆõ	ð !×6Ñ6Ó8Ñˆˆ>ð ˆö	 ÷
	5ð 
	5ð 	
�‰�ZÔ à×ÑØ!ØÜØØØØˆDØØô
	
ð 	�‰˜×)Ñ)×6Ñ6Ô7à�‰×"Ñ"¤7¬>¸*Ó+EÓ#FÔGàˆr1   c                 ó8   ^• SmU4S jnU R                  UT5      $ )z“
If the application raises an exception after the response status has
already been sent then the connection is closed and the exception is
logged.
s?   Some bytes, triggering the server to start sending the responsec              3   ó<   >#   • U" S/ 5        Tv •  [        S5      e7fr  r  )r@   rA   r"  s     €r'   rp   ÚIApplicationTests.test_applicationExceptionAfterWrite.<locals>.application¢  s"   øé € Ù˜( BÔ'Ø!Ò!ÜÐAÓBÐBùs   ƒ©r)  )r#   rp   r"  s     @r'   Ú#test_applicationExceptionAfterWriteÚ4ApplicationTests.test_applicationExceptionAfterWrite˜  s)   ø€ ð Oð 	õ	Cð
 ×)Ñ)¨+°ÓGÐGr1   c                 óF   ^• Sm " U4S jS5      nU R                  UT5      $ )zª
If the application returns a closeable iterator and the C{close} method
raises an exception when called then the connection is still closed and
the exception is logged.
rN   c                   ó.   >• \ rS rSrS rU 4S jrS rSrg)ÚDApplicationTests.test_applicationCloseException.<locals>.Applicationi±  c                 ó   • U" S/ 5        g r÷  r*   )r#   r@   rA   s      r'   r_   ÚMApplicationTests.test_applicationCloseException.<locals>.Application.__init__²  s   € Ù˜h¨Õ+r1   c              3   ó   >#   • Tv •  g 7fr>   r*   )r#   r"  s    €r'   r”  ÚMApplicationTests.test_applicationCloseException.<locals>.Application.__iter__µ  s   øé € Ø%Ó%ùs   ƒ	c                 ó   • [        S5      er
  r  rE   s    r'   r—  ÚJApplicationTests.test_applicationCloseException.<locals>.Application.close¸  s   € Ü"Ð#EÓFÐFr1   r*   Nr™  )r"  s   €r'   ÚApplicationr3  ±  s   ø† ò,õ&õGr1   r:  r.  )r#   r:  r"  s     @r'   Útest_applicationCloseExceptionÚ/ApplicationTests.test_applicationCloseException©  s+   ø€ ð !ˆ÷	Gô 	Gð ×)Ñ)¨+°ÓGÐGr1   )rò  r   r‰   N)r+   r,   r-   r.   r/   r‡  r¥  r´  rÌ  rÙ  rè  rü  r  r  r  r)  r/  r;  r0   r*   r1   r'   r‚  r‚  C  sR   † ñò
.ò+òZ!òF òDòBò@(5òT òD	:ò:ò0òdHõ"Hr1   r‚  )9r/   rx  rb  rÊ  Úsysr   Úurllib.parser   r    Úzope.interface.verifyr   Útwisted.internetr   Útwisted.internet.addressr   r   Útwisted.internet.deferr	   r
   Útwisted.internet.errorr   Útwisted.internet.testingr   Útwisted.loggerr   r   Útwisted.python.failurer   Útwisted.python.threadabler   Útwisted.python.threadpoolr   Útwisted.trial.unittestr   Útwisted.webr   Útwisted.web.resourcer   r   Útwisted.web.serverr   r   r   Útwisted.web.test.test_webr   Útwisted.web.wsgir   r   r3   r:   r†   ræ   rÔ  ro  rv  r|  r‚  r*   r1   r'   Ú<module>rO     sá   ðñó Û Û Ý Ý *å .å $ß =ß :Ý 1Ý 9ß 5Ý *Ý 1Ý 0Ý +Ý ß 4ß 5Ñ 5Ý 2Ý )÷ñ ÷4ñ ô$m/˜ô m/÷`rñ rôjF
�> 8ô F
ôRd˜>ô dôN	Ð2°Hô ô&Ð$8¸(ô &ôJ
O˜¨ô J
OôZxH�~ xõ xHr1   