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__/_util.cpython-38.pyc
U


W[
�@s�dZddlmZmZddlmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	d
�ZGdd�de	�Zd
dgZd
S)z0
General helpers for L{twisted.web} unit tests.
�)�division�absolute_import)�succeed)�server)�TestCase)�Failure)�
flattenString)�FlattenerErrorcCsb|�|�}t|t�r.|�|�|��td�S|tjkrP|jrFtd�S|�	�Snt
d|f��dS)NzUnexpected return value: %r)Zrender�
isinstance�bytes�writeZfinishrrZNOT_DONE_YETZfinishedZnotifyFinish�
ValueError)�resourceZrequest�result�r�8/usr/lib/python3/dist-packages/twisted/web/test/_util.py�_renders




rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FlattenTestCasezH
    A test case that assists with testing L{twisted.web._flatten}.
    cs"td|�}|���fdd��|S)zS
        Assert that a root element, when flattened, is equal to a string.
        Ncs��|��S�N)ZassertEqual)�s��self�targetrr�<lambda>-�z2FlattenTestCase.assertFlattensTo.<locals>.<lambda>)r�addCallback)r�rootr�drrr�assertFlattensTo(s
z FlattenTestCase.assertFlattensTocCsXg}|�||�}|�|j�|�|j�|s6|�d�|d}t|t�rP|��|dS)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}
        z'Rendering did not complete immediately.r)	rZaddBoth�appendZ
addCleanupZcancelZfailr
rZraiseException)rrrZresults�itrrrr�assertFlattensImmediately1s


z)FlattenTestCase.assertFlattensImmediatelycs,����|d�t�}|���fdd��|S)zQ
        Assert flattening a root element raises a particular exception.
        rcs��|j��Sr)ZassertIsInstanceZ
_exception)�exc��exnrrrrPrz8FlattenTestCase.assertFlatteningRaises.<locals>.<lambda>)Z
assertFailurerr	r)rrr$rrr#r�assertFlatteningRaisesKsz&FlattenTestCase.assertFlatteningRaisesN)�__name__�
__module__�__qualname__�__doc__rr!r%rrrrr$s	rN)r)Z
__future__rrZtwisted.internet.deferrZtwisted.webrZtwisted.trial.unittestrZtwisted.python.failurerZtwisted.web._flattenrZtwisted.web.errorr	rr�__all__rrrr�<module>s0