+
    DfjA                        R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtH	t	H
t
HtHtHtHtHtHtHtHtHt ^ RIHt ^ RIHt ^ RIHtHt  ! R R]4      t ! R	 R
]4      t ! R R]4      t ! R R]4      t] ! R R4      4       t ! R R]4      t  ! R R]4      t! ! R R]4      t" ! R R]4      t# ! R R]4      t$ ! R R]4      t% ! R R]4      t& ! R R ]4      t'R# )!z%
Tests for L{twisted.python.compat}.
N)skipIf)_PYPYbytesEnvironcmp
comparableexecfile
intToBytesioType	iterbyteslazyByteSlicenativeStringnetworkStringreraise)FilePath)platform)SynchronousTestCaseTestCasec                   N   a  ] tR t^#t o RtR tR tR tR tR t	R t
R tR	tV tR
# )IOTypeTestsz7
Test cases for determining a file-like object's type.
c                j    V P                  \        \        P                  ! 4       4      \        4       R# )z-
An L{io.StringIO} accepts and returns text.
N)assertEqualr	   ioStringIOstrselfs   &:/usr/lib/python3/dist-packages/twisted/test/test_compat.pytest_3StringIOIOTypeTests.test_3StringIO(   s     	.4    c                j    V P                  \        \        P                  ! 4       4      \        4       R# )z-
An L{io.BytesIO} accepts and returns bytes.
N)r   r	   r   BytesIObytesr   s   &r   test_3BytesIOIOTypeTests.test_3BytesIO.   s     	

-u5r   c                    \        V P                  4       R4      ;_uu_ 4       pV P                  \        V4      \        4       RRR4       R#   + '       g   i     R# ; i)zD
A file opened via 'io.open' in text mode accepts and returns text.
wN)openmktempr   r	   r   r   fs   & r   test_3openTextModeIOTypeTests.test_3openTextMode4   s<     $++-%%VAY, &%%%    AA	c                    \        V P                  4       R4      ;_uu_ 4       pV P                  \        V4      \        4       RRR4       R#   + '       g   i     R# ; i)zG
A file opened via 'io.open' in binary mode accepts and returns bytes.
wbN)r'   r(   r   r	   r"   r)   s   & r   test_3openBinaryMode IOTypeTests.test_3openBinaryMode;   s<     $++-&&!VAY. '&&&r-   c                    \         P                  ! V P                  4       R4      ;_uu_ 4       pV P                  \	        V4      \
        4       RRR4       R#   + '       g   i     R# ; i)zu
The L{codecs} module, oddly, returns a file-like object which returns
bytes when not passed an 'encoding' argument.
r/   N)codecsr'   r(   r   r	   r"   r)   s   & r   test_codecsOpenBytes IOTypeTests.test_codecsOpenBytesB   s@    
 [[--VAY. .---s    AA)	c                    \         P                  ! V P                  4       RRR7      ;_uu_ 4       pV P                  \	        V4      \
        4       RRR4       R#   + '       g   i     R# ; i)zI
When passed an encoding, however, the L{codecs} module returns unicode.
r/   utf-8)encodingN)r3   r'   r(   r   r	   r   r)   s   & r   test_codecsOpenTextIOTypeTests.test_codecsOpenTextJ   sC     [[w??1VAY, @???s    AA+	c                T    V P                  \        \        4       4      \        4       R# )za
When passed an object about which no sensible decision can be made, err
on the side of unicode.
N)r   r	   objectr   r   s   &r   test_defaultToTextIOTypeTests.test_defaultToTextQ   s    
 	)3/r    N)__name__
__module____qualname____firstlineno____doc__r   r#   r+   r0   r4   r9   r=   __static_attributes____classdictcell____classdict__s   @r   r   r   #   s2     56-//-0 0r   r   c                   0   a  ] tR t^Yt o RtR tR tRtV tR# )CompatTestszm
Various utility functions in C{twisted.python.compat} provide same
functionality as modern Python variants.
c                   \        4       pVP                  R4       VP                  R4       VP                  R4       \        V4      pVP                  4        V P	                  V. RO4       VP                  R4       \        V4      pVP                  4        V P	                  VRR.4       VP                  R4       RR0pVP                  V4      p\        V4      pVP                  4        V P	                  V. R	O4       R# )
z7
L{set} should behave like the expected set interface.
bcadrsN)rN   rL   rM   )rN   rM   rP   rQ   )setaddlistsortr   removediscardunionr   rN   rL   rO   s   &   r   test_setCompatTests.test_set_   s     E	c
	c
	c
G	O,	G	S#J'			##JGGAJG	01r   c                ,   \        RR.4      pV P                  \        \        VR4       V P	                  \        V4      RR.4       \        RR.4      pVP                  V4      p\        V4      pVP                  4        V P	                  V. RO4       R# )zC
L{frozenset} should behave like the expected frozenset interface.
rN   rL   rS   rP   rQ   N)rN   rL   rP   rQ   )		frozensetassertRaisesAttributeErrorgetattrr   sortedrX   rT   rU   rY   s   &   r   test_frozensetCompatTests.test_frozensetw   s|     sCj!.'1e<S#J/sCj!GGAJG	01r   r?   N)	r@   rA   rB   rC   rD   rZ   rb   rE   rF   rG   s   @r   rJ   rJ   Y   s     
202 2r   rJ   c                   <   a  ] tR t^t o RtR tR tR tR tRt	V t
R# )ExecfileCompatTestsz=
Tests for the Python 3-friendly L{execfile} implementation.
c                    V P                  4       p\        VR4      ;_uu_ 4       pVP                  VP                  R4      4       RRR4       \	        VP                  R4      4      #   + '       g   i     L*; i)zW
Write L{content} to a new temporary file, returning the L{FilePath}
for the new file.
r/   asciiNr7   )r(   r'   writeencoder   )r   contentpathr*   s   &&  r   writeScriptExecfileCompatTests.writeScript   sU    
 {{}$GGGNN7+, G,-- s   !A((A8	c                    V P                  R4      pR^/p\        VP                  V4       V P                  ^VR,          4       R# )zH
L{execfile} executes the specified file in the given global namespace.
	foo += 1
fooNrl   r   rk   r   )r   scriptglobalNamespaces   &  r   test_execfileGlobals(ExecfileCompatTests.test_execfileGlobals   s@     !!,/ !*o.OE23r   c                    V P                  R4      pR^
/pR^/p\        VP                  W#4       V P                  ^
VR,          4       V P                  ^VR,          4       R# )zS
L{execfile} executes the specified file in the given global and local
namespaces.
ro   rp   Nrq   )r   rr   rs   localNamespaces   &   r   test_execfileGlobalsAndLocals1ExecfileCompatTests.test_execfileGlobalsAndLocals   s^    
 !!,/ "+o>_U34^E23r   c                    R FN  pV P                  RV,           4      pRR/p\        VP                  V4       V P                  RVR,          4       KP  	  R# )z
L{execfile} reads in the specified file using universal newlines so
that scripts written on one platform will work on another.
zfoo = 'okay'rp   Nokay)
z
rq   )r   
lineEndingrr   rs   s   &   r   test_execfileUniversalNewlines2ExecfileCompatTests.test_execfileUniversalNewlines   sO    
 -J%%nz&ABF$dmOV[[/2V_U%;<	 -r   r?   N)r@   rA   rB   rC   rD   rl   rt   rx   r   rE   rF   rG   s   @r   re   re      s#     .4
4	= 	=r   re   c                   *   a  ] tR t^t o RtR tRtV tR# )PYPYTestz
Identification of PyPy.
c                    R\         P                  9   d   V P                  \        4       R# V P	                  \        4       R# )z
On PyPy, L{_PYPY} is True.
PyPyN)sysversion
assertTruer   assertFalser   s   &r   	test_PYPYPYPYTest.test_PYPY   s*     S[[ OOE"U#r   r?   N)r@   rA   rB   rC   rD   r   rE   rF   rG   s   @r   r   r      s     $ $r   r   c                   0   a  ] tR t^t o RtR tR tRtV tR# )
Comparablez=
Objects that can be compared to each other, but not others.
c                    Wn         R # Nvalue)r   r   s   &&r   __init__Comparable.__init__   s    
r   c                z    \        V\        4      '       g   \        # \        V P                  VP                  4      # r   )
isinstancer   NotImplementedr   r   )r   others   &&r   __cmp__Comparable.__cmp__   s*    %,,!!4::u{{++r   r   N)	r@   rA   rB   rC   rD   r   r   rE   rF   rG   s   @r   r   r      s     , ,r   r   c                   H   a  ] tR t^t o RtR tR tR tR tR t	R t
RtV tR	# )
ComparableTestszJ
L{comparable} decorated classes emulate Python 2's C{__cmp__} semantics.
c                    V P                  \        ^4      \        ^4      8H  4       V P                  \        ^4      \        ^4      8H  4       R# )zW
Instances of a class that is decorated by C{comparable} support
equality comparisons.
Nr   r   r   r   s   &r   test_equalityComparableTests.test_equality   s8     	
1A67A*Q-78r   c                    V P                  \        ^4      \        ^4      8g  4       V P                  \        ^4      \        ^4      8g  4       R# )zY
Instances of a class that is decorated by C{comparable} support
inequality comparisons.
N)r   r   r   r   s   &r   test_nonEquality ComparableTests.test_nonEquality   s8     	A*Q-78
1A67r   c                    V P                  \        ^4      \        ^4      8  4       V P                  \        ^ 4      \        ^4      8  4       R# )z[
Instances of a class that is decorated by C{comparable} support
greater-than comparisons.
Nr   r   s   &r   test_greaterThan ComparableTests.test_greaterThan   8    
 	
1
156AA67r   c                    V P                  \        ^4      \        ^4      8  4       V P                  \        ^4      \        ^4      8  4       V P                  \        ^ 4      \        ^4      8  4       R# )zd
Instances of a class that is decorated by C{comparable} support
greater-than-or-equal comparisons.
Nr   r   s   &r   test_greaterThanOrEqual'ComparableTests.test_greaterThanOrEqual   Q    
 	
1A67
1A67A*Q-78r   c                    V P                  \        ^ 4      \        ^4      8  4       V P                  \        ^4      \        ^ 4      8  4       R# )zX
Instances of a class that is decorated by C{comparable} support
less-than comparisons.
Nr   r   s   &r   test_lessThanComparableTests.test_lessThan   r   r   c                    V P                  \        ^4      \        ^4      8*  4       V P                  \        ^ 4      \        ^4      8*  4       V P                  \        ^4      \        ^ 4      8*  4       R# )za
Instances of a class that is decorated by C{comparable} support
less-than-or-equal comparisons.
Nr   r   s   &r   test_lessThanOrEqual$ComparableTests.test_lessThanOrEqual  r   r   r?   N)r@   rA   rB   rC   rD   r   r   r   r   r   r   rE   rF   rG   s   @r   r   r      s-     988989 9r   r   c                   H   a  ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )Python3ComparableTestsi  z3
Python 3-specific functionality of C{comparable}.
c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __eq__r<   r   r   s   &r   test_notImplementedEquals0Python3ComparableTests.test_notImplementedEquals  %     	A--fh7Hr   c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __ne__r<   r   r   s   &r   test_notImplementedNotEquals3Python3ComparableTests.test_notImplementedNotEquals  r   r   c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __gt__r<   r   r   s   &r   test_notImplementedGreaterThan5Python3ComparableTests.test_notImplementedGreaterThan#  r   r   c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __lt__r<   r   r   s   &r   test_notImplementedLessThan2Python3ComparableTests.test_notImplementedLessThan+  r   r   c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __ge__r<   r   r   s   &r   $test_notImplementedGreaterThanEquals;Python3ComparableTests.test_notImplementedGreaterThanEquals3  r   r   c                r    V P                  \        ^4      P                  \        4       4      \        4       R# )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.
N)r   r   __le__r<   r   r   s   &r   !test_notImplementedLessThanEquals8Python3ComparableTests.test_notImplementedLessThanEquals;  r   r   r?   N)r@   rA   rB   rC   rD   r   r   r   r   r   r   rE   rF   rG   s   @r   r   r     s4     IIIIII Ir   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )CmpTestsiD  z9
L{cmp} should behave like the built-in Python 2 C{cmp}.
c                    V P                  \        RR4      ^ 4       V P                  \        ^^4      ^ 4       V P                  \        ^.^.4      ^ 4       R# )z%
L{cmp} returns 0 for equal objects.
rN   Nr   r   r   s   &r   test_equalsCmpTests.test_equalsI  sJ     	S#*QA&aS1#*r   c                v    V P                  \        ^^ 4      ^4       V P                  \        RR4      ^4       R# )zC
L{cmp} returns 1 if its first argument is bigger than its second.
   z   aNr   r   s   &r   r   CmpTests.test_greaterThanQ  s0     	QA&T4!,r   c                v    V P                  \        RR4      R4       V P                  \        RR4      R4       R# )zE
L{cmp} returns -1 if its first argument is smaller than its second.
g?gffffff@r      dNr   r   s   &r   r   CmpTests.test_lessThanX  s0     	S#+T4"-r   r?   N)
r@   rA   rB   rC   rD   r   r   r   rE   rF   rG   s   @r   r   r   D  s     +-. .r   r   c                   N   a  ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
tV tR# )StringTestsi`  z0
Compatibility functions and types for strings.
c                z    V P                  \        V4      V4       V P                  \        V4      \        4       R# )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)r   r   assertIsInstancer   )r   originalexpecteds   &&&r   assertNativeStringStringTests.assertNativeStringe  s.     	h/:l84c:r   c                <    V P                  \        \        R4       R# )zR
C{nativeString} raises a C{UnicodeError} if input bytes are not ASCII
decodable.
   Nr^   UnicodeErrorr   r   s   &r   test_nonASCIIBytesToString&StringTests.test_nonASCIIBytesToStringn  s    
 	,g>r   c                <    V P                  \        \        R4       R# )zS
C{nativeString} raises a C{UnicodeError} if input Unicode is not ASCII
encodable.
u   ሴNr   r   s   &r   test_nonASCIIUnicodeToString(StringTests.test_nonASCIIUnicodeToStringu  s    
 	,h?r   c                *    V P                  RR4       R# )zg
C{nativeString} converts bytes to the native string format, assuming
an ASCII encoding if applicable.
s   hellohelloNr   r   s   &r   test_bytesToStringStringTests.test_bytesToString|  s    
 	'2r   c                *    V P                  RR4       R# )zi
C{nativeString} converts unicode to the native string format, assuming
an ASCII encoding if applicable.
zGood dayNr   r   s   &r   test_unicodeToString StringTests.test_unicodeToString  s    
 	
J7r   c                *    V P                  RR4       R# )z:
C{nativeString} leaves native strings as native strings.
zHello!Nr   r   s   &r   test_stringToStringStringTests.test_stringToString  s     	(3r   c                <    V P                  \        \        ^4       R# )z]
C{nativeString} raises a C{TypeError} if given an object that is not a
string of some sort.
N)r^   	TypeErrorr   r   s   &r   test_unexpectedTypeStringTests.test_unexpectedType  s    
 	)\15r   r?   N)r@   rA   rB   rC   rD   r   r   r   r   r   r   r   rE   rF   rG   s   @r   r   r   `  s3     ;?@3846 6r   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )NetworkStringTestsi  z
Tests for L{networkString}.
c                <    V P                  R\        R4      4       R# )z]
L{networkString} returns a C{unicode} object passed to it encoded into
a C{bytes} instance.
s   foorp   N)r   r   r   s   &r   test_strNetworkStringTests.test_str  s    
 	u!56r   c                <    V P                  \        \        R4       R# )zw
L{networkString} raises L{UnicodeError} if passed a C{unicode} instance
containing characters not encodable in ASCII.
u   ☃N)r^   r   r   r   s   &r   test_unicodeOutOfRange)NetworkStringTests.test_unicodeOutOfRange  s    
 	,}Er   c                    V P                  \        \        \        4       4       V P                  \        \        R4       R# )zh
L{networkString} raises L{TypeError} if passed a non-string object or
the wrong type of string object.
s   bytesN)r^   r   r   r<   r   s   &r   test_nonString!NetworkStringTests.test_nonString  s*    
 	)]FH=)]H=r   r?   N)
r@   rA   rB   rC   rD   r   r   r  rE   rF   rG   s   @r   r   r     s     7F> >r   r   c                   0   a  ] tR tRt o RtR tR tRtV tR# )ReraiseTestsi  z@
L{reraise} re-raises exceptions on both Python 2 and Python 3.
c                    ^^ ,            \        XR4       V P	                  R4       R#   \          d    \        P                  ! 4       w  rp LEi ; i  \          d    \        P                  ! 4       w  rEpT P                  T\        4       T P                  XT4       T P                  \        P                  ! X4      R,          \        P                  ! T4      R,          4        R# i ; i)zm
Calling L{reraise} with an exception instance and a traceback of
L{None} re-raises it with a new traceback.
NThe exception was not raised.r   )BaseExceptionr   exc_infor   failr   ZeroDivisionErrorassertIsassertNotEqual	traceback	format_tbr   typr   tbtyp2value2tb2s   &      r   test_reraiseWithNone!ReraiseTests.test_reraiseWithNone  s    
	,E
	7E4  II56  	, \\^NC	,  	 #D#T#45MM%(##B'+Y-@-@-Eb-I		!   	+ A #AABC+*C+c                    ^^ ,            \        XX4       V P	                  R4       R#   \          d    \        P                  ! 4       w  rp LEi ; i  \          d    \        P                  ! 4       w  rEpT P                  T\        4       T P                  XT4       T P                  \        P                  ! X4      R,          \        P                  ! T4      R,          4        R# i ; i)zq
Calling L{reraise} with an exception instance and a traceback
re-raises the exception with the given traceback.
r  Nr   )
r  r   r	  r   r
  r   r  r  r  r  r  s   &      r   test_reraiseWithTraceback&ReraiseTests.test_reraiseWithTraceback  s    
	,E	7E2 II56  	, \\^NC	,  	X #D#T#45MM%(Y004R8):M:Mc:RSU:VW		Xr  r?   N)	r@   rA   rB   rC   rD   r  r  rE   rF   rG   s   @r   r  r    s     7*7 7r   r  c                   B   a  ] tR tRt o RtR tR tR tR tR t	Rt
V tR	# )
Python3BytesTestsi  z:
Tests for L{iterbytes}, L{intToBytes}, L{lazyByteSlice}.
c                Z    Rp\        \        V4      4      pV P                  V. RO4       R# )z
When L{iterbytes} is called with a bytestring, the returned object
can be iterated over, resulting in the individual bytes of the
bytestring.
s   abcdN)r      b   cr   )rT   r
   r   )r   inputresults   &  r   test_iteration Python3BytesTests.test_iteration  s)     i&'!9:r   c                <    V P                  \        ^4      R4       R# )zs
When L{intToBytes} is called with an integer, the result is an
ASCII-encoded string representation of the number.
s   213N)r   r   r   s   &r   test_intToBytes!Python3BytesTests.test_intToBytes  s    
 	C&1r   c                R    RpV P                  \        \        V4      4      V4       R# )z^
L{lazyByteSlice} called with some bytes returns a semantically equal
version of these bytes.
   123XYZNr   r"   r   r   datas   & r   test_lazyByteSliceNoOffset,Python3BytesTests.test_lazyByteSliceNoOffset  s#    
 }T23T:r   c                b    RpV P                  \        \        V^4      4      VR,          4       R# )z
L{lazyByteSlice} called with some bytes and an offset returns a
semantically equal version of these bytes starting at the given offset.
r)  :   NNNr*  r+  s   & r   test_lazyByteSliceOffset*Python3BytesTests.test_lazyByteSliceOffset   s)    
 }T156RAr   c           	     d    RpV P                  \        \        V^^4      4      VR,          4       R# )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)  :r0     NNr*  r+  s   & r   !test_lazyByteSliceOffsetAndLength3Python3BytesTests.test_lazyByteSliceOffsetAndLength  s+     }T1a8949Er   r?   N)r@   rA   rB   rC   rD   r#  r&  r-  r1  r5  rE   rF   rG   s   @r   r  r    s+     ;2;BF Fr   r  c                   `   a  ] tR tRt o Rt]! ]P                  ! 4       R4      R 4       tRt	V t
R# )BytesEnvironTestsi  z
Tests for L{BytesEnviron}.
z+Environment vars are always str on Windows.c                   \        4       p\        4       pVP                  4        F9  w  r4VP                  \	        V4      4       VP                  \	        V4      4       K;  	  V P                  \        V4      \        .4       R# )zb
The output of L{BytesEnviron} should always be a L{dict} with L{bytes}
values and L{bytes} keys.
N)r   rR   itemsrS   typer   rT   r"   )r   r"  typeskeyvals   &    r   test_alwaysBytes"BytesEnvironTests.test_alwaysBytes  s\     HCIId3i IId3i  ' 	eug.r   r?   N)r@   rA   rB   rC   rD   r   r   	isWindowsr?  rE   rF   rG   s   @r   r8  r8    s0      H "OP/ Q/r   r8  )(rD   r3   r   r   r  unittestr   twisted.python.compatr   r   r   r   r   r   r	   r
   r   r   r   r   twisted.python.filepathr   twisted.python.runtimer   twisted.trial.unittestr   r   r   rJ   re   r   r   r   r   r   r   r   r  r  r8  r?   r   r   <module>rG     s   

  	 
      - + @30% 30l*2% *2Z-=- -=`$" $ , , ,79) 79t3I0 3Il." .856% 56p>, >8+7& +7\-F+ -F`/ /r   