%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/web/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/web/test/__pycache__/test_static.cpython-312.pyc

�

Ϫ�fe
����dZddlZddlZddlZddlZddlZddlZddlZddlm	Z
ddlmZddl
mZddlmZmZddlmZmZddlmZdd	lmZdd
lmZddlmZddlmZmZm Z m!Z!dd
l"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)Gd�de�Z*Gd�de�Z+Gd�de�Z,Gd�de�Z-Gd�de�Z.Gd�de�Z/Gd�de�Z0Gd�d e�Z1Gd!�d"e�Z2Gd#�d$e�Z3Gd%�d&e�Z4y)'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��eZdZdZd�Zd�Zy)�StaticDataTestsz
    Tests for L{Data}.
    c����tjdd�}tdg��d�_t	|��}��fd�}|j|�|S)zV
        L{Data.render} returns an empty response body for a I{HEAD} request.
        �foo�bar��HEADc�\���jdj�j�d�y�N���assertEqual�join�written��ignored�request�selfs ���>/usr/lib/python3/dist-packages/twisted/web/test/test_static.py�
cbRenderedz4StaticDataTests.test_headRequest.<locals>.cbRendered.� ������S�X�X�g�o�o�6��<r )r�Datar�methodr�addCallback)r(�data�dr*r's`   @r)�test_headRequestz StaticDataTests.test_headRequest%sL����{�{�6�5�)����t�$�� ����D�'�"��	=�	
�
�
�j�!��r c��tjdd�}tdg�}d|_|j	t
|j|�y)zv
        L{Data.render} raises L{UnsupportedMethod} in response to a non-I{GET},
        non-I{HEAD} request.
        rsbarr �POSTN)rr,rr-�assertRaisesr�render)r(r/r's   r)�test_invalidMethodz"StaticDataTests.test_invalidMethod4s>��
�{�{�6�6�*����u�%�� ������+�T�[�[�'�Br N)�__name__�
__module__�__qualname__�__doc__r1r6�r r)rr s���
�Cr rc�z�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Ze
ej�d�d��Zd
�Zd�Zd�Zd�Zd�Ze
ej.�j1�dvdj3ej.���d��Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%y )!�StaticFileTestsz2
    Tests for the basic behavior of L{File}.
    c��t||�S�Nr)r(rr's   r)rzStaticFileTests._renderDs���x��)�)r c��tjd��5}tj|j	�d��}|j|jdg�ddd�|jt�d�y#1swY�%xYw)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"rE�len�r(�caughtWarnings�files   r)�test_ignoredExtTruez#StaticFileTests.test_ignoredExtTrueGsn���
$�
$�D�
1�	6�^��;�;�t�{�{�}�!�<�D����T�-�-��u�5�	6�	
����^�,�a�0�		6�	6���AA>�>Bc��tjd��5}tj|j	�d��}|j|jg�ddd�|jt�d�y#1swY�%xYw)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.
        TrArrDNrCrGrMs   r)�test_ignoredExtFalsez$StaticFileTests.test_ignoredExtFalseSsl���
$�
$�D�
1�	3�^��;�;�t�{�{�}�!�<�D����T�-�-�r�2�	3�	
����^�,�a�0�		3�	3�s�AA=�=Bc��tjd��5}tj|j	�d��}|j|jdg�ddd�|jt�d�y#1swY�%xYw)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{*}.
        TrArDrFNrCrGrMs   r)�
test_allowExtzStaticFileTests.test_allowExt_sn���
$�
$�D�
1�	6�^��;�;�t�{�{�}�$�?�D����T�-�-��u�5�	6�	
����^�,�a�0�		6�	6�rQc��tdg�}d|_t|j��}|j	d�tj|j�}|jt|j|�y)zv
        L{File.render} raises L{UnsupportedMethod} in response to a non-I{GET},
        non-I{HEAD} request.
        r r3rN)rr-rrK�
setContentrrJ�pathr4rr5)r(r'rXrOs    r)r6z"StaticFileTests.test_invalidMethodks\��
��u�%�� �������
�&��������{�{�4�9�9�%�����+�T�[�[�'�Br c�0���t�j��}|j�tj|j
�}t
dg��tj|��}�j|��}��fd�}|j|�|S)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�>���j�jd�y�N��r"�responseCoder%s ��r)r*z1StaticFileTests.test_notFound.<locals>.cbRendered��������W�1�1�3�7r �rrK�makedirsrrJrXrr�getChildForRequestrr.�r(�baserO�childr0r*r's`     @r)�
test_notFoundzStaticFileTests.test_notFoundwsv�������
�&���
�
���{�{�4�9�9�%���	�{�+���+�+�D�'�:���L�L���(��	8�	
�
�
�j�!��r c�d�t|j��}|j�tj|j
�}t
dg�}tj||�}|j|tj�|j|j
|j
�y)z�
        The C{''} child of a L{File} which corresponds to a directory in the
        filesystem is a L{DirectoryLister}.
        r N)rrKrbrrJrXrrrc�assertIsInstance�DirectoryListerr"�r(rerOr'rfs     r)�test_emptyChildzStaticFileTests.test_emptyChild�s{��
����
�&���
�
���{�{�4�9�9�%����u�%���+�+�D�'�:�����e�V�%;�%;�<�������T�Y�Y�/r c�T�t|j��j�}|j�|j	d�jd�j
�tj|j�}tdg�}tj||�}|j|tj�tj |j�}|j#|j|�|j%|�}|j|t&�y)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)rrK�
asTextModerbrf�open�closerrJrXrrrcrirjr�nativeStringr"r5�bytes)r(�textBase�textFiler'rf�
nativePath�responses       r)�test_emptyChildUnicodeParentz,StaticFileTests.test_emptyChildUnicodeParent�s����D�K�K�M�*�5�5�7���������{�#�(�(��-�3�3�5��;�;�x�}�}�-����u�%���+�+�H�g�>�����e�V�%;�%;�<��(�(����7�
�������Z�0��<�<��(�����h��.r c�0���t�j��}|j�tj|j
�}t
dg��tj|��}�j|��}��fd�}|j|�|S)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�>���j�jd�yr\r^r%s ��r)r*zBStaticFileTests.test_securityViolationNotFound.<locals>.cbRendered�r`r rards`     @r)�test_securityViolationNotFoundz.StaticFileTests.test_securityViolationNotFound�sv�������
�&���
�
���{�{�4�9�9�%����w�'���+�+�D�'�:���L�L���(��	8�	
�
�
�j�!��r z(Cannot remove read permission on Windowsc�`���t�j��}|jd��j|jd�|j	d�tj|j�}tdg���j|��}��fd�}|j|�|S)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�rc�>���j�jd�y)Ni�r^r%s ��r)r*z:StaticFileTests.test_forbiddenResource.<locals>.cbRendered�r`r )rrKrW�
addCleanup�chmodrrJrXrrr.)r(rerOr0r*r's`    @r)�test_forbiddenResourcez&StaticFileTests.test_forbiddenResource�s��������
�&�����������
�
�E�*�	
�
�
�1�
��{�{�4�9�9�%����u�%���L�L��w�'��	8�	
�
�
�j�!��r c�v����j�}t|t�r|jd�}t	|�}|j�t
j|j�}tdg��tj|��}�j|��}��fd�}|j|�|S)z�
        A request whose path cannot be decoded as UTF-8 receives a not
        found response, and the failure is logged.
        �ascii��c����j�jd��jt�jt��d�y)Nr]rC)r"r_rL�flushLoggedErrors�UnicodeDecodeErrorr%s ��r)r*z8StaticFileTests.test_undecodablePath.<locals>.cbRendered�s:������W�1�1�3�7����S��!7�!7�8J�!K�L�a�Pr )rK�
isinstancers�decoderrbrrJrXrrrcrr.)r(rXrerOrfr0r*r's`      @r)�test_undecodablePathz$StaticFileTests.test_undecodablePath�s����
�{�{�}���d�E�"��;�;�w�'�D���~���
�
���{�{�4�9�9�%����y�)���+�+�D�'�:���L�L���(��	Q�	
�
�
�j�!��r c�~�|jtjd�jtj
�y)zN
        L{File.forbidden} defaults to L{resource.ForbiddenResource}.
        �.N)rirrJ�	forbiddenr�ForbiddenResource�r(s r)�test_forbiddenResource_defaultz.StaticFileTests.test_forbiddenResource_default�s)��	
���f�k�k�$�/�9�9�8�;U�;U�Vr c�b���t|j��}|jd�d�d�}G�fd�dtj��G�fd�dt
j�}||j�}||_tdg�}|j|�}|j�|�y)	z�
        The resource rendered for forbidden requests is stored as a class
        member so that users can customize it.
        r scustom-forbidden-responsec�6�ttjd��)Nr)�OSError�errno�EACCESr;r r)�failingOpenForReadingzOStaticFileTests.test_forbiddenResource_customize.<locals>.failingOpenForReadings���%�,�,��+�+r c���eZdZ�fd�Zy)�QStaticFileTests.test_forbiddenResource_customize.<locals>.CustomForbiddenResourcec����Sr?r;�r(r'�markerResponses  �r)r5zXStaticFileTests.test_forbiddenResource_customize.<locals>.CustomForbiddenResource.render	�	���%�%r N�r7r8r9r5�r�s�r)�CustomForbiddenResourcer�����
&r r�c���eZdZW��Zy)�JStaticFileTests.test_forbiddenResource_customize.<locals>.CustomStaticFileN)r7r8r9r�)r�s�r)�CustomStaticFiler�s���/�1�Ir r�N)rrKrWr�ResourcerrJrX�openForReadingrr5r")	r(rer�r��fileResourcer'�resultr�r�s	       @@r)� test_forbiddenResource_customizez0StaticFileTests.test_forbiddenResource_customize�s����
����
�&�������5��	,�	&�h�&7�&7�	&�	2�v�{�{�	2�(��	�	�2��&;��#���u�%���$�$�W�-�������0r c����t�j��}|j�|jd�j	d�tj|j�}dg|_tdg��tj|��}�j|��}��fd�}|j|�|S)a
        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����jdj�j�d��j�jj	d�dd�y�Nr r��content-lengthr�3�r"r#r$�responseHeaders�
getRawHeadersr%s ��r)r*z3StaticFileTests.test_indexNames.<locals>.cbRendered)�J������S�X�X�g�o�o�6��?�����'�'�5�5�6G�H��K�T�
r )rrKrbrfrWrrJrX�
indexNamesrrrcrr.rds`     @r)�test_indexNameszStaticFileTests.test_indexNamess��������
�&���
�
���
�
�9��(�(��0��{�{�4�9�9�%��$�+�����u�%���+�+�D�'�:���L�L���(��	�	
�
�
�j�!��r c�p���t�j��}|j�|jd�j	d�tj|j�}tdg��tj|��}�j|��}��fd�}|j|�|S)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����jdj�j�d��j�jj	d�dd�yr�r�r%s ��r)r*z3StaticFileTests.test_staticFile.<locals>.cbRenderedBr�r �
rrKrbrfrWrrJrXrrrcrr.rds`     @r)�test_staticFilezStaticFileTests.test_staticFile2s��������
�&���
�
���
�
�9��(�(��0��{�{�4�9�9�%���
�|�,���+�+�D�'�:���L�L���(��	�	
�
�
�j�!��r )�utf-8�mcbsz>Cannot write unicode filenames with file system encoding of {}c�����d}d�t�j��}|j�|j|�j	��tj|j�}t|jd�g��tj|��}�j|��}���fd�}|j|�|S)zx
        A request for a existing unicode file path encoded as UTF-8
        returns the contents of that file.
        uῆscontentr�c
�����jdj�j����j�jj	d�dtt
t�����y)Nr r�r)r"r#r$r�r�r
�strrL)r&�contentr'r(s ���r)r*zBStaticFileTests.test_staticFileUnicodeFileName.<locals>.cbRenderedbsY������S�X�X�g�o�o�6��@�����'�'�5�5�6G�H��K��c�#�g�,�/�0�
r )rrKrbrfrWrrJrXr�encoderrcrr.)	r(�namererOrfr0r*r�r's	`      @@r)�test_staticFileUnicodeFileNamez.StaticFileTests.test_staticFileUnicodeFileNameKs����=��������
�&���
�
���
�
�4��#�#�G�,��{�{�4�9�9�%������G� 4�5�6���+�+�D�'�:���L�L���(��	�	
�
�
�j�!��r c��tj|j��}tdg�}|j	d|�}|j||j�y)z�
        A L{static.File} created for a directory which does not exist should
        return childNotFound from L{static.File.getChild}.
        r�N)rrJrKr�getChildr"�
childNotFound)r(�
staticFiler'rfs    r)�test_staticFileDeletedGetChildz.StaticFileTests.test_staticFileDeletedGetChildlsL��
�[�[�����/�
��
�|�,���#�#�J��8������
� 8� 8�9r c������tj�j��}tdg��tdg���j	|����j	|j
��}����fd�}|j
|�|S)z{
        A L{static.File} created for a file which does not exist should render
        its C{childNotFound} page.
        r�c�8�����fd�}�j|��S)Nc����jdj�j�dj�j��yrr!)r&r'�request2r(s ���r)r*zUStaticFileTests.test_staticFileDeletedRender.<locals>.cbRendered2.<locals>.cbRendered�s/���� � ����'�/�/�!:�C�H�H�X�EU�EU�<V�Wr )r.)r&r*r0r'r�r(s  ����r)�cbRendered2zAStaticFileTests.test_staticFileDeletedRender.<locals>.cbRendered2�s���
X�
�M�M�*�%��Hr )rrJrKrrr�r.)r(r��d2r�r0r'r�s`   @@@r)�test_staticFileDeletedRenderz,StaticFileTests.test_staticFileDeletedRendervso���
�[�[�����/�
��
�|�,�����-���L�L��W�-��
�\�\�*�2�2�H�
=��	�	���{�#��	r c�r���t|j��}|jd�d�G�fd�dtj��G�fd�dt
j�}||j�}tdg�}|jd|�}|j|�}|j�|�y)	zs
        The resource rendered for child not found requests can be customize
        using a class member.
        r scustom-child-not-found-responsec���eZdZ�fd�Zy)�YStaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomChildNotFoundResourcec����Sr?r;r�s  �r)r5z`StaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomChildNotFoundResource.render�r�r Nr�r�s�r)�CustomChildNotFoundResourcer��r�r r�c���eZdZW��Zy)�NStaticFileTests.test_getChildChildNotFound_customize.<locals>.CustomStaticFileN)r7r8r9r�)r�s�r)r�r��s���7�9�Mr r�sno-child.txtN)rrKrWrr�rrJrXrr�r5r")	r(rer�r�r'rfr�r�r�s	       @@r)�$test_getChildChildNotFound_customizez4StaticFileTests.test_getChildChildNotFound_customize�s����
����
�&�������;��	&�(�*;�*;�	&�	:�v�{�{�	:�(��	�	�2����0�1���%�%�o�w�?�����g�&�������0r c����t�j��}|jd�tj|j
�}t
dg��d�_t|��}��fd�}|j|�|S)zd
        L{static.File.render} returns an empty response body for I{HEAD}
        requests.
        rr rc�\���jdj�j�d�yrr!r%s ��r)r*z4StaticFileTests.test_headRequest.<locals>.cbRendered�r+r )
rrKrWrrJrXrr-rr.)r(rXrOr0r*r's`    @r)r1z StaticFileTests.test_headRequest�sj���
����
�&��������{�{�4�9�9�%����u�%�� ����D�'�"��	=�	
�
�
�j�!��r c����t�j��}|j�|jd�j	d�tj|j�}dtji|_
tdg��tj|��}�j|��}��fd�}|j|�|S)a!
        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�sTfrom twisted.web.static import Data
resource = Data(b'dynamic world', 'text/plain')
�.barr�c����jdj�j�d��j�jj	d�dd�y)Nr s
dynamic worldr�rs13r�r%s ��r)r*z3StaticFileTests.test_processors.<locals>.cbRendered�sK������S�X�X�g�o�o�6�8H�I�����'�'�5�5�6G�H��K�U�
r )rrKrbrfrWrrJrXr�ResourceScript�
processorsrrrcrr.rds`     @r)�test_processorszStaticFileTests.test_processors�s��������
�&���
�
���
�
�9��(�(�
A�	
�
�{�{�4�9�9�%��!�6�#8�#8�9����
�|�,���+�+�D�'�:���L�L���(��	�	
�
�
�j�!��r c�P�tjd�}|j|jg�|j	d�|j	d�|j|jddg�tjdd��}|j|jddg�y)z�
        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�)r��.bazrDr�N)rrJr"rE�	ignoreExt)r(rOs  r)�test_ignoreExtzStaticFileTests.test_ignoreExt�s���
�{�{�4� ������)�)�2�.����v�����v������)�)�F�F�+;�<��{�{�4�-=�>������)�)�F�F�+;�<r c����t�j��}|j�|jd�j	d�|jd�j	d�tj|jd��}tdg��tj|��}�j|��}��fd�}|j|�|S)	a
        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�zfoo.quuxrZ)r�rDrc�\���jdj�j�d�y)Nr r�r!r%s ��r)r*zAStaticFileTests.test_ignoredExtensionsIgnored.<locals>.cbRendered�s ������S�X�X�g�o�o�6��?r r�rds`     @r)�test_ignoredExtensionsIgnoredz-StaticFileTests.test_ignoredExtensionsIgnored�s��������
�&���
�
���
�
�9��(�(��0��
�
�:��)�)�)�4��{�{�4�9�9�)�<����x�(���+�+�D�'�:���L�L���(��	@�	
�
�
�j�!��r c��t|j��}|j�|jd�j�t	j
|j�}tdg�}d|_tj||�}|j|j||��|j|jt�|j|j j#d�dg�y)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}.
        �foldersfoldershttp://dummy/folder#baz?foo=barslocations http://dummy/folder/#baz?foo=barN)rrKrbrfrrJrXr�urirrc�successResultOfrr"r_rr�r�rks     r)�+test_directoryWithoutTrailingSlashRedirectsz;StaticFileTests.test_directoryWithoutTrailingSlashRedirects�s���
����
�&���
�
���
�
�8��%�%�'��{�{�4�9�9�%���	�{�+��8����+�+�D�'�:�����T�\�\�%��9�:�����-�-�u�5�����#�#�1�1�+�>�
0�1�	
r c����t��t|j��}|j�t	j
|j�}�fd�|_�|fS)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����Sr?r;)�fakeFiles�r)�<lambda>z;StaticFileTests._makeFilePathWithStringIO.<locals>.<lambda>s���H�r )�StringIOrrK�touchrrJrXrp)r(rXrOr�s   @r)�_makeFilePathWithStringIOz)StaticFileTests._makeFilePathWithStringIOsH����:������
�&���
�
���{�{�4�9�9�%��$��	���~�r c��|j�\}}tdg�}d|_|jt	||��|jdj
|j�d�|j|j�y)zm
        A HEAD request opens the file, gets the size, and then closes it after
        the request.
        rrr N)
r�rr-r�rr"r#r$�
assertTrue�closed�r(r�rOr's    r)�test_HEADClosesFilez#StaticFileTests.test_HEADClosesFilesk��
�7�7�9���$���t�$�� ������W�T�7�3�4�������'�/�/�2�C�8�������(r c�"�|j�\}}tdg�}d|_d�|_|j	t||��|j
dj|j�d�|j|j�y)zQ
        A GET request that is cached closes the file after the request.
        rsGETc�"�tjSr?)r�CACHED)�_s r)r�z>StaticFileTests.test_cachedRequestClosesFile.<locals>.<lambda>1s
��D�K�K�r r N)r�rr-�setLastModifiedr�rr"r#r$r�r�r�s    r)�test_cachedRequestClosesFilez,StaticFileTests.test_cachedRequestClosesFile)ss���7�7�9���$���t�$�����"7������W�T�7�3�4�������'�/�/�2�C�8�������(r N)&r7r8r9r:rrPrSrUr6rgrlrxr{rr�	isWindowsr�r�r�r�r�r��sys�getfilesystemencoding�lower�formatr�r�r�r�r1r�r�r�r�r�r�r�r;r r)r=r=?s���*�
1�
1�
1�
C��*0�/�.�*��H��� �"L�M��N��.�0W�1�6�6�2�!��!�!�#�)�)�+�3D�D�	��f�.�S�.�.�0�1��
��
�8:��*1�0�$�<=��0
�*
�
)�)r r=c��eZdZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�StaticMakeProducerTestsz)
    Tests for L{File.makeProducer}.
    Nc��t|j��}|j|�tj|j��}||_||_|S)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.
        )rrKrWrrJ�_asBytesPath�encoding�type)r(r�rr�fileNamers      r)�makeResourceWithContentz/StaticMakeProducerTests.makeResourceWithContent<sM���D�K�K�M�*�����G�$��;�;�x�4�4�6�7��$�����
��r c��i}|jj�D];\}}|j�jd�s�&|d||j�<�=|S)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-'.
        scontent-r)r��getAllRawHeadersr�
startswith)r(r'�contentHeaders�k�vs     r)r
z&StaticMakeProducerTests.contentHeadersJs[�����+�+�<�<�>�	1�D�A�q��w�w�y�#�#�K�0�,-�a�D��q�w�w�y�)�	1��r c���|jd�}tg�}|j�5}|j||�}|j	|t
j�ddd�y#1swYyxYw)zp
        makeProducer when no Range header is set returns an instance of
        NoRangeStaticProducer.
        r N)r	rr��makeProducerrir�NoRangeStaticProducer)r(rr'rO�producers     r)�,test_noRangeHeaderGivesNoRangeStaticProducerzDStaticMakeProducerTests.test_noRangeHeaderGivesNoRangeStaticProducerWsq��
�/�/��4���r�"��
$�X�
$�
$�
&�	J�$�,�x�,�,�W�d�;�H��!�!�(�F�,H�,H�I�	J�	J�	J�s�4A+�+A4c��|jd�}tg�}|j�5}|j||�|j	t
j|j�ddd�y#1swYyxYw)zp
        makeProducer when no Range header is set sets the responseCode on the
        request to 'OK'.
        r N)r	rr�rr"r�OKr_)r(rr'rOs    r)�test_noRangeHeaderSets200OKz3StaticMakeProducerTests.test_noRangeHeaderSets200OKbso��
�/�/��4���r�"��
$�X�
$�
$�
&�	<�$�!�H�!�!�'�4�0����T�W�W�g�&:�&:�;�	<�	<�	<�s�>A5�5A>c�<�d}d}d}|jd|z||��}tg�}|j�5}|j||�|j	t|�d|fzt|�d�|j
|��ddd�y#1swYyxYw)	zo
        makeProducer when no Range header is set sets the Content-* headers
        for the response.
        �{�
text/plain�gzip�a�rr�%d)�content-typer��content-encodingN)r	rr�rr"r
r
)r(�length�contentType�contentEncodingrr'rOs       r)�$test_noRangeHeaderSetsContentHeadersz<StaticMakeProducerTests.test_noRangeHeaderSetsContentHeadersms���
��"�� ���/�/��6�M��o�0�
���r�"��
$�X�
$�
$�
&�		�$�!�H�!�!�'�4�0����%2�;�%?�',��y�'8�)6��)G��
�#�#�G�,�

�		�		�		�s�AB�Bc�&�tg�}|jjdd�|jd�}|j�5}|j
||�}|j
|tj�ddd�y#1swYyxYw)z�
        makeProducer when the Range header requests a single byte range
        returns an instance of SingleRangeStaticProducer.
        �range�	bytes=1-3�abcdefN�	r�requestHeaders�addRawHeaderr	r�rrir�SingleRangeStaticProducer�r(r'rrOrs     r)�.test_singleRangeGivesSingleRangeStaticProducerzFStaticMakeProducerTests.test_singleRangeGivesSingleRangeStaticProducer�s���
�r�"�����+�+�H�l�C��/�/�	�:��
$�X�
$�
$�
&�	N�$�,�x�,�,�W�d�;�H��!�!�(�F�,L�,L�M�	N�	N�	N���
4B�Bc�:�tg�}|jjdd�|jd�}|j�5}|j
||�|j
tj|j�ddd�y#1swYyxYw)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�
rr*r+r	r�rr"r�PARTIAL_CONTENTr_�r(r'rrOs    r)�%test_singleRangeSets206PartialContentz=StaticMakeProducerTests.test_singleRangeSets206PartialContent�s���
�r�"�����+�+�H�l�C��/�/�	�:��
$�X�
$�
$�
&�	I�$�!�H�!�!�'�4�0����T�1�1�7�3G�3G�H�	I�	I�	I���
>B�Bc�d�tg�}|jjdd�d}d}|jd||��}|j�5}|j
||�|j
t|�t|�ddd	�|j|��d
d
d
�y
#1swYy
xYw)��
        makeProducer when the Range header requests a single, satisfiable byte
        range sets the Content-* headers appropriately.
        r&r'rrr(rsbytes 1-3/6r�)rr �
content-ranger�N)	rr*r+r	r�rr"r
r
)r(r'r"r#rrOs      r)�"test_singleRangeSetsContentHeadersz:StaticMakeProducerTests.test_singleRangeSetsContentHeaders�s���
�r�"�����+�+�H�l�C�"�� ���/�/��K�/�0�
��%�X�
$�
$�
&�
	�$�!�H�!�!�'�4�0����%2�;�%?�)6��)G�&4�'+�	��#�#�G�,�
�
	�
	�
	�s
�AB&�&B/c�&�tg�}|jjdd�|jd�}|j�5}|j
||�}|j
|tj�ddd�y#1swYyxYw)z�
        makeProducer still returns an instance of L{SingleRangeStaticProducer}
        when the Range header requests a single unsatisfiable byte range.
        r&�
bytes=4-10�abcNr)r-s     r)�=test_singleUnsatisfiableRangeReturnsSingleRangeStaticProducerzUStaticMakeProducerTests.test_singleUnsatisfiableRangeReturnsSingleRangeStaticProducer�s���
�r�"�����+�+�H�m�D��/�/��7��
$�X�
$�
$�
&�	N�$�,�x�,�,�W�d�;�H��!�!�(�F�,L�,L�M�	N�	N�	N�r/c�:�tg�}|jjdd�|jd�}|j�5}|j
||�|j
tj|j�ddd�y#1swYyxYw)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&r;r<N�
rr*r+r	r�rr"r�REQUESTED_RANGE_NOT_SATISFIABLEr_r3s    r)�?test_singleUnsatisfiableRangeSets416ReqestedRangeNotSatisfiablezWStaticMakeProducerTests.test_singleUnsatisfiableRangeSets416ReqestedRangeNotSatisfiable�s����r�"�����+�+�H�m�D��/�/��7��
$�X�
$�
$�
&�	Y�$�!�H�!�!�'�4�0����T�A�A�7�CW�CW�X�	Y�	Y�	Y�r5c�8�tg�}|jjdd�d}|jd|��}|j�5}|j
||�|j
dddd	�|j|��d
d
d
�y
#1swYy
xYw)z�
        makeProducer when the Range header requests a single, unsatisfiable
        byte range sets the Content-* headers appropriately.
        r&r;rr<�r�
text/plain�0�	bytes */3�rr�r8N�rr*r+r	r�rr"r
�r(r'r"rrOs     r)�/test_singleUnsatisfiableRangeSetsContentHeaderszGStaticMakeProducerTests.test_singleUnsatisfiableRangeSetsContentHeaders�s���
�r�"�����+�+�H�m�D�"���/�/��[�/�I��
$�X�
$�
$�
&�		�$�!�H�!�!�'�4�0����%2�'+�&2��
�#�#�G�,�

�		�		�		���9B�Bc�8�tg�}|jjdd�d}|jd|��}|j�5}|j
||�|j
dddd	�|j|��d
d
d
�y
#1swYy
xYw)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-10rr<rCrD�1sbytes 2-2/3rGNrHrIs     r)�6test_singlePartiallyOverlappingRangeSetsContentHeaderszNStaticMakeProducerTests.test_singlePartiallyOverlappingRangeSetsContentHeaders�s���
�r�"�����+�+�H�m�D�"���/�/��[�/�I��
$�X�
$�
$�
&�		�$�!�H�!�!�'�4�0����%2�'+�&4��
�#�#�G�,�

�		�		�		�rKc�&�tg�}|jjdd�|jd�}|j�5}|j
||�}|j
|tj�ddd�y#1swYyxYw)z�
        makeProducer when the Range header requests a single byte range
        returns an instance of MultipleRangeStaticProducer.
        r&�
bytes=1-3,5-6r(N�	rr*r+r	r�rrir�MultipleRangeStaticProducerr-s     r)�2test_multipleRangeGivesMultipleRangeStaticProducerzJStaticMakeProducerTests.test_multipleRangeGivesMultipleRangeStaticProducer�s���
�r�"�����+�+�H�6F�G��/�/�	�:��
$�X�
$�
$�
&�	P�$�,�x�,�,�W�d�;�H��!�!�(�F�,N�,N�O�	P�	P�	P�r/c�:�tg�}|jjdd�|jd�}|j�5}|j
||�|j
tj|j�ddd�y#1swYyxYw)z�
        makeProducer when the Range header requests a multiple satisfiable
        byte ranges sets the response code on the request to 'Partial
        Content'.
        r&rPr(Nr1r3s    r)�'test_multipleRangeSets206PartialContentz?StaticMakeProducerTests.test_multipleRangeSets206PartialContents����r�"�����+�+�H�6F�G��/�/�	�:��
$�X�
$�
$�
&�	I�$�!�H�!�!�'�4�0����T�1�1�7�3G�3G�H�	I�	I�	I�r5c�|�tg�}|jjdd�|jdd��}|j�5}|j
||�}|j
|�}|jddht|j���d}|jD]\}}}	|t|�z
}�|jd	|fz|d�|jd|�|d}
|jd
tjd|
��|j!d|�d
d
d
�y
#1swYy
xYw)
r7r&rPsabcdefghijklr)rr�r�rNs(multipart/byteranges; boundary="[^"]*"\Zr )rr*r+r	r�rr
r"�set�keys�	rangeInforL�assertIn�assertNotIdentical�re�match�assertNotIn)r(r'rrOrr
�expectedLength�boundary�offset�sizer"s           r)�#test_mutipleRangeSetsContentHeadersz;StaticMakeProducerTests.test_mutipleRangeSetsContentHeaderssL��
�r�"�����+�+�H�6F�G��/�/��&�/�Q��
$�X�
$�
$�
&�	B�$�,�x�,�,�W�d�;�H�!�0�0��9�N����"�O�4�c�.�:M�:M�:O�6P�
��N�*2�*<�*<�
0�&��&�$��#�h�-�/��
0������)�)�>�:K�+L�
�

�M�M�/�>�:�(��9�K��#�#�����E�{�S�
�
���0�.�A�3	B�	B�	B�s
�CD2�2D;c�&�tg�}|jjdd�|jd�}|j�5}|j
||�}|j
|tj�ddd�y#1swYyxYw)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-20r<NrQr-s     r)�Btest_multipleUnsatisfiableRangesReturnsMultipleRangeStaticProducerzZStaticMakeProducerTests.test_multipleUnsatisfiableRangesReturnsMultipleRangeStaticProducer1s����r�"�����+�+�H�6J�K��/�/��7��
$�X�
$�
$�
&�	P�$�,�x�,�,�W�d�;�H��!�!�(�F�,N�,N�O�	P�	P�	P�r/c�:�tg�}|jjdd�|jd�}|j�5}|j
||�|j
tj|j�ddd�y#1swYyxYw)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&rfr<Nr?r3s    r)�Btest_multipleUnsatisfiableRangesSets416ReqestedRangeNotSatisfiablezZStaticMakeProducerTests.test_multipleUnsatisfiableRangesSets416ReqestedRangeNotSatisfiable>s����r�"�����+�+�H�6J�K��/�/��7��
$�X�
$�
$�
&�	Y�$�!�H�!�!�'�4�0����T�A�A�7�CW�CW�X�	Y�	Y�	Y�r5c�p�tg�}|jjdd�d}|jjdd�|jd|��}|j�5}|j
||�|j
ddd	d
�|j|��ddd�y#1swYyxYw)z�
        makeProducer when the Range header requests multiple ranges, none of
        which are satisfiable, sets the Content-* headers appropriately.
        r&r;rrfr<rCrErFrD)r�r8rNrHrIs     r)�1test_multipleUnsatisfiableRangeSetsContentHeaderszIStaticMakeProducerTests.test_multipleUnsatisfiableRangeSetsContentHeadersKs���
�r�"�����+�+�H�m�D�"�����+�+�H�6J�K��/�/��[�/�I��
$�X�
$�
$�
&�		�$�!�H�!�!�'�4�0����'+�&2�%2��
�#�#�G�,�

�		�		�		�s�*9B,�,B5c�:�tg�}|jjdd�|jd�}|j�5}|j
||�|j
tj|j�ddd�y#1swYyxYw)z�
        makeProducer when the Range header requests multiple ranges, at least
        one of which matches, sets the response code to 'Partial Content'.
        r&sbytes=1-3,100-200r(Nr1r3s    r)� test_oneSatisfiableRangeIsEnoughz8StaticMakeProducerTests.test_oneSatisfiableRangeIsEnough`s���
�r�"�����+�+�H�6J�K��/�/�	�:��
$�X�
$�
$�
&�	I�$�!�H�!�!�'�4�0����T�1�1�7�3G�3G�H�	I�	I�	I�r5)NN)r7r8r9r:r	r
rrr$r.r4r9r=rArJrNrSrUrdrgrirkrmr;r r)rr7sr�����	J�	<��.
N�
I��0
N�Y��(�(
P�I�!B�FP�Y��*
Ir rc��eZdZdZd�Zd�Zy)�StaticProducerTestsz3
    Tests for the abstract L{StaticProducer}.
    c��t�}tjd|�}|j�|j	|j
�y)zu
        L{StaticProducer.stopProducing} closes the file object the producer is
        producing data from.
        N)r�r�StaticProducer�
stopProducingr�r��r(�
fileObjectrs   r)�test_stopProducingClosesFilez0StaticProducerTests.test_stopProducingClosesFilers;��
�Z�
��(�(��z�:����� ����
�)�)�*r c��t�}tjtg�|�}|j	�|jd|j�y)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�rrqrrr�assertIdenticalr'rss   r)�#test_stopProducingSetsRequestToNonez7StaticProducerTests.test_stopProducingSetsRequestToNone|sD���Z�
��(�(��b�)9�:�F����� ����T�8�#3�#3�4r N)r7r8r9r:rurxr;r r)roroms���+�	5r roc�(�eZdZdZd�Zd�Zd�Zd�Zy)�NoRangeStaticProducerTestsz-
    Tests for L{NoRangeStaticProducer}.
    c�`�ttjtjdd��y)zG
        L{NoRangeStaticProducer} implements L{IPullProducer}.
        N)rr�
IPullProducerrrr�s r)�test_implementsIPullProducerz7NoRangeStaticProducerTests.test_implementsIPullProducer�s"��	�Z�-�-�v�/K�/K�D�RV�/W�Xr c���tg�}d}tj|t|��}|j	�|j|dj
|j��y)zs
        L{NoRangeStaticProducer.resumeProducing} writes content from the
        resource to the request.
        r(r N)rrrr��startr"r#r$�r(r'r�rs    r)�#test_resumeProducingProducesContentz>NoRangeStaticProducerTests.test_resumeProducingProducesContent�sS��
�r�"�����/�/���'�9J�K��	��������#�(�(�7�?�?�";�<r c�"�tg�}tjj}dd|zdzz}t	j
|t
|��}|j�|d|||d|z|d|zdg}|j||j�y)z�
        L{NoRangeStaticProducer.start} writes at most
        C{abstract.FileDescriptor.bufferSize} bytes of content from the
        resource to the request at once.
        r�rCrN)
rr�FileDescriptor�
bufferSizerrr�rr"r$�r(r'r�r�r�expecteds      r)�!test_resumeProducingBuffersOutputz<NoRangeStaticProducerTests.test_resumeProducingBuffersOutput�s����r�"���,�,�7�7�
��!�j�.�1�,�-���/�/���'�9J�K��	�����A�j�!��J��Z��0��A�
�N�$�%�
��
	
����7�?�?�3r c��tg�}|j�}g}|j|j�t	j
|t
d��}|j�|jdg|�y)z�
        L{NoRangeStaticProducer.resumeProducing} calls finish() on the request
        after it is done producing content.
        r(N)	r�notifyFinishr.�appendrrr�rr"�r(r'�finishDeferred�callbackListrs     r)�test_finishCalledWhenDonez4NoRangeStaticProducerTests.test_finishCalledWhenDone�sj��
�r�"�� �-�-�/�����"�"�<�#6�#6�7��/�/���)�9L�M��	�������$���.r N�r7r8r9r:r}r�r�r�r;r r)rzrz�s���Y�=�4�(
/r rzc�(�eZdZdZd�Zd�Zd�Zd�Zy)�SingleRangeStaticProducerTestsz1
    Tests for L{SingleRangeStaticProducer}.
    c	�d�ttjtjdddd��y)zK
        L{SingleRangeStaticProducer} implements L{IPullProducer}.
        N)rrr|rr,r�s r)r}z;SingleRangeStaticProducerTests.test_implementsIPullProducer�s)��	��$�$��,�,�T�4��t�D�	
r c���tg�}d}tj|t|�dd�}|j	�|j|dddj
|j��y)z�
        L{SingleRangeStaticProducer.resumeProducing} writes the given amount
        of content, starting at the given offset, from the resource to the
        request.
        r(rC��r N)rrr,r�rr"r#r$r�s    r)r�zBSingleRangeStaticProducerTests.test_resumeProducingProducesContent�s_���r�"�����3�3�G�X�g�=N�PQ�ST�U��	���������1��s�x�x����'@�Ar c��tg�}tjj}d|z}t	j
|t
|�d|dz�}|j�|d|dz||dz|dzg}|j||j�y)z�
        L{SingleRangeStaticProducer.start} writes at most
        C{abstract.FileDescriptor.bufferSize} bytes of content from the
        resource to the request at once.
        r<rC�
�N)
rrr�r�rr,r�rr"r$r�s      r)r�z@SingleRangeStaticProducerTests.test_resumeProducingBuffersOutput�s����r�"���,�,�7�7�
��:�%���3�3��X�g�&��:��?�
��
	�����A�
�Q��'��J��N�Z�"�_�5�
��	
����7�?�?�3r c��tg�}|j�}g}|j|j�t	j
|t
d�dd�}|j�|jdg|�y)z�
        L{SingleRangeStaticProducer.resumeProducing} calls finish() on the
        request after it is done producing content.
        r(rCN)	rr�r.r�rr,r�rr"r�s     r)r�z8SingleRangeStaticProducerTests.test_finishCalledWhenDone�sp��
�r�"�� �-�-�/�����"�"�<�#6�#6�7��3�3�G�X�i�=P�RS�UV�W��	�������$���.r Nr�r;r r)r�r��s���
�B�4�*
/r r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)� MultipleRangeStaticProducerTestsz3
    Tests for L{MultipleRangeStaticProducer}.
    c�b�ttjtjddd��y)zM
        L{MultipleRangeStaticProducer} implements L{IPullProducer}.
        N)rrr|rrRr�s r)r}z=MultipleRangeStaticProducerTests.test_implementsIPullProducer
s'��	��$�$��.�.�t�T�4�@�	
r c���tg�}d}tj|t|�ddg�}|j	�|jddj
|j��y)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()rMrCr�)�2rWrCs1bcd2fr N)rrrRr�rr"r#r$r�s    r)r�zDMultipleRangeStaticProducerTests.test_resumeProducingProducesContents]���r�"�����5�5��X�g�&��|�(D�
��
	��������C�H�H�W�_�_�$=�>r c��tg�}d}tj|t|�gd��}d|_|j�d|ddzdz|dd	z|d	d
dzg}|j
||j�y)
a�
        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.
        s01234567890123456789))rrr�)�brWr�)�crrr�rrr�r�rWr��r�N)rrrRr�r�rr"r$)r(r'r�rr�s     r)r�zBMultipleRangeStaticProducerTests.test_resumeProducingBuffersOutput#s����r�"��#���5�5��X�g�&�(S�
��!���	�����7�1�Q�<��$�&���2��6��B�r�N�T�!�
��	
����7�?�?�3r c��tg�}|j�}g}|j|j�t	j
|t
d�dg�}|j�|jdg|�y)z�
        L{MultipleRangeStaticProducer.resumeProducing} calls finish() on the
        request after it is done producing content.
        r()r rCr�N)	rr�r.r�rrRr�rr"r�s     r)r�z:MultipleRangeStaticProducerTests.test_finishCalledWhenDone@sq��
�r�"�� �-�-�/�����"�"�<�#6�#6�7��5�5��X�i�(�;�-�
��
	�������$���.r Nr�r;r r)r�r�s���
�?� 4�:/r r�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zy)�
RangeTestsa�
    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���t|j��}d|_|j|j�|j	�|_t
j|j
j�|_	d|j_
tdg�|_|j
j|j_
g|_tj |jj"�y)a
        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@�u�E�7���a0y0S�﬷��M6k{�	мkY�I��oZ�b�k�&�%݂q/AY�rCr N)rrK�payloadrWrprOrrJr�r�isLeafrr'r��catcherr	�addObserverr�)r(rXs  r)�setUpzRangeTests.setUpcs�������
�&��
*�	
��	
������%��I�I�K��	����D�I�I�N�N�3��
� ��
�
��#�S�E�*����9�9�>�>��������������+�+�,r c��|jj�tj|jj
�y)zB
        Clean up the resource file and the log observer.
        N)rOrqr	�removeObserverr�r�r�s r)�tearDownzRangeTests.tearDowns*��	
�	�	�������4�<�<�.�.�/r c��|jj�}|j|dd|�|j|jgd|���y)zU
        Asserts that a given log message occurred with an expected message.
        �messagerzAn additional log occurred: N)r��popr")r(r��logItems   r)�
_assertLoggedzRangeTests._assertLogged�sN���,�,�"�"�$�������+�A�.��9�������r�-I�'��+U�Vr c�r�|jj}|jt|d�|jt|d�|jt|d�|jt|d�|jt|d�|jt|d�|jt|d�y)	zw
        L{File._parseRangeHeader} raises L{ValueError} when passed
        syntactically invalid byte ranges.
        sbytessunknown=1-2sbytes=3sbytes=-s
bytes=foo-s
bytes=-foos	bytes=5-4N)r�_parseRangeHeaderr4�
ValueError)r(�fs  r)�test_invalidRangeszRangeTests.test_invalidRanges�s���

�M�M�+�+��	
���*�a��2�	
���*�a��8�	
���*�a��4�	
���*�a��4�	
���*�a��7�	
���*�a��7�	
���*�a��6r c�\�|j|jjd�dg�y)z�
        A single bytes range without an explicit stop position is parsed into a
        two-tuple giving the start position and L{None}.
        sbytes=0-)rNN�r"rr�r�s r)�test_rangeMissingStopz RangeTests.test_rangeMissingStop��%��
	
������8�8��E�	�{�Sr c�\�|j|jjd�dg�y)z�
        A single bytes range without an explicit start position is parsed into
        a two-tuple of L{None} and the end position.
        sbytes=-3)Nr�Nr�r�s r)�test_rangeMissingStartz!RangeTests.test_rangeMissingStart�r�r c�\�|j|jjd�dg�y)z�
        A single bytes range with explicit start and stop positions is parsed
        into a two-tuple of those positions.
        s	bytes=2-5)r�rWNr�r�s r)�
test_rangezRangeTests.test_range�s%��
	
������8�8��F���Qr c��|j|jjd�dg�|j|jjd�dg�|j|jjd�dg�|j|jjd�dg�|j|jjd�dg�|j|jjd�dg�y)	z�
        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 �rCr�sbytes =1-2 s
bytes= 1-2s
bytes=1 -2s
bytes=1- 2s
bytes=1-2 Nr�r�s r)�test_rangeWithSpacezRangeTests.test_rangeWithSpace�s���
	
������8�8��H�6�(�S�������8�8��H�6�(�S�������8�8��G�&��R�������8�8��G�&��R�������8�8��G�&��R�������8�8��G�&��Rr c�\�|j|jjd�dg�y)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.
        sbytes=1-2,
, ,	r�Nr�r�s r)�test_nullRangeElementsz!RangeTests.test_nullRangeElements�s)��
	
����M�M�+�+�,B�C�f�X�	
r c�^�|j|jjd�ddg�y)zd
        If multiple byte ranges are specified their starts and stops are
        returned.
        s
bytes=1-2,3-4r�)r�r�Nr�r�s r)�test_multipleRangeszRangeTests.test_multipleRanges�s,��
	
����M�M�+�+�,<�=���?O�	
r c��|jjjdd�|jj	|j�|jt
dj|jj��d�y)zp
        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*r+rr5r"rLr#r$r�s r)�test_bodyLengthzRangeTests.test_bodyLength�s\��
	
���#�#�0�0��=�I��
�
���T�\�\�*�����S�X�X�d�l�l�&:�&:�;�<�b�Ar c�j�d}|jjjd|�|jj	|j�d|j���}|j
|�|jdj|jj�|j�|j|jjtj�|j|jjjd�ddt!|j�fz�y)	a&
        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.
        sfoobar=0-43r&z Ignoring malformed Range header r r�rrN)r'r*r+rr5r�r�r"r#r$r�r_rrr�r�rL)r(�ranger�s   r)�test_invalidRangeRequestz#RangeTests.test_invalidRangeRequest�s��������#�#�0�0��5�A��
�
���T�\�\�*�5�e�l�l�n�5G�H�����8�$�������$�,�,�"6�"6�7����F�������2�2�D�G�G�<�����L�L�(�(�6�6�7H�I�!�L��S����&�(�(�	
r c�p�d|z}|j|�}|jd|d�|jd|d�g}|ddD]�}|jdd�\}}}	}
}|d	z|	z}|jd|�|jd|
�tjd
|tjtj
z�j
d�}
tjd|tjtj
z�j�\}}}|j|
|||f|d����|S)
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 rs--
���rCs
r��
s^content-type: (.*)$s1^content-range: bytes ([0-9]+)-([0-9]+)/([0-9]+)$)�contentType�contentRange�body)	�splitr"r]�search�I�M�group�groupsr�)r(�bodyra�sep�parts�parsed_parts�part�before�header1�header2�blank�partBody�headers�partContentTypeValuer�endrcs                 r)�parseMultipartBodyzRangeTests.parseMultipartBody�s7���(�"���
�
�3�������e�A�h�'�����E�"�I�.����!�B�K�	�D�8<�
�
�7�A�8N�5�F�G�W�e�X���o��/�G����S�&�)����S�%�(�#%�9�9�'��"�$�$����+�$��e�A�h�
!� "�y�y�D�����r�t�t�� ��f�h�	
�E�3��

���$8�&+�S�$�%7�%��
�	�(�r c��gd�}dj|D��cgc]\}}t|�d|�����c}}�}|jjj	dd|z�|j
j
|j�|j|jjtj�tjd|jjjd�d�jd	�}|j!d
j|jj"�|�}|jt%|�t%|��t'||�D]�\}\}}|jt|j
j(�|d�|d\}}	}
|jt+|�|�|jt+|	�|�|jt+|
�|j
j-��|j|j.||d	z|d
���ycc}}w)zo
        The response to a request for multiple bytes ranges is a MIME-ish
        multipart response.
        )�rr�)��)�(�2�,�-r&�bytes=�'^multipart/byteranges; boundary="(.*)"$rrrCr r�r�r�N)r#r
r'r*r+rr5r"r_rr2r]r^r�r�r�r�r$rL�zipr�int�getFileSizer��r(�	startEnds�s�e�rangeHeaderValuerar�r�rr�rcs           r)�test_multipleRangeRequestz$RangeTests.test_multipleRangeRequests���
1�	��9�9�5>�?�6�A�q�]�a�S��!��:�
&�?�
��	
���#�#�0�0��9�GW�;W�X��
�
���T�\�\�*�������2�2�D�4H�4H�I��8�8�6��L�L�(�(�6�6��G��J�
��%��(�	��'�'�������1E�1E�(F��Q������Y���U��4���y�1�	E�L�D�&�1�a����]�4�=�=�+=�+=�>��^�@T�U�#�O�4��E�3�����S��Z��+����S��X�q�)����S��Y��
�
�(A�(A�(C�D����T�\�\�!�a�!�e�4�d�7�m�D�
	E��
@s�H>
c��ddt|j�dzfg}dj|D��cgc]\}}t|�d|�����c}}�}|jj
j
dd|z�|jj|j�|j|jjtj�tjd|jjj!d	�d
�j#d�}|j%dj|jj&�|�}|jt|�t|��t)||�D]�\}\}}|jt|jj*�|d
�|d\}}	}
|jt-|�|�|jt-|	�t/||jj1�dz
��|jt-|
�|jj1��|j|j||dz|d���ycc}}w)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.
        r�r�r�r�r�r&r�r�rrrCr r�r�r�N)rLr�r#r
r'r*r+rr5r"r_rr2r]r^r�r�r�r�r$r�rr��minr�r�s           r)�0test_multipleRangeRequestWithRangeOverlappingEndz;RangeTests.test_multipleRangeRequestWithRangeOverlappingEnd5s���b�#�d�l�l�"3�b�"8�9�:�	��9�9�5>�?�6�A�q�]�a�S��!��:�
&�?�
��	
���#�#�0�0��9�GW�;W�X��
�
���T�\�\�*�������2�2�D�4H�4H�I��8�8�6��L�L�(�(�6�6��G��J�
��%��(�	��'�'�������1E�1E�(F��Q������Y���U��4���y�1�	E�L�D�&�1�a����]�4�=�=�+=�+=�>��^�@T�U�#�O�4��E�3�����S��Z��+����S��X�s�1�d�m�m�.G�.G�.I�A�.M�'N�O����S��Y��
�
�(A�(A�(C�D����T�\�\�!�a�!�e�4�d�7�m�D�
	E��
@s�I;
c���|jjjdd�|jj	|j�|jdj
|jj�|jdd�|jtdj
|jj��d�|j|jjtj�|j|jjjd�dd	�|j|jjjd
�dd�y)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 �N�)r8rsbytes 23-63/64r�s41�r'r*r+rr5r"r#r$r�rLr_rr2r�r�r�s r)�test_implicitEndzRangeTests.test_implicitEndPs	��
	
���#�#�0�0��<�H��
�
���T�\�\�*�������$�,�,�"6�"6�7����b�c�9J�K�����S�X�X�d�l�l�&:�&:�;�<�b�A�������2�2�D�4H�4H�I�����L�L�(�(�6�6�7G�H��K��	
�	
����L�L�(�(�6�6�7H�I�!�L�e�	
r c���|jjjdd�|jj	|j�|jdj
|jj�|jdd�|jtdj
|jj��d�|j|jjtj�|j|jjjd�dd	�|j|jjjd
�dd�y)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 i��N�r8rsbytes 47-63/64r�s17rr�s r)�test_implicitStartzRangeTests.test_implicitStartbs	��	
���#�#�0�0��<�H��
�
���T�\�\�*�������$�,�,�"6�"6�7����c�d�9K�L�����S�X�X�d�l�l�&:�&:�;�<�b�A�������2�2�D�4H�4H�I�����L�L�(�(�6�6�7G�H��K��	
�	
����L�L�(�(�6�6�7H�I�!�L�e�	
r c��|jjjdd�|jj	|j�dj|jj�}|j||jdd�|j|jjtj�|j|jjjd�dd�|jd	t|�fz|jjjd
�d�y)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�r�r8rs
bytes 3-43/64rr�N�r'r*r+rr5r#r$r"r�r_rr2r�r�rL�r(r$s  r)�test_explicitRangezRangeTests.test_explicitRangeus���	
���#�#�0�0��=�I��
�
���T�\�\�*��(�(�4�<�<�/�/�0������$�,�,�q��"4�5�������2�2�D�4H�4H�I�����L�L�(�(�6�6�7G�H��K��	
�	
����S��\�O�#��L�L�(�(�6�6�7H�I�!�L�	
r c��|jjjdd�|jj	|j�dj|jj�}|j||jdd�|j|jjtj�|j|jjjd�dd�|jd	t|�fz|jjjd
�d�y)a
        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 r�Nr8rsbytes 40-63/64rr�rr	s  r)� test_explicitRangeOverlappingEndz+RangeTests.test_explicitRangeOverlappingEnd�s���	
���#�#�0�0��?�K��
�
���T�\�\�*��(�(�4�<�<�/�/�0������$�,�,�r�s�"3�4�������2�2�D�4H�4H�I�����L�L�(�(�6�6�7G�H��K��	
�	
����S��\�O�#��L�L�(�(�6�6�7H�I�!�L�	
r c��|jjjdd�|jj	|j�|j|jjtj�|jdj|jj�|j�|j|jjjd�ddt|j�fz�y)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&sbytes=20-13r r�rrN)r'r*r+rr5r"r_rrr#r$r�r�r�rLr�s r)�+test_statusCodeRequestedRangeNotSatisfiablez6RangeTests.test_statusCodeRequestedRangeNotSatisfiable�s���	
���#�#�0�0��>�J��
�
���T�\�\�*�������2�2�D�G�G�<�������$�,�,�"6�"6�7����F�����L�L�(�(�6�6�7H�I�!�L��S����&�(�(�	
r c	��|jjjdd�|jj	|j�|j|jjtj�|jdj|jj�d�|j|jjjd�dd�|j|jjjd�dtdt|j�fz��y	)
a
        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�rrEr8z
bytes */%dN)r'r*r+rr5r"r_rr@r#r$r�r�r
rLr�r�s r)�test_invalidStartBytePosz#RangeTests.test_invalidStartBytePos�s���	
���#�#�0�0��?�K��
�
���T�\�\�*�����L�L�%�%�t�'K�'K�	
�	
������$�,�,�"6�"6�7��=�����L�L�(�(�6�6�7H�I�!�L�d�	
�	
����L�L�(�(�6�6�7G�H��K��,�#�d�l�l�*;�)=�=�>�	
r N)r7r8r9r:r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrr;r r)r�r�Rsy��� -�80�W�7�8T�T�R�
S�
�
�B�
�& �DE�4E�6
�$
�&
�(
�*

�
r r�c��eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
eej �d�d
��Zd�Zd�Zd�Zy)�DirectoryListerTestsz.
    Tests for L{static.DirectoryLister}.
    c�,�tdg�}||_|Sr)rr�)r(r�r's   r)�_requestzDirectoryListerTests._request�s����u�%������r c��t|j��}|j�tj|j
�}|j
|jd��}|jd|�|jd|�y)zm
        L{static.DirectoryLister} prints the request uri as header of the
        rendered content.
        rs"<h1>Directory listing for foo</h1>s(<title>Directory listing for foo</title>N�	rrKrbrrjrXr5rr[�r(rX�listerr/s    r)�test_renderHeaderz&DirectoryListerTests.test_renderHeader�sf��
����
�&���
�
���'�'��	�	�2���}�}�T�]�]�6�2�3���
�
�;�T�B��
�
�A�4�Hr c��t|j��}|j�tj|j
�}|j
|jd��}|jd|�|jd|�y)zW
        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>Nrrs    r)�test_renderUnquoteHeaderz-DirectoryListerTests.test_renderUnquoteHeader�sf������
�&���
�
���'�'��	�	�2���}�}�T�]�]�<�8�9���
�
�?��F��
�
�E�t�Lr c��t|j��}|j�tj|j
�}|j
|jd��}|jd|�|jd|�y)zl
        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>Nrrs    r)�test_escapeHeaderz&DirectoryListerTests.test_escapeHeader�sf��
����
�&���
�
���'�'��	�	�2���}�}�T�]�]�<�8�9���
�
�C�T�J��
�
�I�4�Pr c��t|j��}|j�|jd�j	d�|jd�j	ddz�tj|j�}|j|jd��}d}|j||�y)	ze
        L{static.DirectoryLister} is able to list all the files inside a
        directory.
        �file1scontent1�file2scontent2i�rs�<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)rrKrbrfrWrrjrXr5rr[�r(rXrr/r�s     r)�test_renderFilesz%DirectoryListerTests.test_renderFiles�s���
����
�&���
�
���
�
�7��&�&�{�3��
�
�7��&�&�{�T�'9�:��'�'��	�	�2���}�}�T�]�]�6�2�3��	��	
�
�
�d�D�!r c�x�t|j��}|j�|jd�j�|jd�j�t	j
|j�}|j|jd��}d}|j||�y)zk
        L{static.DirectoryLister} is able to list all the directories inside
        a directory.
        �dir1zdir2 & 3rs�<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�
rrKrbrfrrjrXr5rr[r!s     r)�test_renderDirectoriesz+DirectoryListerTests.test_renderDirectoriess���
����
�&���
�
���
�
�6��#�#�%��
�
�:��'�'�)��'�'��	�	�2���}�}�T�]�]�6�2�3��	��	
�
�
�d�D�!r c��t|j��}|j�|jd�j�|jd�j�|jd�j�t	j
|jddg��}|j|jd��}d}|j||�y)z�
        L{static.DirectoryLister} takes an optional C{dirs} argument that
        filter out the list of directories and files printed.
        r$�dir2�dir3)�dirsrs�<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_renderFilteredz(DirectoryListerTests.test_renderFiltered(s���
����
�&���
�
���
�
�6��#�#�%��
�
�6��#�#�%��
�
�6��#�#�%��'�'��	�	���8H�I���}�}�T�]�]�6�2�3��	��	
�
�
�d�D�!r c	�*�tjd�}td�D�cgc]
}dddddd���}}|j|�}|j	t|�d�|j
|djd��|j
|djd��|j
|d	jd��|j
|d
jd��|j
|djd��ycc}w)zu
        L{static.DirectoryLister} gives an alternate class for each odd and
        even rows in the table.
        NrWr)�href�textrcrrrz<tr class="odd">rCz<tr class="even">r�r�r�)rrjr��_buildTableContentr"rLr�r)r(r�i�elementsr�s     r)�test_oddAndEvenz$DirectoryListerTests.test_oddAndEvenBs���
�'�'��-���1�X�
����R���L�
��
��+�+�H�5������W��q�)������
�-�-�.@�A�B������
�-�-�.A�B�C������
�-�-�.@�A�B������
�-�-�.A�B�C������
�-�-�.@�A�B��
s�Dc�4�t|j��}|j�tj|j
�}|j
d�}|j|�|j|jjd�dd�y)z�
        L{static.DirectoryLister} produces a MIME-type that indicates that it is
        HTML, and includes its charset (UTF-8).
        r rrstext/html; charset=utf-8N)rrKrbrrjrXrr5r"r�r�)r(rXr�reqs    r)�test_contentTypez%DirectoryListerTests.test_contentTypeUsu��
����
�&���
�
���'�'��	�	�2���m�m�C� ���
�
�c��������-�-�o�>�q�A�'�	
r c��t|j��}|j�|jd�j	d�|jd�j	d�|jd�j	d�|jd�j	d�tj|j�}|j�d	d
ddd
�}tj|j|��}|j|�\}}|j|g�|j|dddddd�dddddd�dddddd�dddddd�g�y)zl
        L{static.DirectoryLister} is able to detect mimetype and encoding of
        listed files.
        z	file1.txt�file1zfile2.pyspythonz
file3.conf.gzsconf compressedzfile4.diff.bz2sdiff compressedrztext/pythonztext/configurationz	text/diff)z.txtz.pyz.confz.diff)�contentTypesr�5Bz[text/plain])rr-rcr.r�6Bz
[text/python]z[gzip]�15Bz[text/configuration]z[bzip2]z[text/diff]N)
rrKrbrfrW�os�listdirrX�sortrrj�_getFilesAndDirectoriesr")r(rX�	directoryr8rr*�filess       r)�test_mimeTypeAndEncodingsz.DirectoryListerTests.test_mimeTypeAndEncodingsdsW��
����
�&���
�
���
�
�;��*�*�8�4��
�
�:��)�)�)�4��
�
�?�#�.�.�/A�B��
�
�#�$�/�/�0B�C��J�J�t�y�y�)�	�����!� �)� �	
���'�'��	�	��M���4�4�Y�?���e�����r�"�����!#�'� �'�*��!#�&� �&�+��!)�+�!�+�2��!*�,�!�,�)��-
� 	
r zNo symlink supportc��t|j��}|j�|jd�}|j	d�|j|jd��|j
�tj|j�}tj|j�}|j�|j|�\}}|j|g�|j|g�y)z�
        If on the file in the listing points to a broken symlink, it should not
        be returned by L{static.DirectoryLister._getFilesAndDirectories}.
        rr7r N)rrKrbrfrW�linkTo�removerrjrXr<r=r>r?r")r(rXrrr@r*rAs       r)�test_brokenSymlinkz'DirectoryListerTests.test_brokenSymlink�s�������
�&���
�
���
�
�7�#��
����"�
���T�Z�Z��(�)�
�����'�'��	�	�2���J�J�t�y�y�)�	������4�4�Y�?���e�����r�"������#r c�.���t�j��}|j�tj|j
�}�j
d��tj|��}t|��}��fd�}|j|�|S)zu
        Any child resource of L{static.DirectoryLister} renders an HTTP
        I{NOT FOUND} response code.
        r c�Z���j�jtj�yr?)r"r_r�	NOT_FOUNDr%s ��r)r*z>DirectoryListerTests.test_childrenNotFound.<locals>.cbRendered�s������W�1�1�4�>�>�Br )rrKrbrrjrXrrrcrr.)r(rXrrfr�r*r's`     @r)�test_childrenNotFoundz*DirectoryListerTests.test_childrenNotFound�sy���
����
�&���
�
���'�'��	�	�2���-�-��$���+�+�F�G�<�����(��	C�	���:�&��
r c��t|j��}tj|j�}|jt
|�d|j�d��|jt|�d|j�d��y)zR
        L{static.DirectoryLister.__repr__} gives the path of the lister.
        z<DirectoryLister of �>N)rrKrrjrXr"�reprr�)r(rXrs   r)�	test_reprzDirectoryListerTests.test_repr�sl������
�&���'�'��	�	�2������f��)=�d�i�i�]�!�'L�M�����V��(<�T�Y�Y�M��&K�Lr c��|jtjd�d�|jtjd�d�|jtjd�d�|jtjd�d�|jtjd	�d
�|jtjd�d�y
)zi
        L{static.formatFileSize} format an amount of bytes into a more readable
        format.
        r�0Br�123Bi��4Ki�͇�8Mi�X�I�1GlP�c}�1149GN)r"r�formatFileSizer�s r)�test_formatFileSizez(DirectoryListerTests.test_formatFileSize�s���
	
����.�.�q�1�4�8�����.�.�s�3�V�<�����.�.�t�4�d�;�����.�.�w�7��>�����.�.�z�:�D�A�����.�.�}�=�w�Gr N)r7r8r9r:rrrrr"r&r+r2r5rBrr�_supportsSymlinksrFrJrNrWr;r r)rr�s{����
I�
M�Q�"�4"�4"�4C�&

�8
�t�*��*�*�,�,�.B�C�$�D�$�&�$M�
Hr rc�<�eZdZdZe�Zd�Zd�Zd�Zd�Z	d�Z
y)�LoadMimeTypesTestsz�
    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�&�|j|_yr?)�UNSET�pathsr�s r)r�zLoadMimeTypesTests.setUp�s
���Z�Z��
r c��||_y)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)�	_fakeInitzLoadMimeTypesTests._fakeInit�s����
r c�|�tj|j��|j|jd�y)zE
        By default, L{None} is passed to C{mimetypes.init}.
        ��initN�r�
loadMimeTypesr`rwr]r�s r)�test_defaultArgumentIsNonez-LoadMimeTypesTests.test_defaultArgumentIsNone�s*��	���$�.�.�1����T�Z�Z��.r c��gd�}tj||j��|j|j|�y)zI
        Passed MIME type files are passed to C{mimetypes.init}.
        )�x�y�zrbNrdr_s  r)�test_extraLocationsWorkz*LoadMimeTypesTests.test_extraLocationsWork�s1�� �����U����8����T�Z�Z��/r c��ttdd�r[tjtj�}|j|jdjtj�ytjtj�\}}}}||jd�}|j|tj�y)z:
        By default, C{mimetypes.init} is called.
        �	signatureNrc)�getattr�inspectrmrre�assertIs�
parameters�default�	mimetypesrc�
getargspec�index)r(rm�argsr��defaults�defaultInits      r)�test_usesGlobalInitFunctionz.LoadMimeTypesTests.test_usesGlobalInitFunction�s����7�K��.��)�)�&�*>�*>�?�I��M�M�)�.�.�v�6�>�>�	���O�#*�#5�#5�f�6J�6J�#K� �D�!�Q��"�4�:�:�f�#5�6�K��M�M�+�y�~�~�6r N)r7r8r9r:�objectr\r�r`rfrkryr;r r)rZrZ�s)���
�H�E� ��/�0�
7r rZc��eZdZd�Zy)�StaticDeprecationTestsc���ddlm}|tdg��|j|jg�}|jt
|�d�|j|ddd�y)z?
        L{twisted.web.static.addSlash} is deprecated.
        r)�addSlashr rCr�z<twisted.web.static.addSlash was deprecated in Twisted 16.0.0N)�twisted.web.staticr~r�
flushWarnings�test_addSlashDeprecatedr"rL)r(r~rHs   r)r�z.StaticDeprecationTests.test_addSlashDeprecateds`��	0���s�e�$�%��%�%�t�'C�'C�&D�E������X���*�����Q�K�	�"�J�	
r N)r7r8r9r�r;r r)r|r|s��

r r|)5r:r�rorsr<r]r�rH�iorr��unittestr�zope.interface.verifyr�twisted.internetrr�twisted.pythonrr	�twisted.python.compatr
�twisted.python.filepathr�twisted.python.runtimer�twisted.trial.unittestr
�twisted.webrrrr�twisted.web._responsesr�twisted.web.serverr�twisted.web.test._utilr�twisted.web.test.requesthelperrrr=rrorzr�r�r�rrZr|r;r r)�<module>r�s����
���	�	�
��"��.�1�&�/�,�+�+�6�6�(�0�*�7�C�h�C�>u)�h�u)�psI�h�sI�l	5�(�5�69/��9/�x>/�X�>/�BJ/�x�J/�Zo
��o
�dSH�8�SH�l27��27�j
�X�
r 

Zerion Mini Shell 1.0