HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/_util.cpython-310.pyc
o

�bf�@s�dZddlmZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
�ZGdd�de�Zd
d�Zgd�ZdS)z0
General helpers for L{twisted.web} unit tests.
�)�Type)�Deferred�succeed)�SynchronousTestCase)�server)�
flattenString)�FlattenerError)�FlattenablecCs\|�|�}t|t�r|�|�|��td�S|tjur'|jr#td�S|�	�St
d|����)NzUnexpected return value: )�render�
isinstance�bytes�write�finishrr�NOT_DONE_YET�finished�notifyFinish�
ValueError)�resource�request�result�r�8/usr/lib/python3/dist-packages/twisted/web/test/_util.py�_renders



rc@sZeZdZdZdededeefdd�Zdededefdd�Zded	e	e
dd
fdd�Zd
S)
�FlattenTestCasezH
    A test case that assists with testing L{twisted.web._flatten}.
    �root�target�returncs0dtdtf��fdd�}td|�}|�|�|S)zS
        Assert that a root element, when flattened, is equal to a string.
        rrcs��|��S)N)�assertEqual)r��selfrrr�check,sz/FlattenTestCase.assertFlattensTo.<locals>.checkN)rr�addCallback)rrrr �drrr�assertFlattensTo's

z FlattenTestCase.assertFlattensTocCs|�|�||��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#)rrrrrr�assertFlattensImmediately3s
z)FlattenTestCase.assertFlattensImmediately�exnNcCs(|�|�|d�t�}|�|jj|�dS)zQ
        Assert flattening a root element raises a particular exception.
        �N)�failureResultOfr#r�assertIsInstance�value�
_exception)rrr&�failurerrr�assertFlatteningRaisesBsz&FlattenTestCase.assertFlatteningRaises)�__name__�
__module__�__qualname__�__doc__r	rrr#r%r�	Exceptionr-rrrrr"s
rcCs|�|��t�dS)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)r)�fileno�int)�case�fileObjrrr�assertIsFilesystemTemporaryJsr7)rrr7N)r1�typingr�twisted.internet.deferrr�twisted.trial.unittestr�twisted.webr�twisted.web._flattenr�twisted.web.errorr�twisted.web.templater	rrr7�__all__rrrr�<module>s(