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/test/__pycache__/test_compat.cpython-38.pyc
U

��W[^r�@sXdZddlmZmZddlZddlZddlZddlZddlZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"ddl#m$Z$ddl%m&Z&Gdd	�d	e
j'�Z(Gd
d�de
j'�Z)Gdd
�d
e
j'�Z*e�rde*_+Gdd�de
j'�Z,Gdd�de
j'�Z-Gdd�de
j'�Z.eGdd�de/��Z0Gdd�de
j'�Z1Gdd�de
j'�Z2e�s|de2_+Gdd�de
j'�Z3Gdd�de
j'�Z4Gd d!�d!e
j'�Z5Gd"d#�d#e
j'�Z6Gd$d%�d%e
j'�Z7Gd&d'�d'e
j8�Z9Gd(d)�d)e
j8�Z:Gd*d+�d+e
j8�Z;Gd,d-�d-e
j8�Z<Gd.d/�d/e
j8�Z=Gd0d1�d1e
j8�Z>Gd2d3�d3e
j'�Z?dS)4z%
Tests for L{twisted.python.compat}.
�)�division�absolute_importN)�unittest)�reduce�execfile�_PY3�_PYPY�
comparable�cmp�nativeString�
networkString�unicode�
lazyByteSlice�reraise�NativeStringIO�	iterbytes�
intToBytes�ioType�bytesEnviron�	iteritems�_coercedUnicode�unichr�	raw_input�
_bytesRepr�_get_async_param)�FilePath)�platformc@sveZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
erZde_de
_de	_dd�Z
dd�Zdd�ZdS)�IOTypeTestsz?
    Test cases for determining a file-like object's type.
    cCs|�tt���t�dS)z=
        An L{io.StringIO} accepts and returns text.
        N)�assertEqualr�io�StringIO�
unicodeCompat��self�r$�:/usr/lib/python3/dist-packages/twisted/test/test_compat.py�test_3StringIOszIOTypeTests.test_3StringIOcCs|�tt���t�dS)z=
        An L{io.BytesIO} accepts and returns bytes.
        N)rrr�BytesIO�bytesr"r$r$r%�
test_3BytesIO&szIOTypeTests.test_3BytesIOc	Cs0t�|��d��}|�t|�t�W5QRXdS)zT
        A file opened via 'io.open' in text mode accepts and returns text.
        �wN)r�open�mktemprrr!�r#�fr$r$r%�test_3openTextMode-szIOTypeTests.test_3openTextModec	Cs0t�|��d��}|�t|�t�W5QRXdS)zW
        A file opened via 'io.open' in binary mode accepts and returns bytes.
        �wbN)rr+r,rrr(r-r$r$r%�test_3openBinaryMode5sz IOTypeTests.test_3openBinaryModecCs.Gdd�dt�}|�t||��d��t�dS)z�
        The special built-in console file in Python 2 which has an 'encoding'
        attribute should qualify as a special type, since it accepts both bytes
        and text faithfully.
        c@seZdZdZdZdS)z7IOTypeTests.test_2openTextMode.<locals>.VerySpecificLiea3
            In their infinite wisdom, the CPython developers saw fit not to
            allow us a writable 'encoding' attribute on the built-in 'file'
            type in Python 2, despite making it writable in C with
            PyFile_SetEncoding.

            Pretend they did not do that.
            �utf-8N)�__name__�
__module__�__qualname__�__doc__�encodingr$r$r$r%�VerySpecificLieCsr8r0N)�filerrr,Z
basestring)r#r8r$r$r%�test_2openTextMode=s�zIOTypeTests.test_2openTextModecCs@ddlm}ddlm}|�t|��t�|�t|��t�dS)zV
        Python 2's L{StringIO} and L{cStringIO} modules are both binary I/O.
        r)r N)�	cStringIOr rrr()r#r;r r$r$r%�test_2StringIORszIOTypeTests.test_2StringIOc	Cs.t|��d��}|�t|�t�W5QRXdS)zX
        The normal 'open' builtin in Python 2 will always result in bytes I/O.
        r*N)r+r,rrr(r-r$r$r%�test_2openBinaryMode\sz IOTypeTests.test_2openBinaryModez'The 'file' type is no longer available.z$'io.open' is now the same as 'open'.zHThe 'StringIO' and 'cStringIO' modules were subsumed by the 'io' module.c	Cs0t�|��d��}|�t|�t�W5QRXdS)z�
        The L{codecs} module, oddly, returns a file-like object which returns
        bytes when not passed an 'encoding' argument.
        r0N)�codecsr+r,rrr(r-r$r$r%�test_codecsOpenBytesjsz IOTypeTests.test_codecsOpenBytesc	Cs4tj|��ddd��}|�t|�t�W5QRXdS)zY
        When passed an encoding, however, the L{codecs} module returns unicode.
        r0r2)r7N)r>r+r,rrr!r-r$r$r%�test_codecsOpenTextsszIOTypeTests.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�objectr!r"r$r$r%�test_defaultToText{szIOTypeTests.test_defaultToTextN)r3r4r5r6r&r)r/r1r:r<r=r�skipr?r@rBr$r$r$r%rs
	rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�CompatTestszy
    Various utility functions in C{twisted.python.compat} provide same
    functionality as modern Python variants.
    cCs�t�}|�d�|�d�|�d�t|�}|��|�|dddg�|�d�t|�}|��|�|ddg�|�d�tddg�}|�|�}t|�}|��|�|ddddg�dS)zG
        L{set} should behave like the expected set interface.
        �b�c�a�d�r�sN)�set�add�list�sortr�remove�discard�union�r#rGrErHr$r$r%�test_set�s"





zCompatTests.test_setcCsntddg�}|�tt|d�|�t|�ddg�tddg�}|�|�}t|�}|��|�|ddddg�dS)zS
        L{frozenset} should behave like the expected frozenset interface.
        rGrErLrIrJN)	�	frozenset�assertRaises�AttributeError�getattrr�sortedrQrMrNrRr$r$r%�test_frozenset�s
zCompatTests.test_frozensetc
CsF|�dtdd�dddddg��|�d	td
d�dddddgd��dS)zB
        L{reduce} should behave like the builtin reduce.
        �cSs||S�Nr$��x�yr$r$r%�<lambda>��z)CompatTests.test_reduce.<locals>.<lambda>������cSs||Sr[r$r\r$r$r%r_�r`N)rrr"r$r$r%�test_reduce�s zCompatTests.test_reduceN)r3r4r5r6rSrYrgr$r$r$r%rD�srDc@s eZdZdZdd�Zdd�ZdS)�	IPv6TestszE
    C{inet_pton} and C{inet_ntop} implementations support IPv6.
    cs�ddlm��fdd�}�fdd�}|�d|d��|�d|d	��|�d
|d��|�d|d
��|�d|d��|�d|d��|�d|d��|�d|d��dS)Nr��	inet_ntopcs�tj|�Sr[��socketZAF_INET6�rGrir$r%r_�r`z$IPv6Tests.testNToP.<locals>.<lambda>cs�tj|�Sr[�rlZAF_INETrmrir$r%r_�r`�::��::1�z!aef:b01:506:1001:ffff:9997:55:170u
ïÿÿ™—Upz1.0.1.0zz
170.85.170.85uªUªUz255.255.255.255uÿÿÿÿz100::zz100::1z)�twisted.python.compatrjr)r#r.�gr$rir%�testNToP�s�zIPv6Tests.testNToPcs�ddlm��fdd�}�fdd�}|�d|d��|�d|d	��|�d
|d��|�d|d
��|�d|d��|�d|d��|�d|d��|�d|d��|�d|d��|�d|d��|�d|d��dD]}|�t||�q�dS)z�
        L{twisted.python.compat.inet_pton} parses IPv4 and IPv6 addresses in a
        manner similar to that of L{socket.inet_pton}.
        r��	inet_ptoncs�tj|�Sr[rkrmrvr$r%r_�r`z$IPv6Tests.testPToN.<locals>.<lambda>cs�tj|�Sr[rnrmrvr$r%r_�r`zz0.0.0.0uÿÿz255.0.255.0uªªªªz170.170.170.170rproz0::0zz1::uEïvËVï¯ë¬$®®z$45ef:76cb:1a:56ef:afeb:bac:1924:aeaez(45ef:76cb:1a:56ef:afeb:bac:1924:aeae%en0rrrqzz	::1.2.3.4uÿz1:2:3:4:5:6:1.2.3.255)
z1:2:3:4:5:6:7:8:z:1:2:3:4:5:6:7:8z1::2::3z1:::3z:::z1:2z::1.2z	1.2.3.4::z%abcd:1.2.3.4:abcd:abcd:abcd:abcd:abcdz*1234:1.2.3.4:1234:1234:1234:1234:1234:1234z1.2.3.4�z%eth0N)rsrwrrU�
ValueError)r#r.rtZbadaddrr$rvr%�testPToN�s2���zIPv6Tests.testPToNN)r3r4r5r6rurzr$r$r$r%rh�srhz7These tests are only relevant to old versions of Pythonc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�ExecfileCompatTestszE
    Tests for the Python 3-friendly L{execfile} implementation.
    c	Cs<|��}t|d��}|�|�d��W5QRXt|�d��S)zo
        Write L{content} to a new temporary file, returning the L{FilePath}
        for the new file.
        r0�asciir2)r,r+�write�encoder)r#Zcontent�pathr.r$r$r%�writeScriptszExecfileCompatTests.writeScriptcCs2|�d�}ddi}t|j|�|�d|d�dS)zX
        L{execfile} executes the specified file in the given global namespace.
        �	foo += 1
�foorarbN�r�rrr)r#�script�globalNamespacer$r$r%�test_execfileGlobalss
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.
        r�r��
��Nr�)r#r�r�ZlocalNamespacer$r$r%�test_execfileGlobalsAndLocalss
z1ExecfileCompatTests.test_execfileGlobalsAndLocalscCs@dD]6}|�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'r�NZokayr�)r#Z
lineEndingr�r�r$r$r%�test_execfileUniversalNewlines's
z2ExecfileCompatTests.test_execfileUniversalNewlinesN)r3r4r5r6r�r�r�r�r$r$r$r%r{s


r{c@s eZdZdZdd�Zdd�ZdS)�PY3Testsz2
    Identification of Python 2 vs. Python 3.
    cCstj�d�r|�t�dS)z0
        On Python 2, C{_PY3} is False.
        z2.N)�sys�version�
startswith�assertFalserr"r$r$r%�test_python29szPY3Tests.test_python2cCstj�d�r|�t�dS)z/
        On Python 3, C{_PY3} is True.
        z3.N)r�r�r��
assertTruerr"r$r$r%�test_python3AszPY3Tests.test_python3N)r3r4r5r6r�r�r$r$r$r%r�4sr�c@seZdZdZdd�ZdS)�PYPYTestz!
    Identification of PyPy.
    cCs$dtjkr|�t�n
|�t�dS)z,
        On PyPy, L{_PYPY} is True.
        ZPyPyN)r�r�r�rr�r"r$r$r%�	test_PYPYOs
zPYPYTest.test_PYPYN)r3r4r5r6r�r$r$r$r%r�Jsr�c@s eZdZdZdd�Zdd�ZdS)�
ComparablezE
    Objects that can be compared to each other, but not others.
    cCs
||_dSr[)�value)r#r�r$r$r%�__init___szComparable.__init__cCst|t�stSt|j|j�Sr[)�
isinstancer��NotImplementedr
r�)r#�otherr$r$r%�__cmp__cs
zComparable.__cmp__N)r3r4r5r6r�r�r$r$r$r%r�Zsr�c@s@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.
        rarbN�r�r�r�r"r$r$r%�
test_equalityoszComparableTests.test_equalitycCs0|�td�td�k�|�td�td�k�dS)zq
        Instances of a class that is decorated by C{comparable} support
        inequality comparisons.
        rarbN)r�r�r�r"r$r$r%�test_nonEqualityysz 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.
        rbrarrcNr�r"r$r$r%�test_greaterThan�sz 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.
        rarbrrcNr�r"r$r$r%�test_greaterThanOrEqual�sz'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.
        rrcrbNr�r"r$r$r%�
test_lessThan�szComparableTests.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.
        rcrrbNr�r"r$r$r%�test_lessThanOrEqual�sz$ComparableTests.test_lessThanOrEqualN)
r3r4r5r6r�r�r�r�r�r�r$r$r$r%r�js

	
	r�c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�Python3ComparableTestsz;
    Python 3-specific functionality of C{comparable}.
    cCs|�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.
        raN)rr��__eq__rAr�r"r$r$r%�test_notImplementedEquals�sz0Python3ComparableTests.test_notImplementedEqualscCs|�td��t��t�dS)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.
        raN)rr��__ne__rAr�r"r$r$r%�test_notImplementedNotEquals�sz3Python3ComparableTests.test_notImplementedNotEqualscCs|�td��t��t�dS)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.
        raN)rr��__gt__rAr�r"r$r$r%�test_notImplementedGreaterThan�sz5Python3ComparableTests.test_notImplementedGreaterThancCs|�td��t��t�dS)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.
        raN)rr��__lt__rAr�r"r$r$r%�test_notImplementedLessThan�sz2Python3ComparableTests.test_notImplementedLessThancCs|�td��t��t�dS)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.
        raN)rr��__ge__rAr�r"r$r$r%�$test_notImplementedGreaterThanEquals�sz;Python3ComparableTests.test_notImplementedGreaterThanEqualscCs|�td��t��t�dS)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.
        raN)rr��__le__rAr�r"r$r$r%�!test_notImplementedLessThanEquals�sz8Python3ComparableTests.test_notImplementedLessThanEqualsN)
r3r4r5r6r�r�r�r�r�r�r$r$r$r%r��s					r�zPython 3 only.c@s(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.
        rGrraN�rr
r"r$r$r%�test_equals�szCmpTests.test_equalscCs(|�tdd�d�|�tdd�d�dS)zS
        L{cmp} returns 1 if its first argument is bigger than its second.
        rdrra�z�aNr�r"r$r$r%r��szCmpTests.test_greaterThancCs(|�tdd�d�|�tdd�d�dS)zU
        L{cmp} returns -1 if its first argument is smaller than its second.
        g�������?gffffff@���r��dNr�r"r$r$r%r�szCmpTests.test_lessThanN)r3r4r5r6r�r�r�r$r$r$r%r��s	r�c@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�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�assertIsInstance�str)r#Zoriginal�expectedr$r$r%�assertNativeStringszStringTests.assertNativeStringcCs|�ttd�dS)zj
        C{nativeString} raises a C{UnicodeError} if input bytes are not ASCII
        decodable.
        ��N�rU�UnicodeErrorrr"r$r$r%�test_nonASCIIBytesToStringsz&StringTests.test_nonASCIIBytesToStringcCs|�ttd�dS)zk
        C{nativeString} raises a C{UnicodeError} if input Unicode is not ASCII
        encodable.
        uሴNr�r"r$r$r%�test_nonASCIIUnicodeToString!sz(StringTests.test_nonASCIIUnicodeToStringcCs|�dd�dS)z
        C{nativeString} converts bytes to the native string format, assuming
        an ASCII encoding if applicable.
        shello�helloN�r�r"r$r$r%�test_bytesToString)szStringTests.test_bytesToStringcCs|�dd�dS)z�
        C{nativeString} converts unicode to the native string format, assuming
        an ASCII encoding if applicable.
        zGood dayNr�r"r$r$r%�test_unicodeToString1sz StringTests.test_unicodeToStringcCs|�dd�dS)zJ
        C{nativeString} leaves native strings as native strings.
        zHello!Nr�r"r$r$r%�test_stringToString9szStringTests.test_stringToStringcCs|�ttd�dS)zu
        C{nativeString} raises a C{TypeError} if given an object that is not a
        string of some sort.
        raN)rU�	TypeErrorrr"r$r$r%�test_unexpectedType@szStringTests.test_unexpectedTypecCstr
t}nt}|�t|�dS)zR
        C{compat.unicode} is C{str} on Python 3, C{unicode} on Python 2.
        N)rr�r
�assertIsr!)r#r�r$r$r%�test_unicodeHszStringTests.test_unicodecCs.t�}|�d�|�d�|�|��d�dS)zg
        L{NativeStringIO} is a file-like object that stores native strings in
        memory.
        r�z therezhello thereN)rr}r�getvaluer-r$r$r%�test_nativeStringIOSs

zStringTests.test_nativeStringION)
r3r4r5r6r�r�r�r�r�r�r�r�r�r$r$r$r%r�
s
r�c@sXeZdZdZdd�Zdd�Zer,de_e_dd�Zd	d
�Z	esLde_e	_dd
�Z
dS)�NetworkStringTestsz%
    Tests for L{networkString}.
    cCs|�dtd��dS)zU
        L{networkString} returns a C{bytes} object passed to it unmodified.
        �fooN�rrr"r$r$r%�
test_bytescszNetworkStringTests.test_bytescCs|�ttd�d��dS)z�
        L{networkString} raises C{UnicodeError} if passed a C{bytes} instance
        containing bytes not used by ASCII.
        �☃r2N)rUr�rr~r"r$r$r%�test_bytesOutOfRangejs
�z'NetworkStringTests.test_bytesOutOfRangez:Bytes behavior of networkString only provided on Python 2.cCs|�dtd��dS)zu
        L{networkString} returns a C{unicode} object passed to it encoded into
        a C{bytes} instance.
        r�r�Nr�r"r$r$r%r�vszNetworkStringTests.test_unicodecCs|�ttd�dS)z�
        L{networkString} raises L{UnicodeError} if passed a C{unicode} instance
        containing characters not encodable in ASCII.
        r�N)rUr�rr"r$r$r%�test_unicodeOutOfRange~s
�z)NetworkStringTests.test_unicodeOutOfRangez<Unicode behavior of networkString only provided on Python 3.cCs6|�ttt��tr$|�ttd�n|�ttd�dS)z�
        L{networkString} raises L{TypeError} if passed a non-string object or
        the wrong type of string object.
        �bytes�textN)rUr�rrArr"r$r$r%�test_nonString�sz!NetworkStringTests.test_nonStringN)r3r4r5r6r�r�rrCr�r�r�r$r$r$r%r�_s�
�
r�c@s eZdZdZdd�Zdd�ZdS)�ReraiseTestszH
    L{reraise} re-raises exceptions on both Python 2 and Python 3.
    c	Cs�zddWnt��\}}}YnXzt|d�WnRt��\}}}|�|t�|�||�|�t�|�dt�|�d�YnX|�	d�dS)z�
        Calling L{reraise} with an exception instance and a traceback of
        L{None} re-raises it with a new traceback.
        rarNr��The exception was not raised.)
r��exc_inforr�ZeroDivisionErrorr�ZassertNotEqual�	traceback�	format_tb�fail�r#�typr��tbZtyp2Zvalue2Ztb2r$r$r%�test_reraiseWithNone�s�
z!ReraiseTests.test_reraiseWithNonec	Cs�zddWnt��\}}}YnXzt||�WnRt��\}}}|�|t�|�||�|�t�|�dt�|�d�YnX|�d�dS)z�
        Calling L{reraise} with an exception instance and a traceback
        re-raises the exception with the given traceback.
        rarr�r�N)	r�r�rrr�r�r�r�r�r�r$r$r%�test_reraiseWithTraceback�s�
z&ReraiseTests.test_reraiseWithTracebackN)r3r4r5r6r�r�r$r$r$r%r��sr�c@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�Python3BytesTestszB
    Tests for L{iterbytes}, L{intToBytes}, L{lazyByteSlice}.
    cCs(d}tt|��}|�|ddddg�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.
        sabcdr��b�cr�N)rMrr)r#�input�resultr$r$r%�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)rrr"r$r$r%�test_intToBytes�sz!Python3BytesTests.test_intToBytescCsd}|�tt|��|�dS)zv
        L{lazyByteSlice} called with some bytes returns a semantically equal
        version of these bytes.
        �123XYZN�rr(r�r#�datar$r$r%�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�rbNr�r�r$r$r%�test_lazyByteSliceOffset�sz*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�rbrcreNr�r�r$r$r%�!test_lazyByteSliceOffsetAndLength�sz3Python3BytesTests.test_lazyByteSliceOffsetAndLengthN)	r3r4r5r6r�r�r�r�r�r$r$r$r%r��s		r�c@s&eZdZdZdd�Ze��r"de_dS)�BytesEnvironTestsz$
    Tests for L{BytesEnviron}.
    cCsPt�}t�}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)rrKrrL�typerrMr()r#r��types�key�valr$r$r%�test_alwaysBytessz"BytesEnvironTests.test_alwaysBytesz+Environment vars are always str on Windows.N)r3r4r5r6r�rZ	isWindowsrCr$r$r$r%r��sr�c@seZdZdZdd�ZdS)�OrderedDictTestsz9
    Tests for L{twisted.python.compat.OrderedDict}.
    cCs\ddlm}||j|jgd�}|�|ddd�|�|ddt�|�t|�d�dS)	zE
        L{twisted.python.compat.OrderedDict} is deprecated.
        r)�OrderedDict�ZoffendingFunctions�messagezhtwisted.python.compat.OrderedDict was deprecated in Twisted 15.5.0: Use collections.OrderedDict instead.�categoryraN)rsr��
flushWarnings�test_deprecatedr�DeprecationWarning�len)r#r��currentWarningsr$r$r%rs�
�z OrderedDictTests.test_deprecatedN)r3r4r5r6rr$r$r$r%r�sr�c@sLeZdZdZdd�Zdd�Zdd�Zdd	�Zes6d
e_	dd�Z
erHd
e
_	d
S)�CoercedUnicodeTestsz=
    Tests for L{twisted.python.compat._coercedUnicode}.
    cCs$td�}|�|d�|�|t�dS)zG
        Unicode strings with ASCII code points are unchanged.
        r�N�rrr�r!�r#r�r$r$r%�test_unicodeASCII.sz%CoercedUnicodeTests.test_unicodeASCIIcCs$td�}|�|d�|�|t�dS)zK
        Unicode strings with non-ASCII code points are unchanged.
        r�Nrrr$r$r%�test_unicodeNonASCII7sz(CoercedUnicodeTests.test_unicodeNonASCIIcCs$td�}|�|d�|�|t�dS)z�
        Native strings with ASCII code points are unchanged.

        On Python 2, this verifies that ASCII-only byte strings are accepted,
        whereas for Python 3 it is identical to L{test_unicodeASCII}.
        r�Nrrr$r$r%�test_nativeASCII@sz$CoercedUnicodeTests.test_nativeASCIIcCs"|�ttd�}|�t|�d�dS)z?
        Byte strings are not accceptable in Python 3.
        r�z!Expected str not b'bytes' (bytes)N)rUr�rrr��r#�excr$r$r%�
test_bytesPy3Lsz!CoercedUnicodeTests.test_bytesPy3z<Bytes behavior of _coercedUnicode only provided on Python 2.cCs|�ttd�dS)zM
        Byte strings with non-ASCII code points raise an exception.
        s☃N)rUr�rr"r$r$r%�test_bytesNonASCIIWsz&CoercedUnicodeTests.test_bytesNonASCIIN)r3r4r5r6rr	r
r
rrCrr$r$r$r%r)s		��rc@seZdZdZdd�ZdS)�UnichrTestsz
    Tests for L{unichr}.
    cCs|�td�d�dS)zX
        unichar exists and returns a unicode string with the given code point.
        i&r�N)rrr"r$r$r%�test_unichrgszUnichrTests.test_unichrN)r3r4r5r6rr$r$r$r%rbsrc@seZdZdZdd�ZdS)�
RawInputTestsz 
    Tests for L{raw_input}
    cCsbGdd�d�}Gdd�d�}|�td|��|�}|�td|�|�td�d�|�|jd�d	S)
z4
        L{twisted.python.compat.raw_input}
        c@seZdZdd�ZdS)z/RawInputTests.test_raw_input.<locals>.FakeStdincSsdS)NzUser input
r$r"r$r$r%�readlinewsz8RawInputTests.test_raw_input.<locals>.FakeStdin.readlineN)r3r4r5rr$r$r$r%�	FakeStdinvsrc@seZdZdZdd�ZdS)z0RawInputTests.test_raw_input.<locals>.FakeStdoutrxcSs|j|7_dSr[)r�r�r$r$r%r}|sz6RawInputTests.test_raw_input.<locals>.FakeStdout.writeN)r3r4r5r�r}r$r$r$r%�
FakeStdoutzsr�stdin�stdoutZPromptz
User inputN)Zpatchr�rrr�)r#rrrr$r$r%�test_raw_inputrszRawInputTests.test_raw_inputN)r3r4r5r6rr$r$r$r%rnsrc@s eZdZdZdd�Zdd�ZdS)�FutureBytesReprTestsz8
    Tests for L{twisted.python.compat._bytesRepr}.
    cCs$|�ttdg�}|�t|�d�dS)z�
        L{twisted.python.compat._bytesRepr} raises a
        L{TypeError} when called any object that is not an instance of
        L{bytes}.
        z	not bytesz Expected bytes not ['not bytes']N)rUr�rZassertEqualsr�rr$r$r%�test_bytesReprNotBytes�sz+FutureBytesReprTests.test_bytesReprNotBytescCs|�td�d�dS)z�
        L{twisted.python.compat._bytesRepr} always prepends
        ``b`` to the returned repr on both Python 2 and 3.
        �zb'\x00'N)rrr"r$r$r%�test_bytesReprPrefix�sz)FutureBytesReprTests.test_bytesReprPrefixN)r3r4r5r6rrr$r$r$r%r�s
rc@s eZdZdZdd�Zdd�ZdS)�GetAsyncParamTestsz=
    Tests for L{twisted.python.compat._get_async_param}
    cCsx|�tdd�d�|�tdd�d�|�tfddiddi��d�|�tfddiddi��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)�isAsyncTrN�async)rrrUr�r"r$r$r%�test_get_async_param�s��z'GetAsyncParamTests.test_get_async_paramcCsF|�tfddiddi��d�|j|jgd�}|�|ddd�dS)	z�
        L{twisted.python.compat._get_async_param} raises a deprecation
        warning if async keyword argument is passed.
        rNrFr�rr�z:'async' keyword argument is deprecated, please use isAsync)rrr� test_get_async_param_deprecation)r#rr$r$r%r �s��
�z3GetAsyncParamTests.test_get_async_param_deprecationN)r3r4r5r6rr r$r$r$r%r�sr)@r6Z
__future__rrrlr�r�rr>Z
twisted.trialrrsrrrrr	r
rrr
r!rrrrrrrrrrrrrZtwisted.python.filepathrZtwisted.python.runtimerZSynchronousTestCaserrDrhrCr{r�r�rAr�r�r�r�r�r�r�r�ZTestCaser�r�rrrrrr$r$r$r%�<module>s@(`j7@4@:U8059