%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f����dZddlZddlmZddlmZddlmZddlm	Z	ddl
mZmZddl
mZdd	lmZGd
�de�ZGd�d
e�Zy)z"
Tests for L{twisted.web.script}.
�N)�defer)�FilePath)�TestCase)�	NOT_FOUND)�PythonScript�ResourceScriptDirectory)�_render)�DummyRequestc��eZdZdZdej
dfd�Zdej
dfd�Zdej
dfd�Zy)�ResourceScriptDirectoryTestsz/
    Tests for L{ResourceScriptDirectory}.
    �returnNc����t�j��}tdg��t|��}dtddf��fd�}|j|�S)zh
        L{ResourceScriptDirectory.render} sets the HTTP response code to I{NOT
        FOUND}.
        ��ignoredr
Nc�F���j�jt�y�N��assertEqual�responseCoder�r�request�selfs ���>/usr/lib/python3/dist-packages/twisted/web/test/test_script.py�
cbRenderedzDResourceScriptDirectoryTests.test_renderNotFound.<locals>.cbRendered!�������W�1�1�9�=r)r�mktempr
r	�object�addCallback�r�resource�drrs`   @r�test_renderNotFoundz0ResourceScriptDirectoryTests.test_renderNotFoundsQ���
+�4�;�;�=�9����u�%���H�g�&��	>��	>�4�	>��}�}�Z�(�(rc�����j�}tj|�t|�}t	dg��|jd��}t
|��}dtddf��fd�}|j|�S)a
        L{ResourceScriptDirectory.getChild} returns a resource which renders an
        response with the HTTP I{NOT FOUND} status code if the indicated child
        does not exist as an entry in the directory used to initialized the
        L{ResourceScriptDirectory}.
        sfoo�foorr
Nc�F���j�jt�yrrrs ��rrzCResourceScriptDirectoryTests.test_notFoundChild.<locals>.cbRendered4rr)	r�os�makedirsrr
�getChildr	rr)r�pathr �childr!rrs`     @r�test_notFoundChildz/ResourceScriptDirectoryTests.test_notFoundChild&st����{�{�}��
���D��*�4�0����x�(���!�!�%��1���E�7�#��	>��	>�4�	>��}�}�Z�(�(rc�^���t�j��}|j�|jd�j	d�t|j
��}tdg��|jd��}t|��}dtddf��fd�}|j|�S)	��
        L{ResourceScriptDirectory.getChild} returns a resource which renders a
        response with the HTTP 200 status code and the content of the rpy's
        C{request} global.
        ztest.rpys�
from twisted.web.resource import Resource
class TestResource(Resource):
    isLeaf = True
    def render_GET(self, request):
        return b'ok'
resource = TestResource()rstest.rpyrr
Nc�\���jdj�j�d�y)Nrsok)r�join�writtenrs ��rrz<ResourceScriptDirectoryTests.test_render.<locals>.cbRenderedOs ������S�X�X�g�o�o�6��>r)rrr'r*�
setContentr�_asBytesPathr
r(r	rr)r�tmpr r*r!rrs`     @r�test_renderz(ResourceScriptDirectoryTests.test_render9s�����t�{�{�}�%�������	�	�*��(�(�
�	
�+�3�+;�+;�+=�>����u�%���!�!�+�w�7���E�7�#��	?��	?�4�	?��}�}�Z�(�(r)	�__name__�
__module__�__qualname__�__doc__r�Deferredr"r+r4�rrrrsF���)�U�^�^�D�%9�)�)�E�N�N�4�$8�)�&)�U�^�^�D�1�)rrc�\�eZdZdZdej
dfd�Zdej
dfd�Zy)�PythonScriptTestsz$
    Tests for L{PythonScript}.
    r
Nc����t�j�d�}tdg��t|��}dtddf��fd�}|j|�S)z�
        If the source file a L{PythonScript} is initialized with doesn't exist,
        L{PythonScript.render} sets the HTTP response code to I{NOT FOUND}.
        Nrrr
c�F���j�jt�yrrrs ��rrz9PythonScriptTests.test_notFoundRender.<locals>.cbRenderedcrr)rrr
r	rrrs`   @r�test_notFoundRenderz%PythonScriptTests.test_notFoundRenderZsS���
 ����
�t�4����u�%���H�g�&��	>��	>�4�	>��}�}�Z�(�(rc�@���t�j��}|j�|jd�}|j	d�t|j
�d�}tdg��t|��}dtddf��fd�}|j|�S)r-ztest.epysraise Exception("nooo")Nrrr
c�\���jddj�j��y)Nsnooor)�assertInr/r0rs ��rrz:PythonScriptTests.test_renderException.<locals>.cbRenderedvs����M�M�'�3�8�8�G�O�O�#<�=r)rrr'r*r1rr2r
r	rr)rr3r*r r!rrs`     @r�test_renderExceptionz&PythonScriptTests.test_renderExceptionhs�����t�{�{�}�%�������	�	�*�%��
���3�4��� 2� 2� 4�d�;����u�%���H�g�&��	>��	>�4�	>��}�}�Z�(�(r)r5r6r7r8rr9r?rCr:rrr<r<Us1���)�U�^�^�D�%9�)�)�e�n�n�T�&:�)rr<)r8r&�twisted.internetr�twisted.python.filepathr�twisted.trial.unittestr�twisted.web.httpr�twisted.web.scriptrr�twisted.web.test._utilr	�twisted.web.test.requesthelperr
rr<r:rr�<module>rKs=���
�"�,�+�&�D�*�7�?)�8�?)�D$)��$)r

Zerion Mini Shell 1.0