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/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/test/__pycache__/test_compat.cpython-310.pyc
o

�b�F�@szdZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZmZmZddlmZddlmZddlmZmZGdd	�d	e�ZGd
d�de�ZGdd
�d
e�ZGdd�de�ZeGdd�d��Z Gdd�de�Z!Gdd�de�Z"Gdd�de�Z#Gdd�de�Z$Gdd�de�Z%Gdd�de�Z&Gdd�de�Z'Gd d!�d!e�Z(Gd"d#�d#e�Z)dS)$z%
Tests for L{twisted.python.compat}.
�N)�skipIf)
�_PYPY�_get_async_param�bytesEnviron�cmp�
comparable�execfile�
intToBytes�ioType�	iterbytes�
lazyByteSlice�nativeString�
networkString�reraise)�FilePath)�platform)�SynchronousTestCase�TestCasec@�HeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�IOTypeTestsz?
    Test cases for determining a file-like object's type.
    cC�|�tt���t�dS)z=
        An L{io.StringIO} accepts and returns text.
        N)�assertEqualr
�io�StringIO�str��self�r�:/usr/lib/python3/dist-packages/twisted/test/test_compat.py�test_3StringIO)�zIOTypeTests.test_3StringIOcCr)z=
        An L{io.BytesIO} accepts and returns bytes.
        N)rr
r�BytesIO�bytesrrrr�
test_3BytesIO/r zIOTypeTests.test_3BytesIOcC�Dt|��d��}|�t|�t�Wd�dS1swYdS)zT
        A file opened via 'io.open' in text mode accepts and returns text.
        �wN)�open�mktemprr
r�r�frrr�test_3openTextMode5�"�zIOTypeTests.test_3openTextModecCr$)zW
        A file opened via 'io.open' in binary mode accepts and returns bytes.
        �wbN)r&r'rr
r"r(rrr�test_3openBinaryMode<r+z IOTypeTests.test_3openBinaryModecCsFt�|��d��}|�t|�t�Wd�dS1swYdS)z�
        The L{codecs} module, oddly, returns a file-like object which returns
        bytes when not passed an 'encoding' argument.
        r,N)�codecsr&r'rr
r"r(rrr�test_codecsOpenBytesCs"�z IOTypeTests.test_codecsOpenBytescCsJtj|��ddd��}|�t|�t�Wd�dS1swYdS)zY
        When passed an encoding, however, the L{codecs} module returns unicode.
        r,�utf-8)�encodingN)r.r&r'rr
rr(rrr�test_codecsOpenTextKs"�zIOTypeTests.test_codecsOpenTextcCs|�tt��t�dS)zy
        When passed an object about which no sensible decision can be made, err
        on the side of unicode.
        N)rr
�objectrrrrr�test_defaultToTextRszIOTypeTests.test_defaultToTextN)�__name__�
__module__�__qualname__�__doc__rr#r*r-r/r2r4rrrrr$src@� eZdZdZdd�Zdd�ZdS)�CompatTestszy
    Various utility functions in C{twisted.python.compat} provide same
    functionality as modern Python variants.
    cCs�t�}|�d�|�d�|�d�t|�}|��|�|gd��|�d�t|�}|��|�|ddg�|�d�ddh}|�|�}t|�}|��|�|gd��d	S)
zG
        L{set} should behave like the expected set interface.
        �b�c�a)r=r;r<�d�r�s)r=r<r?r@N)�set�add�list�sortr�remove�discard�union�rr=r;r>rrr�test_set`s"





zCompatTests.test_setcCsjtddg�}|�tt|d�|�t|�ddg�tddg�}|�|�}t|�}|��|�|gd��dS)zS
        L{frozenset} should behave like the expected frozenset interface.
        r=r;rBr?r@)r=r;r?r@N)	�	frozenset�assertRaises�AttributeError�getattrr�sortedrGrCrDrHrrr�test_frozensetxs
zCompatTests.test_frozensetN)r5r6r7r8rIrOrrrrr:Zsr:c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ExecfileCompatTestszE
    Tests for the Python 3-friendly L{execfile} implementation.
    cCsP|��}t|d��}|�|�d��Wd�n1swYt|�d��S)zo
        Write L{content} to a new temporary file, returning the L{FilePath}
        for the new file.
        r,�asciiNr0)r'r&�write�encoder)r�content�pathr)rrr�writeScript�s
�zExecfileCompatTests.writeScriptcCs2|�d�}ddi}t|j|�|�d|d�dS)zX
        L{execfile} executes the specified file in the given global namespace.
        �	foo += 1
�foo��N�rVrrUr)r�script�globalNamespacerrr�test_execfileGlobals�s
z(ExecfileCompatTests.test_execfileGlobalscCsL|�d�}ddi}ddi}t|j||�|�d|d�|�d|d�dS)zk
        L{execfile} executes the specified file in the given global and local
        namespaces.
        rWrX�
��Nr[)rr\r]�localNamespacerrr�test_execfileGlobalsAndLocals�s
z1ExecfileCompatTests.test_execfileGlobalsAndLocalscCs@dD]}|�d|�}ddi}t|j|�|�d|d�qdS)z�
        L{execfile} reads in the specified file using universal newlines so
        that scripts written on one platform will work on another.
        )�
�
z
zfoo = 'okay'rXN�okayr[)r�
lineEndingr\r]rrr�test_execfileUniversalNewlines�s�z2ExecfileCompatTests.test_execfileUniversalNewlinesN)r5r6r7r8rVr^rcrhrrrrrP�s
	rPc@seZdZdZdd�ZdS)�PYPYTestz!
    Identification of PyPy.
    cCs&dtjvr|�t�dS|�t�dS)z,
        On PyPy, L{_PYPY} is True.
        �PyPyN)�sys�version�
assertTruer�assertFalserrrr�	test_PYPY�s
zPYPYTest.test_PYPYN)r5r6r7r8rorrrrri�sric@r9)�
ComparablezE
    Objects that can be compared to each other, but not others.
    cCs
||_dS�N)�value)rrrrrr�__init__�s
zComparable.__init__cCst|t�stSt|j|j�Srq)�
isinstancerp�NotImplementedrrr)r�otherrrr�__cmp__�s
zComparable.__cmp__N)r5r6r7r8rsrwrrrrrp�srpc@�@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�ComparableTestszR
    L{comparable} decorated classes emulate Python 2's C{__cmp__} semantics.
    cCs0|�td�td�k�|�td�td�k�dS)zo
        Instances of a class that is decorated by C{comparable} support
        equality comparisons.
        rYrZN�rmrprnrrrr�
test_equality��zComparableTests.test_equalitycCs0|�td�td�k�|�td�td�k�dS)zq
        Instances of a class that is decorated by C{comparable} support
        inequality comparisons.
        rYrZN)rnrprmrrrr�test_nonEquality�r|z ComparableTests.test_nonEqualitycCs0|�td�td�k�|�td�td�k�dS)zs
        Instances of a class that is decorated by C{comparable} support
        greater-than comparisons.
        rZrYr�Nrzrrrr�test_greaterThan��z ComparableTests.test_greaterThancCsF|�td�td�k�|�td�td�k�|�td�td�k�dS)z|
        Instances of a class that is decorated by C{comparable} support
        greater-than-or-equal comparisons.
        rYrZrr~Nrzrrrr�test_greaterThanOrEqual��z'ComparableTests.test_greaterThanOrEqualcCs0|�td�td�k�|�td�td�k�dS)zp
        Instances of a class that is decorated by C{comparable} support
        less-than comparisons.
        rr~rZNrzrrrr�
test_lessThan�r�zComparableTests.test_lessThancCsF|�td�td�k�|�td�td�k�|�td�td�k�dS)zy
        Instances of a class that is decorated by C{comparable} support
        less-than-or-equal comparisons.
        r~rrZNrzrrrr�test_lessThanOrEqualr�z$ComparableTests.test_lessThanOrEqualN)
r5r6r7r8r{r}rr�r�r�rrrrry�s			ryc@rx)�Python3ComparableTestsz;
    Python 3-specific functionality of C{comparable}.
    cC�|�td��t��t�dS)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__eq__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__eq__r3rurrrr�test_notImplementedEquals�z0Python3ComparableTests.test_notImplementedEqualscCr�)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__ne__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__ne__r3rurrrr�test_notImplementedNotEqualsr�z3Python3ComparableTests.test_notImplementedNotEqualscCr�)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__gt__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__gt__r3rurrrr�test_notImplementedGreaterThan$r�z5Python3ComparableTests.test_notImplementedGreaterThancCr�)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__lt__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__lt__r3rurrrr�test_notImplementedLessThan,r�z2Python3ComparableTests.test_notImplementedLessThancCr�)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__ge__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__ge__r3rurrrr�$test_notImplementedGreaterThanEquals4r�z;Python3ComparableTests.test_notImplementedGreaterThanEqualscCr�)z�
        Instances of a class that is decorated by C{comparable} support
        returning C{NotImplemented} from C{__le__} if it is returned by the
        underlying C{__cmp__} call.
        rYN)rrp�__le__r3rurrrr�!test_notImplementedLessThanEquals<r�z8Python3ComparableTests.test_notImplementedLessThanEqualsN)
r5r6r7r8r�r�r�r�r�r�rrrrr�sr�c@�(eZdZdZdd�Zdd�Zdd�ZdS)	�CmpTestszA
    L{cmp} should behave like the built-in Python 2 C{cmp}.
    cCs>|�tdd�d�|�tdd�d�|�tdgdg�d�dS)z5
        L{cmp} returns 0 for equal objects.
        r=rrYN�rrrrrr�test_equalsJszCmpTests.test_equalscC�(|�tdd�d�|�tdd�d�dS)zS
        L{cmp} returns 1 if its first argument is bigger than its second.
        �rrY�z�aNr�rrrrrR�zCmpTests.test_greaterThancCr�)zU
        L{cmp} returns -1 if its first argument is smaller than its second.
        g�������?gffffff@���r��dNr�rrrrr�Yr�zCmpTests.test_lessThanN)r5r6r7r8r�rr�rrrrr�Es
r�c@r)�StringTestsz8
    Compatibility functions and types for strings.
    cCs$|�t|�|�|�t|�t�dS)z�
        Raise an exception indicating a failed test if the output of
        C{nativeString(original)} is unequal to the expected string, or is not
        a native string.
        N)rr
�assertIsInstancer)r�original�expectedrrr�assertNativeStringfszStringTests.assertNativeStringcC�|�ttd�dS)zj
        C{nativeString} raises a C{UnicodeError} if input bytes are not ASCII
        decodable.
        ��N�rK�UnicodeErrorr
rrrr�test_nonASCIIBytesToStringo�z&StringTests.test_nonASCIIBytesToStringcCr�)zk
        C{nativeString} raises a C{UnicodeError} if input Unicode is not ASCII
        encodable.
        uሴNr�rrrr�test_nonASCIIUnicodeToStringvr�z(StringTests.test_nonASCIIUnicodeToStringcCs|�dd�dS)z
        C{nativeString} converts bytes to the native string format, assuming
        an ASCII encoding if applicable.
        shello�helloN�r�rrrr�test_bytesToString}�zStringTests.test_bytesToStringcC�|�dd�dS)z�
        C{nativeString} converts unicode to the native string format, assuming
        an ASCII encoding if applicable.
        zGood dayNr�rrrr�test_unicodeToString�r�z StringTests.test_unicodeToStringcCr�)zJ
        C{nativeString} leaves native strings as native strings.
        zHello!Nr�rrrr�test_stringToString�szStringTests.test_stringToStringcCr�)zu
        C{nativeString} raises a C{TypeError} if given an object that is not a
        string of some sort.
        rYN)rK�	TypeErrorr
rrrr�test_unexpectedType�r�zStringTests.test_unexpectedTypeN)r5r6r7r8r�r�r�r�r�r�r�rrrrr�as	r�c@r�)	�NetworkStringTestsz%
    Tests for L{networkString}.
    cCs|�dtd��dS)zu
        L{networkString} returns a C{unicode} object passed to it encoded into
        a C{bytes} instance.
        sfoorXN)rrrrrr�test_str��zNetworkStringTests.test_strcCr�)z�
        L{networkString} raises L{UnicodeError} if passed a C{unicode} instance
        containing characters not encodable in ASCII.
        u☃N)rKr�rrrrr�test_unicodeOutOfRange�r�z)NetworkStringTests.test_unicodeOutOfRangecCs"|�ttt��|�ttd�dS)z�
        L{networkString} raises L{TypeError} if passed a non-string object or
        the wrong type of string object.
        sbytesN)rKr�rr3rrrr�test_nonString�sz!NetworkStringTests.test_nonStringN)r5r6r7r8r�r�r�rrrrr��s
r�c@r9)�ReraiseTestszH
    L{reraise} re-raises exceptions on both Python 2 and Python 3.
    c	Cs�zddWntyt��\}}}Ynwzt|d�Wn-tyKt��\}}}|�|t�|�||�|�t�	|�dt�	|�d�YdSw|�
d�dS)z�
        Calling L{reraise} with an exception instance and a traceback of
        L{None} re-raises it with a new traceback.
        rYrNr��The exception was not raised.)�
BaseExceptionrk�exc_inforr�ZeroDivisionError�assertIs�assertNotEqual�	traceback�	format_tb�fail�r�typrr�tb�typ2�value2�tb2rrr�test_reraiseWithNone�s �
��z!ReraiseTests.test_reraiseWithNonec	Cs�zddWntyt��\}}}Ynwzt||�Wn-tyKt��\}}}|�|t�|�||�|�t�|�dt�|�d�YdSw|�	d�dS)z�
        Calling L{reraise} with an exception instance and a traceback
        re-raises the exception with the given traceback.
        rYrr�r�N)
r�rkr�rrr�r�r�r�r�r�rrr�test_reraiseWithTraceback�s�&�z&ReraiseTests.test_reraiseWithTracebackN)r5r6r7r8r�r�rrrrr��sr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Python3BytesTestszB
    Tests for L{iterbytes}, L{intToBytes}, L{lazyByteSlice}.
    cCs$d}tt|��}|�|gd��dS)z�
        When L{iterbytes} is called with a bytestring, the returned object
        can be iterated over, resulting in the individual bytes of the
        bytestring.
        sabcd)r��b�cr�N)rCrr)r�input�resultrrr�test_iteration�sz Python3BytesTests.test_iterationcCs|�td�d�dS)z�
        When L{intToBytes} is called with an integer, the result is an
        ASCII-encoded string representation of the number.
        ��s213N)rr	rrrr�test_intToBytes�r�z!Python3BytesTests.test_intToBytescCsd}|�tt|��|�dS)zv
        L{lazyByteSlice} called with some bytes returns a semantically equal
        version of these bytes.
        �123XYZN�rr"r�r�datarrr�test_lazyByteSliceNoOffset�sz,Python3BytesTests.test_lazyByteSliceNoOffsetcCs&d}|�tt|d��|dd��dS)z�
        L{lazyByteSlice} called with some bytes and an offset returns a
        semantically equal version of these bytes starting at the given offset.
        r�rZNr�r�rrr�test_lazyByteSliceOffsets"z*Python3BytesTests.test_lazyByteSliceOffsetcCs(d}|�tt|dd��|dd��dS)z�
        L{lazyByteSlice} called with some bytes, an offset and a length returns
        a semantically equal version of these bytes starting at the given
        offset, up to the given length.
        r�rZr~�Nr�r�rrr�!test_lazyByteSliceOffsetAndLength	s$z3Python3BytesTests.test_lazyByteSliceOffsetAndLengthN)	r5r6r7r8r�r�r�r�r�rrrrr��s
r�c@s&eZdZdZee��d�dd��ZdS)�BytesEnvironTestsz$
    Tests for L{BytesEnviron}.
    z+Environment vars are always str on Windows.cCsPt�}t�}|��D]\}}|�t|��|�t|��q
|�t|�tg�dS)zz
        The output of L{BytesEnviron} should always be a L{dict} with L{bytes}
        values and L{bytes} keys.
        N)rrA�itemsrB�typerrCr")rr��types�key�valrrr�test_alwaysBytessz"BytesEnvironTests.test_alwaysBytesN)r5r6r7r8rr�	isWindowsr�rrrrr�sr�c@r9)�GetAsyncParamTestsz=
    Tests for L{twisted.python.compat._get_async_param}
    cCsx|�tdd�d�|�tdd�d�|�tdddiddi��d�|�tdddiddi��d�|�ttdddi�dS)z�
        L{twisted.python.compat._get_async_param} uses isAsync by default,
        or deprecated async keyword argument if isAsync is None.
        F)�isAsyncTr�N�asyncr)rrrKr�rrrr�test_get_async_param-s
z'GetAsyncParamTests.test_get_async_paramcCsF|�td	ddiddi��d�|j|jgd�}|�|ddd�dS)
z�
        L{twisted.python.compat._get_async_param} raises a deprecation
        warning if async keyword argument is passed.
        r�Nr�F)�offendingFunctionsr�messagez:'async' keyword argument is deprecated, please use isAsyncr)rr�
flushWarnings� test_get_async_param_deprecation)r�currentWarningsrrrr�8s�
�z3GetAsyncParamTests.test_get_async_param_deprecationN)r5r6r7r8r�r�rrrrr�(sr�)*r8r.rrkr��unittestr�twisted.python.compatrrrrrrr	r
rrr
rr�twisted.python.filepathr�twisted.python.runtimer�twisted.trial.unittestrrrr:rPrirpryr�r�r�r�r�r�r�r�rrrr�<module>s2<6-0:68.0

Anon7 - 2022
AnonSec Team