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 :  /usr/lib/python3/dist-packages/twisted/spread/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


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

Current File : /usr/lib/python3/dist-packages/twisted/spread/test/__pycache__/test_banana.cpython-310.pyc
o

�b�7�@s�ddlZddlmZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZd
ZGdd�de�Zd
d�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZdS)�N)�partial)�BytesIO)�main�protocol)�failure)�	iterbytes)�banana)�StringTransport)�TestCasel����c@seZdZdd�ZdS)�	MathTestscCspttdd��ttdd��ttdd��dg}|D]}t�}t�||j�|��}t�|�}|�||�qdS)Nr�di�iLi@Bi�Bl)	�list�rangerr�int2b128�write�getvalue�b1282int�assertEqual)�self�	funkylist�i�x�v�y�r�A/usr/lib/python3/dist-packages/twisted/spread/test/test_banana.py�
test_int2b128s����
�zMathTests.test_int2b128N)�__name__�
__module__�__qualname__rrrrrrsrcCs|�|�dS)z�
    Dictate a Banana dialect to use.

    @param protocol: A L{banana.Banana} instance which has not yet had a
        dialect negotiated.

    @param dialect: A L{bytes} instance naming a Banana dialect to select.
    N)�_selectDialect)r�dialectrrr�
selectDialect#sr"cCs0t�}|�}|�|�|��|�|�|��S)a�
    Banana encode an object using L{banana.Banana.sendEncoded}.

    @param bananaFactory: A no-argument callable which will return a new,
        unconnected protocol instance to use to do the encoding (this should
        most likely be a L{banana.Banana} instance).

    @param obj: The object to encode.
    @type obj: Any type supported by Banana.

    @return: A L{bytes} instance giving the encoded form of C{obj}.
    )r	�makeConnection�clear�sendEncoded�value)�
bananaFactory�obj�	transportrrrr�encode2s


r*c@s.eZdZdZejZdd�Zdd�Zdd�Z	dS)	�BananaTestBasezn
    The base for test classes. It defines commonly used things and sets up a
    connection for testing.
    cCsNt�|_|��|_|j�t�|j��t|jd�|j|j_	t
t|j�|_dS)Nsnone)r�io�encClass�encr#r�FileWrapperr"�	putResult�expressionReceivedrr*�rrrr�setUpPs

zBananaTestBase.setUpcCs
||_dS)z�
        Store an expression received by C{self.enc}.

        @param result: The object that was received.
        @type result: Any type supported by Banana.
        N)�result)rr4rrrr0Xs
zBananaTestBase.putResultcCs|j�t�tj��|`dS�N)r.�connectionLostr�Failurer�CONNECTION_DONEr2rrr�tearDownaszBananaTestBase.tearDownN)
rrr�__doc__r�Bananar-r3r0r9rrrrr+Hs	r+c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0S)1�BananaTestsz
    General banana tests.
    cCs0|j�d�|j�|j���|jdksJ�dS)Nshello)r.r%�dataReceivedr,rr4r2rrr�test_stringk�zBananaTests.test_stringcCs|�dd�dS)z�
        Banana does not support unicode.  ``Banana.sendEncoded`` raises
        ``BananaError`` if called with an instance of ``unicode``.
        �hellozbuiltins.strN)�_unsupportedTypeTestr2rrr�test_unsupportedUnicodepsz#BananaTests.test_unsupportedUnicodecCs|�td�dS)z�
        Banana does not support arbitrary builtin types like L{type}.
        L{banana.Banana.sendEncoded} raises L{banana.BananaError} if called
        with an instance of L{type}.
        z
builtins.typeN)rA�typer2rrr�test_unsupportedBuiltinTypewsz'BananaTests.test_unsupportedBuiltinTypecCs|�t�td�dS)z�
        Banana does not support arbitrary user-defined types (such as those
        defined with the ``class`` statement).  ``Banana.sendEncoded`` raises
        ``BananaError`` if called with an instance of such a type.
        z
.MathTestsN)rArrr2rrr�test_unsupportedUserType�sz$BananaTests.test_unsupportedUserTypecCs0|�tj|jj|�}|�d|�d�t|��dS)a�
        Assert that L{banana.Banana.sendEncoded} raises L{banana.BananaError}
        if called with the given object.

        @param obj: Some object that Banana does not support.
        @param name: The name of the type of the object.

        @raise: The failure exception is raised if L{Banana.sendEncoded} does
            not raise L{banana.BananaError} or if the message associated with the
            exception is not formatted to include the type of the unsupported
            object.
        zBanana cannot send z objectsN)�assertRaisesr�BananaErrorr.r%�assertIn�str)rr(�name�excrrrrA�s
z BananaTests._unsupportedTypeTestcCs>|j�d�|j�|j���|�|jd�|�|jt�dS)z�
        A positive integer less than 2 ** 32 should round-trip through
        banana without changing value and should come out represented
        as an C{int} (regardless of the type which was encoded).
        i�'N)	r.r%r=r,rrr4�assertIsInstance�intr2rrr�test_int�szBananaTests.test_intcCs(|jj}|d}d|d}|d}|S)N���)r.�prefixLimit)r�bytes�bits�largest�smallestrrr�_getSmallest�s
zBananaTests._getSmallestcC� |��}|�tj|jj|�dS)zz
        Test that a long above the implementation-specific limit is rejected
        as too large to be encoded.
        N)rWrFrrGr.r%)rrVrrr�test_encodeTooLargeLong��z#BananaTests.test_encodeTooLargeLongcC�j|��}|j�|jjd�|j�|�|j��}|j�d�|j�|jjd�|�t	j
|jj|�dS)zz
        Test that a long above the implementation specific limit is rejected
        as too large to be decoded.
        rPrN)rWr.�setPrefixLimitrRr%r,r�truncaterFrrGr=)rrV�encodedrrr�test_decodeTooLargeLong��
z#BananaTests.test_decodeTooLargeLongcCs
|��Sr5)rWr2rrr�_getLargest�s
zBananaTests._getLargestcCrX)z�
        Test that a negative long below the implementation-specific limit is
        rejected as too small to be encoded.
        N)rarFrrGr.r%)rrUrrr�test_encodeTooSmallLong�rZz#BananaTests.test_encodeTooSmallLongcCr[)z�
        Test that a negative long below the implementation specific limit is
        rejected as too small to be decoded.
        rPrN)rar.r\rRr%r,rr]rFrrGr=)rrUr^rrr�test_decodeTooSmallLong�r`z#BananaTests.test_decodeTooSmallLongcC�0|j�d�|j�|j���|�|jd�dS)Ni��r.r%r=r,rrr4r2rrr�test_integer�r?zBananaTests.test_integercCrd)Ni	���rer2rrr�
test_negative�r?zBananaTests.test_negativecCrd)Ng��@rer2rrr�
test_float�r?zBananaTests.test_floatc	CsXddddgddgddd	d
dggdggg}|j�|�|j�|j���|�|j|�dS)
NrQrP����>@皙���D@��six�seven�eight�	�
re�r�foorrr�	test_list�s�
zBananaTests.test_listcCslddddgddgddd	d
dggdgtjdtjdtjd
g
}|j�|�|�|j���|�|j|�dS)zj
        Test feeding the data byte per byte to the receiver. Normally
        data is not split.
        rQrPrirjrkrlrmrnrorprqrr���N)	�sys�maxsizer.r%�feedr,rrr4rsrrr�test_partial�s�
zBananaTests.test_partialcCst|�D]}|j�|�qdS)z�
        Feed the data byte per byte to the receiver.

        @param data: The bytes to deliver.
        @type data: L{bytes}
        N)rr.r=)r�data�byterrrrys�zBananaTests.feedcC�d}|�tj|j|�dS)Ns��rFrrGry�rr{rrr�test_oversizedList�zBananaTests.test_oversizedListcCr})Ns�r~rrrr�test_oversizedString!r�z BananaTests.test_oversizedStringcCs.d}z	|j�|�WdStjyYdSw)Ns�)r.r=rrG)r�crashStringrrr�test_crashString&s�zBananaTests.test_crashStringcCrd)N��rer2rrr�test_crashNegativeLong9sz"BananaTests.test_crashNegativeLongcCsPd}d}d}|�|�|d�d|�|�|�|d�d|�|�|�|d�d	|�d
}|�|�|d�d|�|�|�|d�d|�|�|�|d
�d|�d}|�|�|d�d|�|�|�|d�d	|�|�|�|d�d�d}|�|�|d�d|�|�|�|d�d|�|�|�|d
�d|�dS)z�
        Test that integers below the maximum C{INT} token size cutoff are
        serialized as C{INT} or C{NEG} and that larger integers are
        serialized as C{LONGINT} or C{LONGNEG}.
        i���r�s�rP�}rQ�~r�s���ri�s�s�s��N)rr*)r�	baseIntIn�	baseNegIn�
baseIntOut�baseLongIntOut�
baseNegOut�baseLongNegOutrrr�test_sizedIntegerTypesEs$z"BananaTests.test_sizedIntegerTypesN)rrrr:r>rBrDrErArNrWrYr_rarbrcrfrgrhrurzryr�r�r�r�r�rrrrr<fs2	
r<c@sZeZdZdZdZeejjef�ej	Z
ed�ej	Zdd�Zdd�Z
dd	�Zd
d�ZdS)
�DialectTestsz2
    Tests for Banana's handling of dialects.
    sremote)�zcCs|�t|jj|j�dS)z|
        If no dialect has been selected and a PB VOCAB item is received,
        L{NotImplementedError} is raised.
        N)rF�NotImplementedErrorr.r=�legalPbItemr2rrr�test_dialectNotSetlszDialectTests.test_dialectNotSetcCs.t|jd�|j�|j�|�|j|j�dS)zS
        If the PB dialect has been selected, a PB VOCAB item is accepted.
        �pbN)r"r.r=r�rr4�vocabr2rrr�test_receivePbsszDialectTests.test_receivePbcCs$t|jd�|�t|jj|j�dS)z�
        If the PB dialect has been selected and an unrecognized PB VOCAB item
        is received, L{banana.Banana.dataReceived} raises L{KeyError}.
        r�N)r"r.rF�KeyErrorr=�
illegalPbItemr2rrr�test_receiveIllegalPb{sz"DialectTests.test_receiveIllegalPbcCs2t|jd�|j�|j�|�|j|j���dS)zl
        if pb dialect is selected, the sender must be able to send things in
        that dialect.
        r�N)r"r.r%r�rr�r,rr2rrr�test_sendPb�szDialectTests.test_sendPbN)rrrr:r�rSrr;�outgoingVocabulary�VOCABr�r�r�r�r�r�rrrrr�csr�c@seZdZdZdd�ZdS)�GlobalCoderTestszM
    Tests for the free functions L{banana.encode} and L{banana.decode}.
    cCs0d}|�tjtj|�d}|�t�|�d�dS)zJ
        Calls to L{banana.decode} are independent of each other.
        sB�s�rQN)rFrrG�decoder)r�undecodable�	decodablerrr�test_statelessDecode�sz%GlobalCoderTests.test_statelessDecodeN)rrrr:r�rrrrr��sr�)rw�	functoolsrr,r�twisted.internetrr�twisted.pythonr�twisted.python.compatr�twisted.spreadr�twisted.test.proto_helpersr	�twisted.trial.unittestr
�_maxintrr"r*r+r<r�r�rrrr�<module>s$~*

Anon7 - 2022
AnonSec Team