+
    Dfje
                       R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t
 ^ RIHt ^ RIHt ^ RIHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHtH t H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t)  ! R R]4      t* ! R R]4      t+ ! R R]4      t, ! R R]4      t- ! R R]4      t. ! R R]4      t/ ! R R]4      t0 ! R R]4      t1 ! R  R!]4      t2 ! R" R#]4      t3 ! R$ R%]4      t4R# )&z"
Tests for L{twisted.web.static}.
N)BytesIO)skipIf)verifyObject)abstract
interfaces)compatlog)networkString)FilePath)platform)TestCase)httpresourcescriptstatic)FOUND)UnsupportedMethod_render)DummyRequestc                   0   a  ] tR t^ t o RtR tR tRtV tR# )StaticDataTestsz
Tests for L{Data}.
c                   a a \         P                  ! RR4      p\        R.4      oRSn        \	        VS4      pVV 3R lpVP                  V4       V# )zF
L{Data.render} returns an empty response body for a I{HEAD} request.
   foobar    HEADc                 ^   < SP                  R P                  SP                  4      R 4       R#     NassertEqualjoinwrittenignoredrequestselfs   &>/usr/lib/python3/dist-packages/twisted/web/test/test_static.py
cbRendered4StaticDataTests.test_headRequest.<locals>.cbRendered.        SXXgoo6<r   )r   Datar   methodr   addCallback)r'   datadr)   r&   s   f   @r(   test_headRequest StaticDataTests.test_headRequest%   sL     {{65)t$ D'"	= 	
j!r   c                    \         P                  ! RR4      p\        R.4      pRVn        V P	                  \
        VP                  V4       R# )z^
L{Data.render} raises L{UnsupportedMethod} in response to a non-I{GET},
non-I{HEAD} request.
r   s   barr      POSTN)r   r,   r   r-   assertRaisesr   render)r'   r/   r&   s   &  r(   test_invalidMethod"StaticDataTests.test_invalidMethod4   s>    
 {{66*u% +T[['Br    N)	__name__
__module____qualname____firstlineno____doc__r1   r7   __static_attributes____classdictcell____classdict__s   @r(   r   r       s     C Cr   r   c                     a  ] tR t^?t o RtR tR tR tR tR t	R t
R tR	 tR
 t]! ]P                   ! 4       R4      R 4       tR tR tR tR tR t]! ]P0                  ! 4       P3                  4       R!9  RP5                  ]P0                  ! 4       4      4      R 4       tR tR tR tR tR t R t!R t"R t#R t$R t%R t&Rt'V t(R # )"StaticFileTestsz*
Tests for the basic behavior of L{File}.
c                    \        W4      # Nr   )r'   r   r&   s   &&&r(   r   StaticFileTests._renderD   s    x))r   c                8   \         P                  ! RR7      ;_uu_ 4       p\        P                  ! V P	                  4       ^R7      pV P                  VP                  R.4       RRR4       V P                  \        X4      ^4       R#   + '       g   i     L-; i)z
Passing C{1} as the value to L{File}'s C{ignoredExts} argument
issues a warning and sets the ignored extensions to the
wildcard C{"*"}.
TrecordignoredExts*Nwarningscatch_warningsr   Filemktempr!   rL   lenr'   caughtWarningsfiles   &  r(   test_ignoredExtTrue#StaticFileTests.test_ignoredExtTrueG   sj     $$D11^;;t{{}!<DT--u5 2 	^,a0	 21   AB		B	c                6   \         P                  ! RR7      ;_uu_ 4       p\        P                  ! V P	                  4       ^ R7      pV P                  VP                  . 4       RRR4       V P                  \        X4      ^4       R#   + '       g   i     L-; i)z
Passing C{1} as the value to L{File}'s C{ignoredExts} argument
issues a warning and sets the ignored extensions to the empty
list.
TrI   rK   NrN   rT   s   &  r(   test_ignoredExtFalse$StaticFileTests.test_ignoredExtFalseS   sh     $$D11^;;t{{}!<DT--r2 2 	^,a0	 21s   ABB	c                8   \         P                  ! RR7      ;_uu_ 4       p\        P                  ! V P	                  4       RR7      pV P                  VP                  R.4       RRR4       V P                  \        X4      ^4       R#   + '       g   i     L-; i)z
Passing C{1} as the value to L{File}'s C{allowExt} argument
issues a warning and sets the ignored extensions to the
wildcard C{*}.
TrI   rK   rM   NrN   rT   s   &  r(   test_allowExtStaticFileTests.test_allowExt_   sj     $$D11^;;t{{}$?DT--u5 2 	^,a0	 21rY   c                   \        R.4      pRVn        \        V P                  4       4      pVP	                  R4       \
        P                  ! VP                  4      pV P                  \        VP                  V4       R# )z^
L{File.render} raises L{UnsupportedMethod} in response to a non-I{GET},
non-I{HEAD} request.
r   r4   r   N)r   r-   r
   rR   
setContentr   rQ   pathr5   r   r6   )r'   r&   rb   rV   s   &   r(   r7   "StaticFileTests.test_invalidMethodk   s\    
 u% &{{499%+T[['Br   c                6  a a \        S P                  4       4      pVP                  4        \        P                  ! VP
                  4      p\        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )z
If a request is made which encounters a L{File} before a final segment
which does not correspond to any file in the path the L{File} was
created with, a not found response is sent.
   foobarc                 @   < SP                  SP                  R 4       R#   Nr!   responseCoder$   s   &r(   r)   1StaticFileTests.test_notFound.<locals>.cbRendered       W1137r   r
   rR   makedirsr   rQ   rb   r   r   getChildForRequestr   r.   r'   baserV   childr0   r)   r&   s   f     @r(   test_notFoundStaticFileTests.test_notFoundw   sv     &{{499%	{+++D':LL(	8 	
j!r   c                h   \        V P                  4       4      pVP                  4        \        P                  ! VP
                  4      p\        R.4      p\        P                  ! W#4      pV P                  V\        P                  4       V P                  VP
                  VP
                  4       R# )zj
The C{''} child of a L{File} which corresponds to a directory in the
filesystem is a L{DirectoryLister}.
r   N)r
   rR   rn   r   rQ   rb   r   r   ro   assertIsInstanceDirectoryListerr!   r'   rq   rV   r&   rr   s   &    r(   test_emptyChildStaticFileTests.test_emptyChild   sy    
 &{{499%u%++D:eV%;%;<TYY/r   c                Z   \        V P                  4       4      P                  4       pVP                  4        VP	                  R4      P                  R4      P                  4        \        P                  ! VP                  4      p\        R.4      p\        P                  ! W#4      pV P                  V\        P                  4       \        P                   ! VP                  4      pV P#                  VP                  V4       VP%                  V4      pV P                  V\&        4       R# )z
The C{u''} child of a L{File} which corresponds to a directory
whose path is text is a L{DirectoryLister} that renders to a
binary listing.

@see: U{https://twistedmatrix.com/trac/ticket/9438}
z	text-filewr   N)r
   rR   
asTextModern   rr   opencloser   rQ   rb   r   r   ro   rv   rw   r   nativeStringr!   r6   bytes)r'   textBasetextFiler&   rr   
nativePathresponses   &      r(   test_emptyChildUnicodeParent,StaticFileTests.test_emptyChildUnicodeParent   s     DKKM*557{#((-335;;x}}-u%++H>eV%;%;<((7
Z0<<(h.r   c                6  a a \        S P                  4       4      pVP                  4        \        P                  ! VP
                  4      p\        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )z
If a request is made which encounters a L{File} before a final segment
which cannot be looked up in the filesystem due to security
considerations, a not found response is sent.
s   ..c                 @   < SP                  SP                  R 4       R# rg   ri   r$   s   &r(   r)   BStaticFileTests.test_securityViolationNotFound.<locals>.cbRendered   rl   r   rm   rp   s   f     @r(   test_securityViolationNotFound.StaticFileTests.test_securityViolationNotFound   sv     &{{499%w'++D':LL(	8 	
j!r   z(Cannot remove read permission on Windowsc                d  a a \        S P                  4       4      pVP                  R4       S P                  VP                  R4       VP	                  ^ 4       \
        P                  ! VP                  4      p\        R.4      oS P                  VS4      pVV 3R lpVP                  V4       V# )z
If the file in the filesystem which would satisfy a request cannot be
read, L{File.render} sets the HTTP response code to I{FORBIDDEN}.
r   i  c                 @   < SP                  SP                  R 4       R# )i  Nri   r$   s   &r(   r)   :StaticFileTests.test_forbiddenResource.<locals>.cbRendered   rl   r   )r
   rR   ra   
addCleanupchmodr   rQ   rb   r   r   r.   )r'   rq   rV   r0   r)   r&   s   f    @r(   test_forbiddenResource&StaticFileTests.test_forbiddenResource   s     &

E* 	

1{{499%u%LLw'	8 	
j!r   c                  a a S P                  4       p\        V\        4      '       d   VP                  R4      p\	        V4      pVP                  4        \        P                  ! VP                  4      p\        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )zk
A request whose path cannot be decoded as UTF-8 receives a not
found response, and the failure is logged.
ascii   c                    < SP                  SP                  R 4       SP                  \        SP                  \        4      4      ^4       R# rg   )r!   rj   rS   flushLoggedErrorsUnicodeDecodeErrorr$   s   &r(   r)   8StaticFileTests.test_undecodablePath.<locals>.cbRendered   s:    W1137S!7!78J!KLaPr   )rR   
isinstancer   decoder
   rn   r   rQ   rb   r   r   ro   r   r.   )r'   rb   rq   rV   rr   r0   r)   r&   s   f      @r(   test_undecodablePath$StaticFileTests.test_undecodablePath   s    
 {{}dE"";;w'D~{{499%y)++D':LL(	Q 	
j!r   c                    V P                  \        P                  ! R4      P                  \        P
                  4       R# )z>
L{File.forbidden} defaults to L{resource.ForbiddenResource}.
   .N)rv   r   rQ   	forbiddenr   ForbiddenResourcer'   s   &r(   test_forbiddenResource_default.StaticFileTests.test_forbiddenResource_default   s)     	fkk$/998;U;UVr   c                f  aa \        V P                  4       4      pVP                  R4       RoR p ! V3R lR\        P                  4      o ! V3R lR\
        P                  4      pV! VP                  4      pW$n        \        R.4      pVP                  V4      pV P                  SV4       R# )	zj
The resource rendered for forbidden requests is stored as a class
member so that users can customize it.
r   s   custom-forbidden-responsec                  6    \        \        P                  R 4      h)r   )OSErrorerrnoEACCESr9   r   r(   failingOpenForReadingOStaticFileTests.test_forbiddenResource_customize.<locals>.failingOpenForReading  s    %,,++r   c                   .   <a  ] tR tRt o V3R ltRtV tR# )QStaticFileTests.test_forbiddenResource_customize.<locals>.CustomForbiddenResourcei  c                   < S# rF   r9   r'   r&   markerResponses   &&r(   r6   XStaticFileTests.test_forbiddenResource_customize.<locals>.CustomForbiddenResource.render	  	    %%r   r9   Nr:   r;   r<   r=   r6   r?   r@   rB   r   s   @r(   CustomForbiddenResourcer          & &r   r   c                   (   < ] tR tRt Z ! 4       tRtR# )JStaticFileTests.test_forbiddenResource_customize.<locals>.CustomStaticFilei  r9   N)r:   r;   r<   r=   r   r?   )r   s   r(   CustomStaticFiler     s    /1Ir   r   N)r
   rR   ra   r   Resourcer   rQ   rb   openForReadingr   r6   r!   )	r'   rq   r   r   fileResourcer&   resultr   r   s	   &      @@r(    test_forbiddenResource_customize0StaticFileTests.test_forbiddenResource_customize   s    
 &5	,	&h&7&7 	&	2v{{ 	2 (		2&;#u%$$W-0r   c                  a a \        S P                  4       4      pVP                  4        VP                  R4      P	                  R4       \
        P                  ! VP                  4      pR.Vn        \        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )z
If a request is made which encounters a L{File} before a final empty
segment, a file in the L{File} instance's C{indexNames} list which
exists in the path the L{File} was created with is served as the
response to the request.
foo.bar   bazr   c                    < SP                  R P                  SP                  4      R4       SP                  SP                  P	                  R4      ^ ,          R4       R# r   r      content-length   3Nr!   r"   r#   responseHeadersgetRawHeadersr$   s   &r(   r)   3StaticFileTests.test_indexNames.<locals>.cbRendered)  J    SXXgoo6?''556GHKTr   )r
   rR   rn   rr   ra   r   rQ   rb   
indexNamesr   r   ro   r   r.   rp   s   f     @r(   test_indexNamesStaticFileTests.test_indexNames  s     &

9((0{{499%$+u%++D':LL(	 	
j!r   c                v  a a \        S P                  4       4      pVP                  4        VP                  R4      P	                  R4       \
        P                  ! VP                  4      p\        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )z
If a request is made which encounters a L{File} before a final segment
which names a file in the path the L{File} was created with, that file
is served as the response to the request.
r   r      foo.barc                    < SP                  R P                  SP                  4      R4       SP                  SP                  P	                  R4      ^ ,          R4       R# r   r   r$   s   &r(   r)   3StaticFileTests.test_staticFile.<locals>.cbRenderedB  r   r   r
   rR   rn   rr   ra   r   rQ   rb   r   r   ro   r   r.   rp   s   f     @r(   test_staticFileStaticFileTests.test_staticFile2  s     &

9((0{{499%
|,++D':LL(	 	
j!r   z>Cannot write unicode filenames with file system encoding of {}c                  a aa RpRo\        S P                  4       4      pVP                  4        VP                  V4      P	                  S4       \
        P                  ! VP                  4      p\        VP                  R4      .4      o\        P                  ! VS4      pS P                  VS4      pVVV 3R lpVP                  V4       V# )z`
A request for a existing unicode file path encoded as UTF-8
returns the contents of that file.
u   ῆs   contentutf-8c           
         < SP                  R P                  SP                  4      S4       SP                  SP                  P	                  R4      ^ ,          \        \        \        S4      4      4      4       R# )r   r   N)r!   r"   r#   r   r   r	   strrS   )r%   contentr&   r'   s   &r(   r)   BStaticFileTests.test_staticFileUnicodeFileName.<locals>.cbRenderedb  sY    SXXgoo6@''556GHKc#g,/0r   )r
   rR   rn   rr   ra   r   rQ   rb   r   encoder   ro   r   r.   )	r'   namerq   rV   rr   r0   r)   r   r&   s	   f      @@r(   test_staticFileUnicodeFileName.StaticFileTests.test_staticFileUnicodeFileNameK  s     =&

4##G,{{499%G 456++D':LL(	 	
j!r   c                    \         P                  ! V P                  4       4      p\        R.4      pVP	                  RV4      pV P                  W1P                  4       R# )zy
A L{static.File} created for a directory which does not exist should
return childNotFound from L{static.File.getChild}.
r   N)r   rQ   rR   r   getChildr!   childNotFound)r'   
staticFiler&   rr   s   &   r(   test_staticFileDeletedGetChild.StaticFileTests.test_staticFileDeletedGetChildl  sJ    
 [[/

|,##J8 8 89r   c                  a aaa \         P                  ! S P                  4       4      p\        R.4      o\        R.4      oS P	                  VS4      oS P	                  VP
                  S4      pVVVV 3R lpVP                  V4       V# )zc
A L{static.File} created for a file which does not exist should render
its C{childNotFound} page.
r   c                 :   < VVV3R  lpSP                  V4       S# )c                    < SP                  R P                  SP                  4      R P                  SP                  4      4       R# r   r    )r%   r&   request2r'   s   &r(   r)   UStaticFileTests.test_staticFileDeletedRender.<locals>.cbRendered2.<locals>.cbRendered  s/      '//!:CHHXEUEU<VWr   )r.   )r%   r)   r0   r&   r   r'   s   & r(   cbRendered2AStaticFileTests.test_staticFileDeletedRender.<locals>.cbRendered2  s    X MM*%Hr   )r   rQ   rR   r   r   r   r.   )r'   r   d2r   r0   r&   r   s   f   @@@r(   test_staticFileDeletedRender,StaticFileTests.test_staticFileDeletedRenderv  st    
 [[/

|,-LLW-\\*22H=	 	 	{#	r   c                x  aa \        V P                  4       4      pVP                  R4       Ro ! V3R lR\        P                  4      o ! V3R lR\
        P                  4      pV! VP                  4      p\        R.4      pVP                  RV4      pVP                  V4      pV P                  SV4       R# )	z[
The resource rendered for child not found requests can be customize
using a class member.
r   s   custom-child-not-found-responsec                   .   <a  ] tR tRt o V3R ltRtV tR# )YStaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomChildNotFoundResourcerh   c                   < S# rF   r9   r   s   &&r(   r6   `StaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomChildNotFoundResource.render  r   r   r9   Nr   r   s   @r(   CustomChildNotFoundResourcer     r   r   r   c                   (   < ] tR tRt Z ! 4       tRtR# )NStaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomStaticFilei  r9   N)r:   r;   r<   r=   r   r?   )r   s   r(   r   r     s    79Mr   r   s   no-child.txtN)r
   rR   ra   r   r   r   rQ   rb   r   r   r6   r!   )	r'   rq   r   r   r&   rr   r   r   r   s	   &      @@r(   $test_getChildChildNotFound_customize4StaticFileTests.test_getChildChildNotFound_customize  s    
 &;	&(*;*; 	&	:v{{ 	: (		201%%ow?g&0r   c                  a a \        S P                  4       4      pVP                  R4       \        P                  ! VP
                  4      p\        R.4      oRSn        \        VS4      pVV 3R lpVP                  V4       V# )zL
L{static.File.render} returns an empty response body for I{HEAD}
requests.
r   r   r   c                 ^   < SP                  R P                  SP                  4      R 4       R# r   r    r$   s   &r(   r)   4StaticFileTests.test_headRequest.<locals>.cbRendered  r+   r   )
r
   rR   ra   r   rQ   rb   r   r-   r   r.   )r'   rb   rV   r0   r)   r&   s   f    @r(   r1    StaticFileTests.test_headRequest  sj    
 &{{499%u% D'"	= 	
j!r   c                  a a \        S P                  4       4      pVP                  4        VP                  R4      P	                  R4       \
        P                  ! VP                  4      pR\        P                  /Vn
        \        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )z
If a request is made which encounters a L{File} before a final segment
which names a file with an extension which is in the L{File}'s
C{processors} mapping, the processor associated with that extension is
used to serve the response to the request.
r   sT   from twisted.web.static import Data
resource = Data(b'dynamic world', 'text/plain')
.barr   c                    < SP                  R P                  SP                  4      R4       SP                  SP                  P	                  R4      ^ ,          R4       R# )r   s   dynamic worldr   s   13Nr   r$   s   &r(   r)   3StaticFileTests.test_processors.<locals>.cbRendered  sK    SXXgoo68HI''556GHKUr   )r
   rR   rn   rr   ra   r   rQ   rb   r   ResourceScript
processorsr   r   ro   r   r.   rp   s   f     @r(   test_processorsStaticFileTests.test_processors  s     &

9((A	

 {{499%!6#8#89
|,++D':LL(	 	
j!r   c                V   \         P                  ! R4      pV P                  VP                  . 4       VP	                  R4       VP	                  R4       V P                  VP                  RR.4       \         P                  ! RRR7      pV P                  VP                  RR.4       R# )zy
The list of ignored extensions can be set by passing a value to
L{File.__init__} or by calling L{File.ignoreExt} later.
r   z.foor   .bazrK   N)r   r  )r   rQ   r!   rL   	ignoreExt)r'   rV   s   & r(   test_ignoreExtStaticFileTests.test_ignoreExt  s    
 {{4 ))2.vv))FF+;<{{4-=>))FF+;<r   c                  a a \        S P                  4       4      pVP                  4        VP                  R4      P	                  R4       VP                  R4      P	                  R4       \
        P                  ! VP                  RR7      p\        R.4      o\        P                  ! VS4      pS P                  VS4      pVV 3R lpVP                  V4       V# )	z
A request for the I{base} child of a L{File} succeeds with a resource
for the I{base<extension>} file in the path the L{File} was created
with if such a file exists and the L{File} has been configured to
ignore the I{<extension>} extension.
r   r   zfoo.quuxre   rK   r   c                 ^   < SP                  R P                  SP                  4      R4       R# )r   r   Nr    r$   s   &r(   r)   AStaticFileTests.test_ignoredExtensionsIgnored.<locals>.cbRendered  s     SXXgoo6?r   )r   r   rp   s   f     @r(   test_ignoredExtensionsIgnored-StaticFileTests.test_ignoredExtensionsIgnored  s     &

9((0

:)))4{{499)<x(++D':LL(	@ 	
j!r   c                    \        V P                  4       4      pVP                  4        VP                  R4      P                  4        \        P
                  ! VP                  4      p\        R.4      pRVn        \        P                  ! W#4      pV P                  V P                  WC4      4       V P                  VP                  \        4       V P                  VP                   P#                  R4      R.4       R# )z
A request for a path which is a directory but does not have a trailing
slash will be redirected to a URL which does have a slash by L{File}.
folders   folders   http://dummy/folder#baz?foo=bars   locations    http://dummy/folder/#baz?foo=barN)r
   rR   rn   rr   r   rQ   rb   r   urir   ro   successResultOfr   r!   rj   r   r   r   rx   s   &    r(   +test_directoryWithoutTrailingSlashRedirects;StaticFileTests.test_directoryWithoutTrailingSlashRedirects  s    
 &

8%%'{{499%	{+8++D:T\\%9:--u5##11+>01	
r   c                   a \        4       o\        V P                  4       4      pVP                  4        \        P
                  ! VP                  4      pV3R lVn        SV3# )z
Create a L{File} that when opened for reading, returns a L{StringIO}.

@return: 2-tuple of the opened "file" and the L{File}.
@rtype: L{tuple}
c                     < S # rF   r9   )fakeFiles   r(   <lambda>;StaticFileTests._makeFilePathWithStringIO.<locals>.<lambda>  s    Hr   )StringIOr
   rR   touchr   rQ   rb   r~   )r'   rb   rV   r  s   &  @r(   _makeFilePathWithStringIO)StaticFileTests._makeFilePathWithStringIO  sH     :&

{{499%$	~r   c                   V P                  4       w  r\        R.4      pRVn        V P                  \	        W#4      4       V P                  RP                  VP                  4      R4       V P                  VP                  4       R# )zU
A HEAD request opens the file, gets the size, and then closes it after
the request.
r   r   r   N)
r  r   r-   r  r   r!   r"   r#   
assertTrueclosedr'   r  rV   r&   s   &   r(   test_HEADClosesFile#StaticFileTests.test_HEADClosesFile  sg    
 779t$ WT34'//2C8(r   c                    V P                  4       w  r\        R.4      pRVn        R Vn        V P	                  \        W#4      4       V P                  RP                  VP                  4      R4       V P                  VP                  4       R# )zA
A GET request that is cached closes the file after the request.
r   s   GETc                 "    \         P                  # rF   )r   CACHED)_s   &r(   r  >StaticFileTests.test_cachedRequestClosesFile.<locals>.<lambda>1  s    DKKr   r   N)r  r   r-   setLastModifiedr  r   r!   r"   r#   r!  r"  r#  s   &   r(   test_cachedRequestClosesFile,StaticFileTests.test_cachedRequestClosesFile)  so     779t$"7WT34'//2C8(r   r9   N)r   mcbs))r:   r;   r<   r=   r>   r   rW   r[   r^   r7   rs   ry   r   r   r   r   	isWindowsr   r   r   r   r   r   sysgetfilesystemencodinglowerformatr   r   r   r   r1   r  r
  r  r  r  r$  r,  r?   r@   rA   s   @r(   rD   rD   ?   s     *
1
1
1
C*0/.* H "LM N.0W1662 !!#))+3DD	fS..01

8:*10$<=0
*
)) )r   rD   c                      a  ] tR tRt o RtRR ltR tR tR tR t	R	 t
R
 tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )StaticMakeProducerTestsi7  z!
Tests for L{File.makeProducer}.
Nc                    \        V P                  4       4      pVP                  V4       \        P                  ! VP                  4       4      pW5n        W%n        V# )z
Make a L{static.File} resource that has C{content} for its content.

@param content: The L{bytes} to use as the contents of the resource.
@param type: Optional value for the content type of the resource.
)r
   rR   ra   r   rQ   _asBytesPathencodingtype)r'   r   r9  r8  fileNamer   s   &&&&  r(   makeResourceWithContent/StaticMakeProducerTests.makeResourceWithContent<  sI     DKKM*G$;;x4467$r   c                    / pVP                   P                  4        FE  w  r4VP                  4       P                  R4      '       g   K,  V^ ,          W#P                  4       &   KG  	  V# )z
Extract the content-* headers from the L{DummyRequest} C{request}.

This returns the subset of C{request.outgoingHeaders} of headers that
start with 'content-'.
s   content-)r   getAllRawHeadersr2  
startswith)r'   r&   contentHeaderskvs   &&   r(   r@  &StaticMakeProducerTests.contentHeadersJ  sU     ++<<>DAwwy##K00,-aDwwy) ? r   c                   V P                  R4      p\        . 4      pVP                  ! 4       ;_uu_ 4       pVP                  ! W#4      pV P	                  V\
        P                  4       RRR4       R#   + '       g   i     R# ; i)zX
makeProducer when no Range header is set returns an instance of
NoRangeStaticProducer.
r   N)r;  r   r   makeProducerrv   r   NoRangeStaticProducer)r'   r   r&   rV   producers   &    r(   ,test_noRangeHeaderGivesNoRangeStaticProducerDStaticMakeProducerTests.test_noRangeHeaderGivesNoRangeStaticProducerW  sd    
 //4r"$$&&$,,W;H!!(F,H,HI '&&&s   3A33B	c                "   V P                  R4      p\        . 4      pVP                  ! 4       ;_uu_ 4       pVP                  ! W#4       V P	                  \
        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)zX
makeProducer when no Range header is set sets the responseCode on the
request to 'OK'.
r   N)r;  r   r   rE  r!   r   OKrj   )r'   r   r&   rV   s   &   r(   test_noRangeHeaderSets200OK3StaticMakeProducerTests.test_noRangeHeaderSets200OKb  sf    
 //4r"$$&&$!!'0TWWg&:&:; '&&&s   =A==B	c                n   ^{pRpRpV P                  RV,          W#R7      p\        . 4      pVP                  ! 4       ;_uu_ 4       pVP                  ! WV4       V P	                  R\        V4      RRV3,          R\        V4      /V P                  V4      4       R	R	R	4       R	#   + '       g   i     R	# ; i)
zW
makeProducer when no Range header is set sets the Content-* headers
for the response.

text/plaingzip   ar9  r8     content-typer      %d   content-encodingN)r;  r   r   rE  r!   r	   r@  )r'   lengthcontentTypecontentEncodingr   r&   rV   s   &      r(   $test_noRangeHeaderSetsContentHeaders<StaticMakeProducerTests.test_noRangeHeaderSetsContentHeadersm  s    
 " //6M 0 
 r"$$&&$!!'0#];%?%uy'8')G
 ##G, '&&&s   AB##B4	c                F   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4      pV P                  V\        P                  4       RRR4       R#   + '       g   i     R# ; i)zs
makeProducer when the Range header requests a single byte range
returns an instance of SingleRangeStaticProducer.
   range	   bytes=1-3   abcdefN	r   requestHeadersaddRawHeaderr;  r   rE  rv   r   SingleRangeStaticProducerr'   r&   r   rV   rG  s   &    r(   .test_singleRangeGivesSingleRangeStaticProducerFStaticMakeProducerTests.test_singleRangeGivesSingleRangeStaticProducer  sz    
 r"++HlC//	:$$&&$,,W;H!!(F,L,LM '&&&   3BB 	c                Z   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  \        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer when the Range header requests a single, satisfiable byte
range sets the response code on the request to 'Partial Content'.
r\  r]  r^  N
r   r`  ra  r;  r   rE  r!   r   PARTIAL_CONTENTrj   r'   r&   r   rV   s   &   r(   %test_singleRangeSets206PartialContent=StaticMakeProducerTests.test_singleRangeSets206PartialContent  s~    
 r"++HlC//	:$$&&$!!'0T1173G3GH '&&&   =BB*	c                   \        . 4      pVP                  P                  RR4       RpRpV P                  RW#R7      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  R\        V4      R\        V4      R	R
RR/V P                  V4      4       RRR4       R#   + '       g   i     R# ; i)x
makeProducer when the Range header requests a single, satisfiable byte
range sets the Content-* headers appropriately.
r\  r]  rO  rP  r^  rR  rS  rU     content-ranges   bytes 1-3/6r   r   N)	r   r`  ra  r;  r   rE  r!   r	   r@  )r'   r&   rW  rX  r   rV   s   &     r(   "test_singleRangeSetsContentHeaders:StaticMakeProducerTests.test_singleRangeSetsContentHeaders  s    
 r"++HlC" //K 0 
 $$&&$!!'0#];%?')G$n%t	 ##G, '&&&s   AB00C	c                F   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4      pV P                  V\        P                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer still returns an instance of L{SingleRangeStaticProducer}
when the Range header requests a single unsatisfiable byte range.
r\  
   bytes=4-10   abcNr_  rc  s   &    r(   =test_singleUnsatisfiableRangeReturnsSingleRangeStaticProducerUStaticMakeProducerTests.test_singleUnsatisfiableRangeReturnsSingleRangeStaticProducer  sz    
 r"++HmD//7$$&&$,,W;H!!(F,L,LM '&&&rf  c                Z   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  \        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer sets the response code of the request to of 'Requested
Range Not Satisfiable' when the Range header requests a single
unsatisfiable byte range.
r\  rt  ru  N
r   r`  ra  r;  r   rE  r!   r   REQUESTED_RANGE_NOT_SATISFIABLErj   rj  s   &   r(   ?test_singleUnsatisfiableRangeSets416ReqestedRangeNotSatisfiableWStaticMakeProducerTests.test_singleUnsatisfiableRangeSets416ReqestedRangeNotSatisfiable  s~     r"++HmD//7$$&&$!!'0TAA7CWCWX '&&&rm  c           
     \   \        . 4      pVP                  P                  RR4       RpV P                  RVR7      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  RRRR	R
R/V P                  V4      4       RRR4       R#   + '       g   i     R# ; i)zz
makeProducer when the Range header requests a single, unsatisfiable
byte range sets the Content-* headers appropriately.
r\  rt  rO  ru  r9  rS  
   text/plainr      0rp  	   bytes */3Nr   r`  ra  r;  r   rE  r!   r@  r'   r&   rW  r   rV   s   &    r(   /test_singleUnsatisfiableRangeSetsContentHeadersGStaticMakeProducerTests.test_singleUnsatisfiableRangeSetsContentHeaders  s    
 r"++HmD"//[/I$$&&$!!'0#]%t$l
 ##G, '&&&   :BB+	c           
     \   \        . 4      pVP                  P                  RR4       RpV P                  RVR7      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  RRRR	R
R/V P                  V4      4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer when the Range header requests a single byte range that
partly overlaps the resource sets the Content-* headers appropriately.
r\  s
   bytes=2-10rO  ru  r~  rS  r  r      1rp  s   bytes 2-2/3Nr  r  s   &    r(   6test_singlePartiallyOverlappingRangeSetsContentHeadersNStaticMakeProducerTests.test_singlePartiallyOverlappingRangeSetsContentHeaders  s    
 r"++HmD"//[/I$$&&$!!'0#]%t$n
 ##G, '&&&r  c                F   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4      pV P                  V\        P                  4       RRR4       R#   + '       g   i     R# ; i)zu
makeProducer when the Range header requests a single byte range
returns an instance of MultipleRangeStaticProducer.
r\     bytes=1-3,5-6r^  N	r   r`  ra  r;  r   rE  rv   r   MultipleRangeStaticProducerrc  s   &    r(   2test_multipleRangeGivesMultipleRangeStaticProducerJStaticMakeProducerTests.test_multipleRangeGivesMultipleRangeStaticProducer  s{    
 r"++H6FG//	:$$&&$,,W;H!!(F,N,NO '&&&rf  c                Z   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  \        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer when the Range header requests a multiple satisfiable
byte ranges sets the response code on the request to 'Partial
Content'.
r\  r  r^  Nrh  rj  s   &   r(   'test_multipleRangeSets206PartialContent?StaticMakeProducerTests.test_multipleRangeSets206PartialContent  s     r"++H6FG//	:$$&&$!!'0T1173G3GH '&&&rm  c           	        \        . 4      pVP                  P                  RR4       V P                  RRR7      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4      pV P                  V4      pV P                  RR0\        VP                  4       4      4       ^pVP                   F  w  rxp	V\        V4      ,          pK  	  V P                  RV3,          VR,          4       V P                  RV4       VR,          p
V P                  R	\        P                  ! R
V
4      4       V P!                  RV4       R	R	R	4       R	#   + '       g   i     R	# ; i)ro  r\  r  s   abcdefghijklrP  )r8  r   rS  rT  Ns(   multipart/byteranges; boundary="[^"]*"\ZrU  )r   r`  ra  r;  r   rE  r@  r!   setkeys	rangeInforS   assertInassertNotIdenticalrematchassertNotIn)r'   r&   r   rV   rG  r@  expectedLengthboundaryoffsetsizerW  s   &          r(   #test_mutipleRangeSetsContentHeaders;StaticMakeProducerTests.test_mutipleRangeSetsContentHeaders  s8   
 r"++H6FG//&/Q$$&&$,,W;H!009N"O4c.:M:M:O6P N*2*<*<&$#h-/ +=))>:K+L
 MM/>:(9K##E{S 0.A3 '&&&s   C.EE	c                F   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4      pV P                  V\        P                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer still returns an instance of L{SingleRangeStaticProducer}
when the Range header requests multiple ranges, none of which are
satisfiable.
r\     bytes=10-12,15-20ru  Nr  rc  s   &    r(   Btest_multipleUnsatisfiableRangesReturnsMultipleRangeStaticProducerZStaticMakeProducerTests.test_multipleUnsatisfiableRangesReturnsMultipleRangeStaticProducer1  s{     r"++H6JK//7$$&&$,,W;H!!(F,N,NO '&&&rf  c                Z   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  \        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer sets the response code of the request to of 'Requested
Range Not Satisfiable' when the Range header requests multiple ranges,
none of which are satisfiable.
r\  r  ru  Nry  rj  s   &   r(   Btest_multipleUnsatisfiableRangesSets416ReqestedRangeNotSatisfiableZStaticMakeProducerTests.test_multipleUnsatisfiableRangesSets416ReqestedRangeNotSatisfiable>  s     r"++H6JK//7$$&&$!!'0TAA7CWCWX '&&&rm  c           
        \        . 4      pVP                  P                  RR4       RpVP                  P                  RR4       V P                  RVR7      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  RRR	R
RR/V P                  V4      4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer when the Range header requests multiple ranges, none of
which are satisfiable, sets the Content-* headers appropriately.
r\  rt  rO  r  ru  r~  r   r  rp  r  rS  r  Nr  r  s   &    r(   1test_multipleUnsatisfiableRangeSetsContentHeadersIStaticMakeProducerTests.test_multipleUnsatisfiableRangeSetsContentHeadersK  s    
 r"++HmD"++H6JK//[/I$$&&$!!'0%t$l#]
 ##G, '&&&s   2:B66C	c                Z   \        . 4      pVP                  P                  RR4       V P                  R4      pVP                  ! 4       ;_uu_ 4       pVP
                  ! W4       V P                  \        P                  VP                  4       RRR4       R#   + '       g   i     R# ; i)z
makeProducer when the Range header requests multiple ranges, at least
one of which matches, sets the response code to 'Partial Content'.
r\  s   bytes=1-3,100-200r^  Nrh  rj  s   &   r(    test_oneSatisfiableRangeIsEnough8StaticMakeProducerTests.test_oneSatisfiableRangeIsEnough`  s    
 r"++H6JK//	:$$&&$!!'0T1173G3GH '&&&rm  r9   )NN)r:   r;   r<   r=   r>   r;  r@  rH  rL  rY  rd  rk  rq  rv  r{  r  r  r  r  r  r  r  r  r  r?   r@   rA   s   @r(   r5  r5  7  s{     	J	<.
N
I0
NY((
PI!BFPY*
I 
Ir   r5  c                   0   a  ] tR tRt o RtR tR tRtV tR# )StaticProducerTestsim  z+
Tests for the abstract L{StaticProducer}.
c                    \        4       p\        P                  ! RV4      pVP                  4        V P	                  VP
                  4       R# )z]
L{StaticProducer.stopProducing} closes the file object the producer is
producing data from.
N)r  r   StaticProducerstopProducingr!  r"  r'   
fileObjectrG  s   &  r(   test_stopProducingClosesFile0StaticProducerTests.test_stopProducingClosesFiler  s;    
 Z
((z: 
))*r   c                    \        4       p\        P                  ! \        . 4      V4      pVP	                  4        V P                  RVP                  4       R# )z
L{StaticProducer.stopProducing} sets the request instance variable to
None, which indicates to subclasses' resumeProducing methods that no
more data should be produced.
N)r  r   r  r   r  assertIdenticalr&   r  s   &  r(   #test_stopProducingSetsRequestToNone7StaticProducerTests.test_stopProducingSetsRequestToNone|  sD     Z
((b)9:F T8#3#34r   r9   N)	r:   r;   r<   r=   r>   r  r  r?   r@   rA   s   @r(   r  r  m  s     +	5 	5r   r  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	NoRangeStaticProducerTestsi  z%
Tests for L{NoRangeStaticProducer}.
c                d    \        \        P                  \        P                  ! RR4      4       R# )z7
L{NoRangeStaticProducer} implements L{IPullProducer}.
N)r   r   IPullProducerr   rF  r   s   &r(   test_implementsIPullProducer7NoRangeStaticProducerTests.test_implementsIPullProducer  s"     	Z--v/K/KDRV/WXr   c                    \        . 4      pRp\        P                  ! V\        V4      4      pVP	                  4        V P                  VRP                  VP                  4      4       R# )z[
L{NoRangeStaticProducer.resumeProducing} writes content from the
resource to the request.
r^  r   N)r   r   rF  r  startr!   r"   r#   r'   r&   r   rG  s   &   r(   #test_resumeProducingProducesContent>NoRangeStaticProducerTests.test_resumeProducingProducesContent  sS    
 r"//'9JK 	#((7??";<r   c                J   \        . 4      p\        P                  P                  pR^V,          ^,           ,          p\        P
                  ! V\        V4      4      pVP                  4        V^ V W2^V,           V^V,          R .pV P                  WQP                  4       R# )z
L{NoRangeStaticProducer.start} writes at most
C{abstract.FileDescriptor.bufferSize} bytes of content from the
resource to the request at once.
rQ  N)
r   r   FileDescriptor
bufferSizer   rF  r  r  r!   r#   r'   r&   r  r   rG  expecteds   &     r(   !test_resumeProducingBuffersOutput<NoRangeStaticProducerTests.test_resumeProducingBuffersOutput  s     r",,77
!j.1,-//'9JK 	Aj!Z0A
N$%

 	??3r   c                    \        . 4      pVP                  4       p. pVP                  VP                  4       \        P
                  ! V\        R4      4      pVP                  4        V P                  R.V4       R# )zl
L{NoRangeStaticProducer.resumeProducing} calls finish() on the request
after it is done producing content.
r^  N)	r   notifyFinishr.   appendr   rF  r  r  r!   r'   r&   finishDeferredcallbackListrG  s   &    r(   test_finishCalledWhenDone4NoRangeStaticProducerTests.test_finishCalledWhenDone  sj    
 r" --/""<#6#67//)9LM 	$.r   r9   Nr:   r;   r<   r=   r>   r  r  r  r  r?   r@   rA   s   @r(   r  r    s$     Y=4(/ /r   r  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	SingleRangeStaticProducerTestsi  z)
Tests for L{SingleRangeStaticProducer}.
c           	     h    \        \        P                  \        P                  ! RRRR4      4       R# )z;
L{SingleRangeStaticProducer} implements L{IPullProducer}.
N)r   r   r  r   rb  r   s   &r(   r  ;SingleRangeStaticProducerTests.test_implementsIPullProducer  s)     	$$,,T4tD	
r   c                    \        . 4      pRp\        P                  ! V\        V4      ^^4      pVP	                  4        V P                  VR,          RP                  VP                  4      4       R# )z
L{SingleRangeStaticProducer.resumeProducing} writes the given amount
of content, starting at the given offset, from the resource to the
request.
r^  :      Nr   N)r   r   rb  r  r  r!   r"   r#   r  s   &   r(   r  BSingleRangeStaticProducerTests.test_resumeProducingProducesContent  s]     r"33GXg=NPQSTU 	sxx'@Ar   c                F   \        . 4      p\        P                  P                  pRV,          p\        P
                  ! V\        V4      ^V^
,           4      pVP                  4        V^V^,            W2^,           V^,            .pV P                  WQP                  4       R# )z
L{SingleRangeStaticProducer.start} writes at most
C{abstract.FileDescriptor.bufferSize} bytes of content from the
resource to the request at once.
ru  N)
r   r   r  r  r   rb  r  r  r!   r#   r  s   &     r(   r  @SingleRangeStaticProducerTests.test_resumeProducingBuffersOutput  s     r",,77
:%33Xg&:?

 	A
Q'NZ"_5
 	??3r   c                    \        . 4      pVP                  4       p. pVP                  VP                  4       \        P
                  ! V\        R4      ^^4      pVP                  4        V P                  R.V4       R# )zp
L{SingleRangeStaticProducer.resumeProducing} calls finish() on the
request after it is done producing content.
r^  N)	r   r  r.   r  r   rb  r  r  r!   r  s   &    r(   r  8SingleRangeStaticProducerTests.test_finishCalledWhenDone  sp    
 r" --/""<#6#6733GXi=PRSUVW 	$.r   r9   Nr  rA   s   @r(   r  r    s$     
B4*/ /r   r  c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	 MultipleRangeStaticProducerTestsi  z+
Tests for L{MultipleRangeStaticProducer}.
c                f    \        \        P                  \        P                  ! RRR4      4       R# )z=
L{MultipleRangeStaticProducer} implements L{IPullProducer}.
N)r   r   r  r   r  r   s   &r(   r  =MultipleRangeStaticProducerTests.test_implementsIPullProducer
  s'     	$$..tT4@	
r   c                    \        . 4      pRp\        P                  ! V\        V4      RR.4      pVP	                  4        V P                  RRP                  VP                  4      4       R# )z
L{MultipleRangeStaticProducer.resumeProducing} writes the requested
chunks of content from the resource to the request, with the supplied
boundaries in between each chunk.
r^  s   1bcd2fr   N)r  r     )   2   r  )r   r   r  r  r  r!   r"   r#   r  s   &   r(   r  DMultipleRangeStaticProducerTests.test_resumeProducingProducesContent  s]     r"55Xg&|(D

 	CHHW__$=>r   c                4   \        . 4      pRp\        P                  ! V\        V4      . R	O4      p^
Vn        VP                  4        RVR,          ,           R,           VR,          ,           VR,          R,           .pV P                  WAP                  4       R# )
aB  
L{MultipleRangeStaticProducer.start} writes about
C{abstract.FileDescriptor.bufferSize} bytes of content from the
resource to the request at once.

To be specific about the 'about' above: it can write slightly more,
for example in the case where the first boundary plus the first chunk
is less than C{bufferSize} but first boundary plus the first chunk
plus the second boundary is more, but this is unimportant as in
practice the boundaries are fairly small.  On the other side, it is
important for performance to bundle up several small chunks into one
call to request.write.
rQ     b   c:       N:r     N:r     NNs   01234567890123456789))rQ  r  r  )r  r  
   )r  r  r  )r   r   r  r  r  r  r!   r#   )r'   r&   r   rG  r  s   &    r(   r  BMultipleRangeStaticProducerTests.test_resumeProducingBuffersOutput#  s     r"#55Xg&(S
 ! 	73<$&6ENT!
 	??3r   c                    \        . 4      pVP                  4       p. pVP                  VP                  4       \        P
                  ! V\        R4      R.4      pVP                  4        V P                  R.V4       R# )zr
L{MultipleRangeStaticProducer.resumeProducing} calls finish() on the
request after it is done producing content.
r^  N)r   r  r  )	r   r  r.   r  r   r  r  r  r!   r  s   &    r(   r  :MultipleRangeStaticProducerTests.test_finishCalledWhenDone@  sq    
 r" --/""<#6#6755Xi(;-

 	$.r   r9   Nr  rA   s   @r(   r  r    s#     
? 4:/ /r   r  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )
RangeTestsiR  a  
Tests for I{Range-Header} support in L{twisted.web.static.File}.

@type file: L{file}
@ivar file: Temporary (binary) file containing the content to be served.

@type resource: L{static.File}
@ivar resource: A leaf web resource using C{file} as content.

@type request: L{DummyRequest}
@ivar request: A fake request, requesting C{resource}.

@type catcher: L{list}
@ivar catcher: List which gathers all log information.
c                   \        V P                  4       4      pRV n        VP                  V P                  4       VP	                  4       V n        \        P                  ! V P
                  P                  4      V n	        ^V P                  n
        \        R.4      V n        V P
                  P                  V P                  n        . V n        \        P                   ! V P                  P"                  4       R# )z
Create a temporary file with a fixed payload of 64 bytes.  Create a
resource for that file and create a request which will be for that
resource.  Each test can set a different range header to test different
aspects of the implementation.
s@   uE7 a0y0S﬷M6k{	мkYIoZbk&%݂q/AYr   N)r
   rR   payloadra   r~   rV   r   rQ   r   r   isLeafr   r&   r  catcherr   addObserverr  )r'   rb   s   & r(   setUpRangeTests.setUpc  s     &* 	 	%IIK	DIINN3 #SE*99>>++,r   c                    V P                   P                  4        \        P                  ! V P                  P
                  4       R# )z2
Clean up the resource file and the log observer.
N)rV   r   r   removeObserverr  r  r   s   &r(   tearDownRangeTests.tearDown  s*     			4<<../r   c                    V P                   P                  4       pV P                  VR,          ^ ,          V4       V P                  V P                   . RV: 24       R# )zE
Asserts that a given log message occurred with an expected message.
messagezAn additional log occurred: N)r  popr!   )r'   r  logItems   && r(   _assertLoggedRangeTests._assertLogged  sN     ,,""$+A.9r-I'+UVr   c                t   V P                   P                  pV P                  \        VR4       V P                  \        VR4       V P                  \        VR4       V P                  \        VR4       V P                  \        VR4       V P                  \        VR4       V P                  \        VR4       R# )	z_
L{File._parseRangeHeader} raises L{ValueError} when passed
syntactically invalid byte ranges.
s   bytess   unknown=1-2s   bytes=3s   bytes=-s
   bytes=foo-s
   bytes=-foos	   bytes=5-4N)r   _parseRangeHeaderr5   
ValueError)r'   fs   & r(   test_invalidRangesRangeTests.test_invalidRanges  s    
 MM++ 	*a2 	*a8 	*a4 	*a4 	*a7 	*a7 	*a6r   c                ^    V P                  V P                  P                  R4      R.4       R# )zz
A single bytes range without an explicit stop position is parsed into a
two-tuple giving the start position and L{None}.
s   bytes=0-N)r  Nr!   r   r  r   s   &r(   test_rangeMissingStop RangeTests.test_rangeMissingStop  %    
 	88E	{Sr   c                ^    V P                  V P                  P                  R4      R.4       R# )zu
A single bytes range without an explicit start position is parsed into
a two-tuple of L{None} and the end position.
s   bytes=-3N)Nr  r  r   s   &r(   test_rangeMissingStart!RangeTests.test_rangeMissingStart  r  r   c                ^    V P                  V P                  P                  R4      R.4       R# )zl
A single bytes range with explicit start and stop positions is parsed
into a two-tuple of those positions.
s	   bytes=2-5N)r  r  r  r   s   &r(   
test_rangeRangeTests.test_range  s%    
 	88FQr   c                   V P                  V P                  P                  R4      R.4       V P                  V P                  P                  R4      R.4       V P                  V P                  P                  R4      R.4       V P                  V P                  P                  R4      R.4       V P                  V P                  P                  R4      R.4       V P                  V P                  P                  R4      R.4       R# )	zy
A single bytes range with whitespace in allowed places is parsed in
the same way as it would be without the whitespace.
s    bytes=1-2 s   bytes =1-2 s
   bytes= 1-2s
   bytes=1 -2s
   bytes=1- 2s
   bytes=1-2 Nr  r  r  r   s   &r(   test_rangeWithSpaceRangeTests.test_rangeWithSpace  s    
 	88H6(S88H6(S88G&R88G&R88G&R88G&Rr   c                ^    V P                  V P                  P                  R4      R.4       R# )z{
If there are multiple byte ranges but only one is non-null, the
non-null range is parsed and its start and stop returned.
s   bytes=1-2,
, ,	Nr  r  r   s   &r(   test_nullRangeElements!RangeTests.test_nullRangeElements  s)    
 	MM++,BCfX	
r   c                `    V P                  V P                  P                  R4      RR.4       R# )zL
If multiple byte ranges are specified their starts and stops are
returned.
s   bytes=1-2,3-4Nr  )r  r  r  r   s   &r(   test_multipleRangesRangeTests.test_multipleRanges  s,    
 	MM++,<=?O	
r   c                   V P                   P                  P                  RR4       V P                  P	                  V P                   4       V P                  \        RP                  V P                   P                  4      4      ^,4       R# )zX
A correct response to a range request is as long as the length of the
requested range.
r\  s
   bytes=0-43r   N)	r&   r`  ra  r   r6   r!   rS   r"   r#   r   s   &r(   test_bodyLengthRangeTests.test_bodyLength  s\    
 	##00=IT\\*SXXdll&:&:;<bAr   c                ~   RpV P                   P                  P                  RV4       V P                  P	                  V P                   4       RVP                  4       : 2pV P                  V4       V P                  RP                  V P                   P                  4      V P                  4       V P                  V P                   P                  \        P                  4       V P                  V P                   P                  P                  R4      ^ ,          R\!        V P                  4      3,          4       R# )z
An incorrect range request (RFC 2616 defines a correct range request as
a Bytes-Unit followed by a '=' character followed by a specific range.
Only 'bytes' is defined) results in the range header value being logged
and a normal 200 response being sent.
s   foobar=0-43r\  z Ignoring malformed Range header r   r   rT  N)r&   r`  ra  r   r6   r   r	  r!   r"   r#   r  rj   r   rK  r   r   rS   )r'   ranger  s   &  r(   test_invalidRangeRequest#RangeTests.test_invalidRangeRequest  s     ##005AT\\*5elln5GH8$$,,"6"67F22DGG<LL((667HI!LS&((	
r   c           	        RV,           pVP                  V4      pV P                  RV^ ,          4       V P                  RVR,          4       . pV^R  F  pVP                  R^4      w  rxrpVR,           V	,           pV P                  RV4       V P                  RV
4       \        P                  ! RV\        P                  \        P
                  ,          4      P                  ^4      p\        P                  ! RV\        P                  \        P
                  ,          4      P                  4       w  rpVP                  RVR	WV3R
V/4       K  	  V# )z
Parse C{body} as a multipart MIME response separated by C{boundary}.

Note that this with fail the calling test on certain syntactic
problems.
s   
--r   s   --
s   
   
s   ^content-type: (.*)$s1   ^content-range: bytes ([0-9]+)-([0-9]+)/([0-9]+)$   contentType   contentRange   body)	splitr!   r  searchIMgroupgroupsr  )r'   bodyr  seppartsparsed_partspartbeforeheader1header2blankpartBodyheaderspartContentTypeValuer  endr  s   &&&              r(   parseMultipartBodyRangeTests.parseMultipartBody  s1    ("

3eAh'E"I.!BKD8<

7A8N5FWXo/GS&)S%(#%99'"$$+$eAh !  "yyDrtt  fh	 E
 "$8#e$%7X  ( r   c                   . ROpRP                  V UUu. uF  w  r#\        V RV 24      NK  	  upp4      pV P                  P                  P	                  RRV,           4       V P
                  P                  V P                  4       V P                  V P                  P                  \        P                  4       \        P                  ! RV P                  P                  P                  R4      ^ ,          4      P                  ^4      pV P!                  RP                  V P                  P"                  4      V4      pV P                  \%        V4      \%        V4      4       \'        Wa4       F  w  pw  r#V P                  \        V P
                  P(                  4      VR,          4       VR	,          w  rp
V P                  \+        V4      V4       V P                  \+        V	4      V4       V P                  \+        V
4      V P
                  P-                  4       4       V P                  V P.                  W#^,            VR
,          4       K  	  R# u uppi )zW
The response to a request for multiple bytes ranges is a MIME-ish
multipart response.
   ,-r\     bytes='   ^multipart/byteranges; boundary="(.*)"$rS  r   r/  r0  r1  N)r  r  )      )(   2   )r"   r	   r&   r`  ra  r   r6   r!   rj   r   ri  r  r  r   r   r7  rF  r#   rS   zipr9  intgetFileSizer  r'   	startEndsserangeHeaderValuer  r;  r=  r  rE  r  s   &          r(   test_multipleRangeRequest$RangeTests.test_multipleRangeRequest  s   
 1	995>?Y6A]aS!:&Y?
 	##009GW;WXT\\*22D4H4HI886LL((66GJ
 %( 	 ''1E1E(FQYU41LD&1]4==+=+=>^@TU#O4ESZ+SXq)SY(A(A(CDT\\!!e4d7mD 2 @s   I
c                F   R^(\        V P                  4      ^
,           3.pRP                  V UUu. uF  w  r#\        V RV 24      NK  	  upp4      pV P                  P
                  P                  RRV,           4       V P                  P                  V P                  4       V P                  V P                  P                  \        P                  4       \        P                  ! RV P                  P                  P!                  R4      ^ ,          4      P#                  ^4      pV P%                  RP                  V P                  P&                  4      V4      pV P                  \        V4      \        V4      4       \)        Wa4       EF  w  pw  r#V P                  \        V P                  P*                  4      VR,          4       VR	,          w  rp
V P                  \-        V4      V4       V P                  \-        V	4      \/        W0P                  P1                  4       ^,
          4      4       V P                  \-        V
4      V P                  P1                  4       4       V P                  V P                  W#^,            VR
,          4       EK  	  R# u uppi )z
The response to a request for multiple bytes ranges is a MIME-ish
multipart response, even when one of the ranged falls off the end of
the resource.
rI  rJ  r\  rK  rL  rS  r   r/  r0  r1  NrM  )rS   r  r"   r	   r&   r`  ra  r   r6   r!   rj   r   ri  r  r  r   r   r7  rF  r#   rR  r9  rS  minrT  rU  s   &          r(   0test_multipleRangeRequestWithRangeOverlappingEnd;RangeTests.test_multipleRangeRequestWithRangeOverlappingEnd5  s    b#dll"3b"89:	995>?Y6A]aS!:&Y?
 	##009GW;WXT\\*22D4H4HI886LL((66GJ
 %( 	 ''1E1E(FQYU41LD&1]4==+=+=>^@TU#O4ESZ+SXs1mm.G.G.IA.M'NOSY(A(A(CDT\\!!e4d7mD 2 @s   J
c                   V P                   P                  P                  RR4       V P                  P	                  V P                   4       V P                  RP                  V P                   P                  4      V P                  R,          4       V P                  \        RP                  V P                   P                  4      4      ^)4       V P                  V P                   P                  \        P                  4       V P                  V P                   P                  P                  R4      ^ ,          R4       V P                  V P                   P                  P                  R4      ^ ,          R4       R	# )
z
If the end byte position is omitted, then it is treated as if the
length of the resource was specified by the end byte position.
r\  s	   bytes=23-r   :   NNrp  s   bytes 23-63/64r   s   41Nr&   r`  ra  r   r6   r!   r"   r#   r  rS   rj   r   ri  r   r   r   s   &r(   test_implicitEndRangeTests.test_implicitEndP  s   
 	##00<HT\\*$,,"6"67c9JKSXXdll&:&:;<bA22D4H4HILL((667GHK	
 	LL((667HI!Le	
r   c                   V P                   P                  P                  RR4       V P                  P	                  V P                   4       V P                  RP                  V P                   P                  4      V P                  R	R 4       V P                  \        RP                  V P                   P                  4      4      ^4       V P                  V P                   P                  \        P                  4       V P                  V P                   P                  P                  R4      ^ ,          R4       V P                  V P                   P                  P                  R4      ^ ,          R4       R# )
z
If the start byte position is omitted but the end byte position is
supplied, then the range is treated as requesting the last -N bytes of
the resource, where N is the end byte position.
r\  s	   bytes=-17r   Nrp  s   bytes 47-63/64r   s   17irb  r   s   &r(   test_implicitStartRangeTests.test_implicitStartb  s	    	##00<HT\\*$,,"6"67cd9KLSXXdll&:&:;<bA22D4H4HILL((667GHK	
 	LL((667HI!Le	
r   c                   V P                   P                  P                  RR4       V P                  P	                  V P                   4       RP                  V P                   P                  4      pV P                  WP                  R,          4       V P                  V P                   P                  \        P                  4       V P                  V P                   P                  P                  R4      ^ ,          R4       V P                  R\        V4      3,          V P                   P                  P                  R4      ^ ,          4       R	# )
z
A correct response to a bytes range header request from A to B starts
with the A'th byte and ends with (including) the B'th byte. The first
byte of a page is numbered with 0.
r\  s
   bytes=3-43r   :r  ,   Nrp  s   bytes 3-43/64rT  r   Nr&   r`  ra  r   r6   r"   r#   r!   r  rj   r   ri  r   r   rS   r'   r#   s   & r(   test_explicitRangeRangeTests.test_explicitRangeu  s     	##00=IT\\*((4<<//0,,t"4522D4H4HILL((667GHK	
 	S\O#LL((667HI!L	
r   c                   V P                   P                  P                  RR4       V P                  P	                  V P                   4       RP                  V P                   P                  4      pV P                  WP                  R,          4       V P                  V P                   P                  \        P                  4       V P                  V P                   P                  P                  R4      ^ ,          R4       V P                  R\        V4      3,          V P                   P                  P                  R4      ^ ,          4       R	# )
z
A correct response to a bytes range header request from A to B when B
is past the end of the resource starts with the A'th byte and ends
with the last byte of the resource. The first byte of a page is
numbered with 0.
r\  s   bytes=40-100r   :rP  NNrp  s   bytes 40-63/64rT  r   Nrj  rk  s   & r(    test_explicitRangeOverlappingEnd+RangeTests.test_explicitRangeOverlappingEnd  s     	##00?KT\\*((4<<//0,,s"3422D4H4HILL((667GHK	
 	S\O#LL((667HI!L	
r   c                0   V P                   P                  P                  RR4       V P                  P	                  V P                   4       V P                  V P                   P                  \        P                  4       V P                  RP                  V P                   P                  4      V P                  4       V P                  V P                   P                  P                  R4      ^ ,          R\        V P                  4      3,          4       R# )z
If a range is syntactically invalid due to the start being greater than
the end, the range header is ignored (the request is responded to as if
it were not present).
r\  s   bytes=20-13r   r   rT  N)r&   r`  ra  r   r6   r!   rj   r   rK  r"   r#   r  r   r   rS   r   s   &r(   +test_statusCodeRequestedRangeNotSatisfiable6RangeTests.test_statusCodeRequestedRangeNotSatisfiable  s     	##00>JT\\*22DGG<$,,"6"67FLL((667HI!LS&((	
r   c           	        V P                   P                  P                  RR4       V P                  P	                  V P                   4       V P                  V P                   P                  \        P                  4       V P                  RP                  V P                   P                  4      R4       V P                  V P                   P                  P                  R4      ^ ,          R4       V P                  V P                   P                  P                  R4      ^ ,          \        R\        V P                  4      3,          4      4       R# )	z
If a range is unsatisfiable due to the start not being less than the
length of the resource, the response is 416 (Requested range not
satisfiable) and no data is written to the response body (RFC 2616,
section 14.35.1).
r\  s   bytes=67-108r   r   r  rp  z
bytes */%dN)r&   r`  ra  r   r6   r!   rj   r   rz  r"   r#   r   r   r	   rS   r  r   s   &r(   test_invalidStartBytePos#RangeTests.test_invalidStartBytePos  s     	##00?KT\\*LL%%t'K'K	
 	$,,"6"67=LL((667HI!Ld	
 	LL((667GHK,#dll*;)==>	
r   )r  rV   r  r&   r   N)r:   r;   r<   r=   r>   r  r  r	  r  r  r  r  r  r!  r$  r'  r+  rF  rZ  r^  rc  rf  rl  ro  rr  ru  r?   r@   rA   s   @r(   r  r  R  s      -80W78TTR
S

B
& DE4E6
$
&
(
*

 
r   r  c                      a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR t]! ]P"                  ! 4       '       * R4      R 4       tR tR tR tRtV tR# )DirectoryListerTestsi  z&
Tests for L{static.DirectoryLister}.
c                *    \        R .4      pWn        V# )r   )r   r  )r'   r  r&   s   && r(   _requestDirectoryListerTests._request  s    u%r   c                    \        V P                  4       4      pVP                  4        \        P                  ! VP
                  4      pVP                  V P                  R4      4      pV P                  RV4       V P                  RV4       R# )zU
L{static.DirectoryLister} prints the request uri as header of the
rendered content.
r   s"   <h1>Directory listing for foo</h1>s(   <title>Directory listing for foo</title>N	r
   rR   rn   r   rw   rb   r6   rz  r  r'   rb   listerr/   s   &   r(   test_renderHeader&DirectoryListerTests.test_renderHeader  sf    
 &''		2}}T]]623;TBA4Hr   c                    \        V P                  4       4      pVP                  4        \        P                  ! VP
                  4      pVP                  V P                  R4      4      pV P                  RV4       V P                  RV4       R# )zG
L{static.DirectoryLister} unquote the request uri before printing it.
s	   foo%20bars&   <h1>Directory listing for foo bar</h1>s,   <title>Directory listing for foo bar</title>Nr}  r~  s   &   r(   test_renderUnquoteHeader-DirectoryListerTests.test_renderUnquoteHeader  sf     &''		2}}T]]<89?FEtLr   c                    \        V P                  4       4      pVP                  4        \        P                  ! VP
                  4      pVP                  V P                  R4      4      pV P                  RV4       V P                  RV4       R# )zT
L{static.DirectoryLister} escape "&", "<" and ">" after unquoting the
request uri.
s	   foo%26bars*   <h1>Directory listing for foo&amp;bar</h1>s0   <title>Directory listing for foo&amp;bar</title>Nr}  r~  s   &   r(   test_escapeHeader&DirectoryListerTests.test_escapeHeader  sf    
 &''		2}}T]]<89CTJI4Pr   c                   \        V P                  4       4      pVP                  4        VP                  R4      P	                  R4       VP                  R4      P	                  RR,          4       \
        P                  ! VP                  4      pVP                  V P                  R4      4      pRpV P                  WC4       R# )	zM
L{static.DirectoryLister} is able to list all the files inside a
directory.
file1s   content1file2s   content2i  r   s   <tr class="odd">
    <td><a href="file1">file1</a></td>
    <td>8B</td>
    <td>[text/html]</td>
    <td></td>
</tr>
<tr class="even">
    <td><a href="file2">file2</a></td>
    <td>7K</td>
    <td>[text/html]</td>
    <td></td>
</tr>N)r
   rR   rn   rr   ra   r   rw   rb   r6   rz  r  r'   rb   r  r/   r9  s   &    r(   test_renderFiles%DirectoryListerTests.test_renderFiles  s    
 &

7&&{3

7&&{T'9:''		2}}T]]623	 	d!r   c                z   \        V P                  4       4      pVP                  4        VP                  R4      P                  4        VP                  R4      P                  4        \        P
                  ! VP                  4      pVP                  V P                  R4      4      pRpV P                  WC4       R# )zS
L{static.DirectoryLister} is able to list all the directories inside
a directory.
dir1zdir2 & 3r   s   <tr class="odd">
    <td><a href="dir1/">dir1/</a></td>
    <td></td>
    <td>[Directory]</td>
    <td></td>
</tr>
<tr class="even">
    <td><a href="dir2%20%26%203/">dir2 &amp; 3/</a></td>
    <td></td>
    <td>[Directory]</td>
    <td></td>
</tr>N
r
   rR   rn   rr   r   rw   rb   r6   rz  r  r  s   &    r(   test_renderDirectories+DirectoryListerTests.test_renderDirectories  s    
 &

6##%

:'')''		2}}T]]623	 	d!r   c                   \        V P                  4       4      pVP                  4        VP                  R4      P                  4        VP                  R4      P                  4        VP                  R4      P                  4        \        P
                  ! VP                  RR.R7      pVP                  V P                  R4      4      pRpV P                  WC4       R# )zy
L{static.DirectoryLister} takes an optional C{dirs} argument that
filter out the list of directories and files printed.
r  dir2dir3)dirsr   s   <tr class="odd">
    <td><a href="dir1/">dir1/</a></td>
    <td></td>
    <td>[Directory]</td>
    <td></td>
</tr>
<tr class="even">
    <td><a href="dir3/">dir3/</a></td>
    <td></td>
    <td>[Directory]</td>
    <td></td>
</tr>Nr  r  s   &    r(   test_renderFiltered(DirectoryListerTests.test_renderFiltered(  s    
 &

6##%

6##%

6##%''		8HI}}T]]623	 	d!r   c                b   \         P                  ! R4      p\        ^4       Uu. uF  pRRRRRRRRRR/NK  	  ppVP                  V4      pV P	                  \        V4      ^4       V P                  V^ ,          P                  R4      4       V P                  V^,          P                  R	4      4       V P                  V^,          P                  R4      4       V P                  V^,          P                  R	4      4       V P                  V^,          P                  R4      4       R# u upi )
z]
L{static.DirectoryLister} gives an alternate class for each odd and
even rows in the table.
Nhrefr   textr  r9  r8  z<tr class="odd">z<tr class="even">)r   rw   r*  _buildTableContentr!   rS   r!  r?  )r'   r  ielementsr   s   &    r(   test_oddAndEven$DirectoryListerTests.test_oddAndEvenB  s   
 ''- 1X
 RVRZL 	 
 ++H5Wq)
--.@AB
--.ABC
--.@AB
--.ABC
--.@AB
s   D,c                @   \        V P                  4       4      pVP                  4        \        P                  ! VP
                  4      pV P                  R4      pVP                  V4       V P                  VP                  P                  R4      ^ ,          R4       R# )zr
L{static.DirectoryLister} produces a MIME-type that indicates that it is
HTML, and includes its charset (UTF-8).
r   rS  s   text/html; charset=utf-8N)r
   rR   rn   r   rw   rb   rz  r6   r!   r   r   )r'   rb   r  reqs   &   r(   test_contentType%DirectoryListerTests.test_contentTypeU  su    
 &''		2mmC c--o>qA'	
r   c                   \        V P                  4       4      pVP                  4        VP                  R4      P	                  R4       VP                  R4      P	                  R4       VP                  R4      P	                  R4       VP                  R4      P	                  R4       \
        P                  ! VP                  4      pVP                  4        R	R
RRRRRR/p\        P                  ! VP                  VR7      pVP                  V4      w  rVV P                  V. 4       V P                  VRRRRRRRRRR/RRRRRRRRRR/RRRRRRRRRR/RRRRRRRRRR /.4       R!# )"zT
L{static.DirectoryLister} is able to detect mimetype and encoding of
listed files.
z	file1.txt   file1zfile2.pys   pythonzfile3.conf.gzs   conf compressedzfile4.diff.bz2s   diff compressedz.txtrO  z.pyztext/pythonz.confztext/configurationz.diffz	text/diff)contentTypesr8  r   r  r  5Br  r9  z[text/plain]6Bz[text/python]z[gzip]15Bz[text/configuration]z[bzip2]z[text/diff]N)r
   rR   rn   rr   ra   oslistdirrb   sortr   rw   _getFilesAndDirectoriesr!   )r'   rb   	directoryr  r  r  filess   &      r(   test_mimeTypeAndEncodings.DirectoryListerTests.test_mimeTypeAndEncodingsd  s   
 &

;**84

:)))4

?#../AB

#$//0BCJJtyy)	 L=)[	
 ''		M44Y?r" KDKN JDJO OEO2 	,E,M- 	
r   zNo symlink supportc                
   \        V P                  4       4      pVP                  4        VP                  R4      pVP	                  R4       VP                  VP                  R4      4       VP                  4        \        P                  ! VP                  4      p\        P                  ! VP                  4      pVP                  4        VP                  V4      w  rVV P                  V. 4       V P                  V. 4       R# )z
If on the file in the listing points to a broken symlink, it should not
be returned by L{static.DirectoryLister._getFilesAndDirectories}.
r  r  r  N)r
   rR   rn   rr   ra   linkToremover   rw   rb   r  r  r  r  r!   )r'   rb   r  r  r  r  r  s   &      r(   test_brokenSymlink'DirectoryListerTests.test_brokenSymlink  s     &

7#"TZZ()''		2JJtyy)	44Y?r"#r   c                4  a a \        S P                  4       4      pVP                  4        \        P                  ! VP
                  4      pS P                  R4      o\        P                  ! VS4      p\        VS4      pVV 3R lpVP                  V4       V# )z]
Any child resource of L{static.DirectoryLister} renders an HTTP
I{NOT FOUND} response code.
r   c                 \   < SP                  SP                  \        P                  4       R # rF   )r!   rj   r   	NOT_FOUNDr$   s   &r(   r)   >DirectoryListerTests.test_childrenNotFound.<locals>.cbRendered  s    W114>>Br   )r
   rR   rn   r   rw   rb   rz  r   ro   r   r.   )r'   rb   r  rr   r   r)   r&   s   f     @r(   test_childrenNotFound*DirectoryListerTests.test_childrenNotFound  sy    
 &''		2--$++FG<(	C 	:&r   c                    \        V P                  4       4      p\        P                  ! VP                  4      pV P                  \        V4      RVP                  : R24       V P                  \        V4      RVP                  : R24       R# )zB
L{static.DirectoryLister.__repr__} gives the path of the lister.
z<DirectoryLister of >N)r
   rR   r   rw   rb   r!   reprr   )r'   rb   r  s   &  r(   	test_reprDirectoryListerTests.test_repr  sl     &''		2f)=dii]!'LMV(<TYYM&KLr   c                   V P                  \        P                  ! ^ 4      R4       V P                  \        P                  ! ^{4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R4      R4       V P                  \        P                  ! R	4      R
4       R# )zQ
L{static.formatFileSize} format an amount of bytes into a more readable
format.
0B123Bi  4Ki͇ 8MiXI1Gl   Pc}1149GN)r!   r   formatFileSizer   s   &r(   test_formatFileSize(DirectoryListerTests.test_formatFileSize  s    
 	..q148..s3V<..t4d;..w7>..z:DA..}=wGr   r9   N)r:   r;   r<   r=   r>   rz  r  r  r  r  r  r  r  r  r  r   r   _supportsSymlinksr  r  r  r  r?   r@   rA   s   @r(   rx  rx    s     
I
MQ"4"4"4C&
8
t **,,.BC$ D$&$M
H 
Hr   rx  c                   P   a  ] tR tRt o Rt]! 4       tR tR tR t	R t
R tRtV tR	# )
LoadMimeTypesTestsi  z
Tests for the MIME type loading routine.

@cvar UNSET: A sentinel to signify that C{self.paths} has not been set by
    the mock init.
c                (    V P                   V n        R # rF   )UNSETpathsr   s   &r(   r  LoadMimeTypesTests.setUp  s    ZZ
r   c                    Wn         R# )z
A mock L{mimetypes.init} that records the value of the passed C{paths}
argument.

@param paths: The paths that will be recorded.
Nr  r'   r  s   &&r(   	_fakeInitLoadMimeTypesTests._fakeInit  s	     
r   c                    \         P                  ! V P                  R7       V P                  V P                  R4       R# )z5
By default, L{None} is passed to C{mimetypes.init}.
initNr   loadMimeTypesr  r  r  r   s   &r(   test_defaultArgumentIsNone-LoadMimeTypesTests.test_defaultArgumentIsNone  s*     	$..1TZZ.r   c                    . ROp\         P                  ! WP                  R7       V P                  V P                  V4       R# )z9
Passed MIME type files are passed to C{mimetypes.init}.
r  N)xyzr  r  s   & r(   test_extraLocationsWork*LoadMimeTypesTests.test_extraLocationsWork  s/      U8TZZ/r   c                   \        \        RR4      '       db   \        P                  ! \        P                  4      pV P                  VP                  R,          P                  \        P                  4       R# \        P                  ! \        P                  4      w  p r4WBP                  R4      ,          pV P                  V\        P                  4       R# )z*
By default, C{mimetypes.init} is called.
	signatureNr  )getattrinspectr  r   r  assertIs
parametersdefault	mimetypesr  
getargspecindex)r'   r  argsr)  defaultsdefaultInits   &     r(   test_usesGlobalInitFunction.LoadMimeTypesTests.test_usesGlobalInitFunction  s     7K..))&*>*>?IMM)..v6>>	O#*#5#5f6J6J#K D!Q"::f#56KMM+y~~6r   r  N)r:   r;   r<   r=   r>   objectr  r  r  r  r  r  r?   r@   rA   s   @r(   r  r    s1      HE /07 7r   r  c                   &   a  ] tR tRt o R tRtV tR# )StaticDeprecationTestsi  c                    ^ RI Hp V! \        R.4      4       V P                  V P                  .4      pV P                  \        V4      ^4       V P                  V^ ,          R,          R4       R# )z/
L{twisted.web.static.addSlash} is deprecated.
)addSlashr   r  z<twisted.web.static.addSlash was deprecated in Twisted 16.0.0N)twisted.web.staticr  r   flushWarningstest_addSlashDeprecatedr!   rS   )r'   r  rO   s   &  r(   r  .StaticDeprecationTests.test_addSlashDeprecated  s`     	0se$%%%t'C'C&DEX*QK	"J	
r   r9   N)r:   r;   r<   r=   r  r?   r@   rA   s   @r(   r  r    s     
 
r   r  )5r>   r   r  r  r  r  r0  rO   ior   r  unittestr   zope.interface.verifyr   twisted.internetr   r   twisted.pythonr   r   twisted.python.compatr	   twisted.python.filepathr
   twisted.python.runtimer   twisted.trial.unittestr   twisted.webr   r   r   r   twisted.web._responsesr   twisted.web.serverr   twisted.web.test._utilr   twisted.web.test.requesthelperr   r   rD   r5  r  r  r  r  r  rx  r  r  r9   r   r(   <module>r     s       	 	 
  "  . 1 & / , + + 6 6 ( 0 * 7Ch C>u)h u)psIh sIl	5( 569/ 9/x>/X >/BJ/x J/Zo
 o
dSH8 SHl27 27j
X 
r   