HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_script.cpython-38.pyc
U


W[��@s|dZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZGd	d
�d
e�ZGdd�de�ZdS)
z"
Tests for L{twisted.web.script}.
�N)�TestCase)�FilePath)�	NOT_FOUND)�ResourceScriptDirectory�PythonScript)�_render)�DummyRequestc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ResourceScriptDirectoryTestsz/
    Tests for L{ResourceScriptDirectory}.
    cs<t����}tdg��t|��}��fdd�}|�|�|S)zh
        L{ResourceScriptDirectory.render} sets the HTTP response code to I{NOT
        FOUND}.
        �cs���jt�dS�N��assertEqualZresponseCoder�Zignored�Zrequest�self��>/usr/lib/python3/dist-packages/twisted/web/test/test_script.py�
cbRenderedszDResourceScriptDirectoryTests.test_renderNotFound.<locals>.cbRendered)r�mktemprr�addCallback�r�resource�drrrr�test_renderNotFounds


z0ResourceScriptDirectoryTests.test_renderNotFoundcsV���}t�|�t|�}tdg��|�d��}t|��}��fdd�}|�|�|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}.
        sfooZfoocs���jt�dSrrrrrrr1szCResourceScriptDirectoryTests.test_notFoundChild.<locals>.cbRendered)r�os�makedirsrr�getChildrr)r�pathr�childrrrrr�test_notFoundChild$s



z/ResourceScriptDirectoryTests.test_notFoundChildcslt����}|��|�d��d�t|���}tdg��|�d��}t	|��}��fdd�}|�
|�|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()r
stest.rpycs��d��j�d�dS)Nr
sok)r
�join�writtenrrrrrJsz<ResourceScriptDirectoryTests.test_render.<locals>.cbRendered)rrrr�
setContentr�_asBytesPathrrrr)r�tmprrrrrrr�test_render7s


z(ResourceScriptDirectoryTests.test_renderN)�__name__�
__module__�__qualname__�__doc__rrr&rrrrr	sr	c@s eZdZdZdd�Zdd�ZdS)�PythonScriptTestsz$
    Tests for L{PythonScript}.
    cs>t���d�}tdg��t|��}��fdd�}|�|�|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}.
        Nr
cs���jt�dSrrrrrrr]sz9PythonScriptTests.test_notFoundRender.<locals>.cbRendered)rrrrrrrrr�test_notFoundRenderUs


z%PythonScriptTests.test_notFoundRendercsft����}|��|�d�}|�d�t|��d�}tdg��t|��}��fdd�}|�	|�|S)r ztest.epysraise Exception("nooo")Nr
cs��dd��j��dS)Nsnooor
)ZassertInr!r"rrrrrpsz:PythonScriptTests.test_renderException.<locals>.cbRendered)
rrrrr#rr$rrr)rr%rrrrrrr�test_renderExceptioncs




z&PythonScriptTests.test_renderExceptionN)r'r(r)r*r,r-rrrrr+Qsr+)r*rZtwisted.trial.unittestrZtwisted.python.filepathrZtwisted.web.httprZtwisted.web.scriptrrZtwisted.web.test._utilrZtwisted.web.test.requesthelperrr	r+rrrr�<module>s?