+
    Dfj                     l   R t ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RIHtHt  ^ RI	H
t
 ^ RIH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# ^ RI$H%t% ^ RI&H't'  ! R R4      t( ! R R]'4      t) ! R R]'4      t* ! R R]%]'4      t+ ! R R]'4      t,R t-R t. ! R R]'4      t/]! ]! R^^^4      4       ! R R4      4       t0 ! R R4      t1]! ]! R^^^ 4      R 4      R*R! l4       t2 ! R" R#]'4      t3 ! R$ R%]'4      t4 ! R& R']'4      t5 ! R( R)]'4      t6R#   ] d    Rt
 EL
i ; i)+zI
Tests for Twisted's deprecation framework, L{twisted.python.deprecate}.
N)normcase)catch_warningssimplefilter)invalidate_caches)Version)	deprecate)DEPRECATION_WARNING_FORMAT_appendToDocstring_fullyQualifiedName_getDeprecationDocstring_getDeprecationWarningString_mutuallyExclusiveArguments_passedArgSpec_passedSignature
deprecateddeprecatedKeywordParameterdeprecatedPropertygetDeprecationWarningString)FilePath)platform)deprecatedattributes)TwistedModulesMixin)SynchronousTestCasec                   0   a  ] tR t^1t o RtR tR tRtV tR# )_MockDeprecatedAttributeze
Mock of L{twisted.python.deprecate._DeprecatedAttribute}.

@ivar value: The value of the attribute.
c                    Wn         R # Nvalueselfr   s   &&D/usr/lib/python3/dist-packages/twisted/python/test/test_deprecate.py__init__!_MockDeprecatedAttribute.__init__8   s    
    c                    V P                   # )z
Get a known value.
r   r    s   &r!   get_MockDeprecatedAttribute.get;   s     zzr$   r   N)	__name__
__module____qualname____firstlineno____doc__r"   r'   __static_attributes____classdictcell____classdict__s   @r!   r   r   1   s      r$   r   c                   H   a  ] tR t^Bt o RtR tR tR tR tR t	R t
RtV tR	# )
ModuleProxyTestsz
Tests for L{twisted.python.deprecate._ModuleProxy}, which proxies
access to module-level attributes, intercepting access to deprecated
attributes and passing through access to normal attributes.
c                    \         P                  ! R4      pVP                  4        F  w  r4\        W#V4       K  	  \        P
                  ! V4      # )z
Create a temporary module proxy object.

@param **kw: Attributes to initialise on the temporary module object

@rtype: L{twistd.python.deprecate._ModuleProxy}
foo)types
ModuleTypeitemssetattrr   _ModuleProxy)r    attrsmodkeyr   s   &,   r!   
_makeProxyModuleProxyTests._makeProxyI   sA     u%++-JCCe$ (%%c**r$   c                    V P                  RR7      pV P                  VP                  R4       V P                  \        \
        VR4       R# )z
Getting a normal attribute on a L{twisted.python.deprecate._ModuleProxy}
retrieves the underlying attribute's value, and raises C{AttributeError}
if a non-existent attribute is accessed.
hello)SOME_ATTRIBUTEDOES_NOT_EXISTN)r>   assertIsrB   assertRaisesAttributeErrorgetattrr    proxys   & r!   test_getattrPassthrough(ModuleProxyTests.test_getattrPassthroughV   s=     w7e**G4.'5:JKr$   c                    V P                  4       p\        P                  VR4      p\        ^*4      VR&   V P	                  VP
                  ^*4       R# )z
Getting an attribute marked as being deprecated on
L{twisted.python.deprecate._ModuleProxy} results in calling the
deprecated wrapper's C{get} method.
_deprecatedAttributesr5   N)r>   object__getattribute__r   assertEqualr5   )r    rI   rM   s   &  r!   test_getattrIntercept&ModuleProxyTests.test_getattrIntercept`   sH     ! & 7 7?V W'?'Ce$B'r$   c                    V P                  4       pV P                  \        \        VR4       V P                  \        \        VR4       R# )zx
Private attributes of L{twisted.python.deprecate._ModuleProxy} are
inaccessible when regular attribute access is used.
_modulerM   N)r>   rE   rF   rG   rH   s   & r!   test_privateAttributes'ModuleProxyTests.test_privateAttributesk   s9    
 !.'5)D.'5:QRr$   c                    V P                  4       p^Vn        V P                  \        P	                  VR4      ^4       V P                  VP                  ^4       R# )zl
Setting attributes on L{twisted.python.deprecate._ModuleProxy} proxies
them through to the wrapped module.
rT   N)r>   rT   assertNotEqualrN   rO   rP   rH   s   & r!   test_setattrModuleProxyTests.test_setattrt   sH    
 !F33E9EqI*r$   c                    V P                  4       p\        P                  VR4      pV P                  \	        V4      R\        V4      P                   RV: R24       R# )z
L{twisted.python.deprecated._ModuleProxy.__repr__} produces a string
containing the proxy type and a representation of the wrapped module
object.
rT   <z module=>N)r>   rN   rO   rP   reprtyper)   )r    rI   
realModules   &  r!   	test_reprModuleProxyTests.test_repr~   sQ     !,,UI>
e$u+*>*>)?x
~UV&WXr$    N)r)   r*   r+   r,   r-   r>   rJ   rQ   rU   rY   ra   r.   r/   r0   s   @r!   r3   r3   B   s1     +L	(S+Y Yr$   r3   c                   B   a  ] tR t^t o RtR tR tR tR tR t	Rt
V tR# )	DeprecatedAttributeTestsz
Tests for L{twisted.python.deprecate._DeprecatedAttribute} and
L{twisted.python.deprecate.deprecatedModuleAttribute}, which issue
warnings for deprecated module-level attributes.
c                ~    \         P                  V n        \         P                  V n        \        R ,           V n        R# )z.fooN)r   versionmessager)   _testModuleNamer&   s   &r!   setUpDeprecatedAttributeTests.setUp   s)    +33+33'&0r$   c                    \        \        P                  R,           V,           \        P                  \        R,           \        P
                  ,           4      # )z:
Create the warning string used by deprecated attributes.
.z: )r   r   r)   rg   r   rh   )r    attrs   &&r!   _getWarningString*DeprecatedAttributeTests._getWarningString   sA     , ))C/$6 ((&-0D0L0LL
 	
r$   c                  a Rp\        \        V^*4       \        P                  ! \        WP                  V P
                  4      oV P                  SP                  V4       V3R lpV! 4        V P                  V P                  .4      pV P                  V^ ,          R,          \        4       V P                  V^ ,          R,          V P                  V4      4       V P                  \        V4      ^4       R# )z
L{twisted.python.deprecate._DeprecatedAttribute} correctly sets its
__name__ to match that of the deprecated attribute and emits a warning
when the original attribute value is accessed.
ANOTHER_DEPRECATED_ATTRIBUTEc                  (   < S P                  4        R # r   )r'   )rn   s   r!   addStackLevelNDeprecatedAttributeTests.test_deprecatedAttributeHelper.<locals>.addStackLevel   s    HHJr$   categoryrh   N)r9   r   r   _DeprecatedAttributerg   rh   rP   r)   flushWarningstest_deprecatedAttributeHelperrD   DeprecationWarningro   len)r    namert   warningsShownrn   s   &   @r!   ry   7DeprecatedAttributeTests.test_deprecatedAttributeHelper   s     .$dB/-- $dll
 	-	 	**D,O,O+PQmA&z24FGq))4d6L6LT6RS]+Q/r$   c                   \         P                   V P                  V P                  .4      pV P	                  \        V4      ^ 4       Rp\        \         V4       V P                  V P                  .4      pV P	                  \        V4      ^4       V P                  V^ ,          R,          \        4       V P	                  V^ ,          R,          V P                  V4      4       R# )z
L{twisted.python.deprecate.deprecatedModuleAttribute} wraps a
module-level attribute in an object that emits a deprecation warning
when it is accessed the first time only, while leaving other unrelated
attributes alone.
DEPRECATED_ATTRIBUTErv   rh   N)
r   ANOTHER_ATTRIBUTErx   test_deprecatedAttributerP   r{   rG   rD   rz   ro   )r    r}   r|   s   &  r!   r   1DeprecatedAttributeTests.test_deprecatedAttribute   s     	..**D,I,I+JK]+Q/% 	$d+**D,I,I+JK]+Q/mA&z24FGq))4d6L6LT6RSr$   c                   \         P                  ! R4      ;\        P                  V P                  &   pV P                  \        P                  P                  V P                  4       \        VR^4       \        VR^4       \        P                  ! \        R^^ ^ 4      RV P                  R4       \        P                  V P                  ,          pV P                  W!4       \        P                  ! \        R^^ ^ 4      RV P                  R4       V P                  V\        P                  V P                  ,          4       R# )z
Deprecating an attribute in a module replaces and wraps that module
instance, in C{sys.modules}, with a
L{twisted.python.deprecate._ModuleProxy} instance but only if it hasn't
already been wrapped.
r5   firstsecondTwistedrh   N)r6   r7   sysmodulesri   
addCleanuppopr9   r   deprecatedModuleAttributer   rX   rD   )r    r<   rI   s   &  r!   test_wrappedModule+DeprecatedAttributeTests.test_wrappedModule   s     382B2B52IID(()C)=)=>Wa Xq!++Iq!Q'D4H4H'	
 D001E'++Iq!Q'D4H4H(	
 	eS[[)=)=>?r$   )ri   rh   rg   N)r)   r*   r+   r,   r-   rj   ro   ry   r   r   r.   r/   r0   s   @r!   re   re      s+     1

04T.@ @r$   re   c                   F   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	# )
ImportedModuleAttributeTestszU
Tests for L{deprecatedModuleAttribute} which involve loading a module via
'import'.
zfrom twisted.python.deprecate import deprecatedModuleAttribute
from incremental import Version

deprecatedModuleAttribute(
    Version('Package', 1, 2, 3), 'message', __name__, 'module')
c                n  a V3R lo\        V P                  4       P                  R4      4      pVP                  4        S! W!4      pV P	                  VP
                  P                  R4      .\        P
                  ,           4       V P                  \        P                  P                  4       4       V# )a  
Create some files in a hierarchy, based on a dictionary describing those
files.  The resulting hierarchy will be placed onto sys.path for the
duration of the test.

@param tree: A dictionary representing a directory structure.  Keys are
    strings, representing filenames, dictionary values represent
    directories, string values represent file contents.

@return: another dictionary similar to the input, with file content
    strings replaced with L{FilePath} objects pointing at where those
    contents are now stored.
c                 0  < / pVP                  4        F~  w  r4V P                  V4      p\        V\        4      '       d   WRV&   VP	                  V4       KC  \        V\
        4      '       d   VP                  4        S! WT4      W#&   Ku  \        R 4      h	  V# )z(only strings and dicts allowed as values)r8   child
isinstancebytes
setContentdictcreateDirectory
ValueError)pathobjdirdictpathdictr=   r   r   makeSomeFiless   &&    r!   r   AImportedModuleAttributeTests.pathEntryTree.<locals>.makeSomeFiles  s    H%mmo
c*eU++$)SM$$U+t,,))+$1%$?HM$%OPP . Or$   utf-8)r   mktempencodemakedirsreplaceSysPathpathdecoder   replaceSysModulesr   copy)r    treebaseresultr   s   &&  @r!   pathEntryTree*ImportedModuleAttributeTests.pathEntryTree   s    	 ,,W56t*TYY--g67#((BCs{{//12r$   c                    V P                  RRV P                  P                  R4      RR//4      pVR,          R,          # )z
Add a sample module and package to the path, returning a L{FilePath}
pointing at the module which will be loadable as C{package.module}.
s   packages   __init__.pyr   	   module.pyr$   )r   _packageInitr   )r    pathss   & r!   simpleModuleEntry.ImportedModuleAttributeTests.simpleModuleEntry  sN    
 """D$5$5$<$<W$E #
 Z ..r$   c                p   ^ RI Hp V P                  \        VP                  P                  R4      4      V4       V P                  V P                  .4      pV P                  \        V4      ^4       V P                  V^ ,          R,          R4       V P                  V^ ,          R,          \        4       R# )z2
Verification logic for L{test_deprecatedModule}.
moduler   rh   z7package.module was deprecated in Package 1.2.3: messagerv   N)
packager   rP   r   __file__r   rx   checkOneWarningr{   rz   )r    
modulePathr   emitteds   &&  r!   r   ,ImportedModuleAttributeTests.checkOneWarning.  s     	#&//"8"8"ABJO$$d&:&:%;<Wq)AJy!H	
 	J/1CDr$   c                D    V P                  V P                  4       4       R# )z
If L{deprecatedModuleAttribute} is used to deprecate a module attribute
of a package, only one deprecation warning is emitted when the
deprecated module is imported.
N)r   r   r&   s   &r!   test_deprecatedModule2ImportedModuleAttributeTests.test_deprecatedModule=  s     	T3356r$   c                    V P                  4       pV P                  V4       V P                  V4       \        ^4       F  pV P                  V4       K  	  R# )z
If L{deprecatedModuleAttribute} is used to deprecate a module attribute
of a package, only one deprecation warning is emitted when the
deprecated module is subsequently imported.
N)r   r   range)r    mpxs   &  r!   "test_deprecatedModuleMultipleTimes?ImportedModuleAttributeTests.test_deprecatedModuleMultipleTimesE  sN     ##%R  	R  qA  $ r$   rc   N)r)   r*   r+   r,   r-   r   r   r   r   r   r   r.   r/   r0   s   @r!   r   r      s1     
L$L/E7% %r$   r   c                   T   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RtV tR# )WarnAboutFunctionTestsiZ  z
Tests for L{twisted.python.deprecate.warnAboutFunction} which allows the
callers of a function to issue a C{DeprecationWarning} about that function.
c                .  a \        V P                  4       4      P                  R4      V n        V P                  P	                  4        V P                  P                  R4      P                  R4       V P                  P                  R4      P                  R4       V P                  P                  R4      P                  R4       V P                  P                  4       P                  p\        P                  P                  ^ V4       V P                  \        P                  P                  V4       \        P                  P                  4       oV P                  V3R l4       \        P                  ! 4       '       d   V P!                  4        R	# R	# )
zI
Create a file that will have known line numbers when emitting warnings.
twisted_private_helperz__init__.pyr$   z	module.pys  
"A module string"

from twisted.python import deprecate

def testFunction():
    "A doc string"
    a = 1 + 2
    return a

def callTestFunction():
    b = testFunction()
    if b == 3:
        deprecate.warnAboutFunction(testFunction, "A Warning String")
z	pep626.pysQ  
"A module string"

from twisted.python import deprecate

def noop():
    pass

def testFunction(a=1, b=1):
    "A doc string"
    if a:
        if b:
            noop()
        else:
            pass

def callTestFunction():
    b = testFunction()
    if b is None:
        deprecate.warnAboutFunction(testFunction, "A Warning String")
c                  ~   < \         P                  P                  4       \         P                  P                  S 4      3# r   )r   r   clearupdate)r   s   r!   <lambda>.WarnAboutFunctionTests.setUp.<locals>.<lambda>  s&    !2!2!4ckk6H6H6Q Rr$   N)r   r   r   r   r   r   parentr   r   insertr   remover   r   r   	isWindowsrx   )r    packagePathr   s   & @r!   rj   WarnAboutFunctionTests.setUp`  s     .445MN=)44S9;'22	
" 	;'22	
0 ll))+00;'5++""$RS
    r$   c                ^   R p\         P                  ! VR4       V P                  4       p\        pVP	                  4       P                  R4      '       d   VRR pV P                  \        V^ ,          R,          4      \        V4      4       V P                  V^ ,          R,          R4       R# )z
L{deprecate.warnAboutFunction} emits a warning the file and line number
of which point to the beginning of the implementation of the function
passed to it.
c                      R # r   rc   rc   r$   r!   aFunc2WarnAboutFunctionTests.test_warning.<locals>.aFunc      r$   zA Warning Messagez.pycNfilenamerh   )	r   warnAboutFunctionrx   r   lowerendswithassertSamePathr   rP   )r    r   r}   r   s   &   r!   test_warning#WarnAboutFunctionTests.test_warning  s    	 	##E+>?**,>>$$V,,}HH]1%5j%ABHXDVWq))46IJr$   c                   ^ RI Hp VP                  4        V P                  4       pV P	                  \        V^ ,          R,          P                  R4      4      V P                  P                  R4      P                  R4      4       V P                  V^ ,          R,          ^	4       V P                  V^ ,          R,          R4       V P                  \        V4      ^4       R	# )
z
L{deprecate.warnAboutFunction} emits a C{DeprecationWarning} with the
number of a line within the implementation of the function passed to it.
r   r   r      twisted_private_helperr   linenorh   A Warning StringN)r   r   callTestFunctionrx   r   r   r   r   siblingr   rP   r{   r    r   r}   s   &  r!   test_warningLineNumber-WarnAboutFunctionTests.test_warningLineNumber  s    
 	2!**,]1%j188ABLL  !:;AA,O	
 	q)(3Q7q))46HI]+Q/r$   c                   ^ RI Hp VP                  4        V P                  4       pV P	                  \        V^ ,          R,          P                  R4      4      V P                  P                  R4      P                  R4      4       V P                  V^ ,          R,          ^4       V P                  V^ ,          R,          R4       V P                  \        V4      ^4       R	# )
z
L{deprecate.warnAboutFunction} emits a C{DeprecationWarning} with the
number of a line within the implementation handling the case in which
dis.findlinestarts returns the lines in random order.
)pep626r   r   r   s	   pep626.pyr   rh   r   N)r   r   r   rx   r   r   r   r   r   r   rP   r{   )r    r   r}   s   &  r!   'test_warningLineNumberDisFindlinestarts>WarnAboutFunctionTests.test_warningLineNumberDisFindlinestarts  s     	2!**,]1%j188ABLL  !:;AA,O	
 	q)(3R8q))46HI]+Q/r$   c                    V P                  \        VP                  4      \        VP                  4      8H  V: RV: 24       R# )z
Assert that the two paths are the same, considering case normalization
appropriate for the current platform.

@type first: L{FilePath}
@type second: L{FilePath}

@raise C{self.failureType}: If the paths are not the same.
z != N)
assertTruer   r   )r    r   r   s   &&&r!   r   %WarnAboutFunctionTests.assertSamePath  s8     	UZZ HV[[$99itF:&	
r$   c                   ^ RI Hp \        P                  R \        P                  VP                   V P
                  P                  V P
                  P                  R4      4       \        '       d   \        4        ^ RI	Hp V P                  \        P                  P                  R4       V P                  \        P                  P                  VP                  4       VP                  4        V P                  VP                  .4      p\        V^ ,          R,          P!                  R4      4      pV P
                  P                  R4      P#                  R4      pV P%                  W44       V P'                  V^ ,          R,          ^	4       V P'                  V^ ,          R	,          R
4       V P'                  \)        V4      ^4       R# )z
Even if the implementation of a deprecated function is moved around on
the filesystem, the line number in the warning emitted by
L{deprecate.warnAboutFunction} points to a line in the implementation of
the deprecated function.
r   r   s   twisted_renamed_helpertwisted_renamed_helperr   r   r   r   rh   r   N)r   r   r   r   r)   r   moveTor   r   r   r   r   r   rx   testFunctionr   r   r   r   rP   r{   )r    r   r}   
warnedPathexpectedPaths   &    r!   test_renamedFile'WarnAboutFunctionTests.test_renamedFile  sO    	2 KK01KK( 	DLL001JKL  	2)AB9!**F,?,?+@AmA.z:AA'JK
||++,EFLL
 	J5q)(3Q7q))46HI]+Q/r$   c                    \         P                  R \         P                  ! RRR7       ^ RIHp VP                  4        V P                  4       pV P                  \        V4      ^ 4       R# )z
L{deprecate.warnAboutFunction} emits a warning that will be filtered if
L{warnings.filterwarning} is called with the module name of the
deprecated function.
NNNignorer   actionr   r   N)	warningsfiltersfilterwarningsr   r   r   rx   rP   r{   r   s   &  r!   test_filteredWarning+WarnAboutFunctionTests.test_filteredWarning  sU     Qx8PQ1!**,]+Q/r$   c                   \         P                  R \         P                  ! RRR7       ^ RIHp VP                  4        VP                  4        V P                  4       pV P                  \        V4      ^4       V^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV^ ,          R	,          p\         P                  ! W4WV4      pV P                  VP                  R
4      RV: 24       R# )z
L{deprecate.warnAboutFunction} emits a warning that will be filtered
once if L{warnings.filterwarning} is called with the module name of the
deprecated function and an action of once.
r   r   r   r   r   rh   rv   r   r   z=module.py:9: DeprecationWarning: A Warning String
  return a
zUnexpected warning string: N)r   r   r   r   r   r   rx   rP   r{   formatwarningr   r   )r    r   r}   rh   rv   r   r   msgs   &       r!   test_filteredOnceWarning/WarnAboutFunctionTests.test_filteredOnceWarning  s     Qx8PQ1!!**,]+Q/"9- #J/ #J/q!(+$$WILLT *#1		
r$   )r   N)r)   r*   r+   r,   r-   rj   r   r   r   r   r   r  r  r.   r/   r0   s   @r!   r   r   Z  s:     
;!zK$0&0(
$0L0(
 
r$   r   c                     R# z?
Do nothing.

This is used to test the deprecation decorators.
Nrc   rc   r$   r!   dummyCallabler
  @      r$   c                     R# )zO
Do nothing.

This is used to test the replacement parameter to L{deprecated}.
Nrc   rc   r$   r!   dummyReplacementMethodr  H  r  r$   c                   V   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RtV tR# )DeprecationWarningsTestsiP  c                ~    \        R^^ ^ 4      pV P                  \        V P                  V4      \        : R24       R# )z
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted.
r   zZ.DeprecationWarningsTests.test_getDeprecationWarningString was deprecated in Twisted 8.0.0N)r   rP   r    test_getDeprecationWarningStringr)   r    rg   s   & r!   r  9DeprecationWarningsTests.test_getDeprecationWarningStringQ  s:    
 )Q1-'(M(MwW19<	
r$   c                    \        R^^ ^ 4      p\        R,           pV P                  \        V P                  W4      \
        : R24       R# )z
L{getDeprecationWarningString} returns a string that tells us that a
callable was deprecated at a certain released version of Twisted, with
a message containing additional information about the deprecation.
r   z: This is a messagezm.DeprecationWarningsTests.test_getDeprecationWarningString was deprecated in Twisted 8.0.0: This is a messageN)r   r   rP   r   r  r)   )r    rg   formats   &  r!   *test_getDeprecationWarningStringWithFormatCDeprecationWarningsTests.test_getDeprecationWarningStringWithFormat]  sM     )Q1-+.CC'55w AIK		
r$   c           	     ,  a \        R^^ ^ 4      p\        V4      ! \        4      oV3R lp\        RR7      ;_uu_ 4       p\	        R4       V! 4        V P                  V^ ,          P                  \        4       V P                  \        V^ ,          P                  4      \        \        V4      4       V P                  V^ ,          P                  P                  R4      \        P                  R4      4       RRR4       R#   + '       g   i     R# ; i)z;
Decorating a callable with L{deprecated} emits a warning.
r   c                     < S ! 4        R # r   rc   )dummys   r!   rt   JDeprecationWarningsTests.test_deprecateEmitsWarning.<locals>.addStackLevelt  s    Gr$   TrecordalwayscoN)r   r   r
  r   r   rP   rv   rz   strrh   r   r   rstripr   )r    rg   rt   caughtr  s   &   @r!   test_deprecateEmitsWarning3DeprecationWarningsTests.test_deprecateEmitsWarningm  s     )Q1-7#M2	 4((F"OVAY//1CDF1I%%&+M7C
 VAY//66t<hood>ST )(((s   B9DD	c                    \        R^^ ^ 4      p\        V4      ! \        4      pV P                  \        P                  VP                  4       V P                  \        \        4      \        V4      4       R# )z;
The decorated function has the same name as the original.
r   N)r   r   r
  rP   r)   fullyQualifiedNamer    rg   r  s   &  r!   test_deprecatedPreservesName5DeprecationWarningsTests.test_deprecatedPreservesName  sY     )Q1-7#M2//@+M:<Nu<UVr$   c                Z    \        R^^ ^ 4      pV P                  R\        VR4      4       R# )zZ
L{_getDeprecationDocstring} returns a note about the deprecation to go
into a docstring.
r   zDeprecated in Twisted 8.0.0. N)r   rP   r   r  s   & r!   test_getDeprecationDocstring5DeprecationWarningsTests.test_getDeprecationDocstring  s/    
 )Q1-*,DWb,Q	
r$   c                    R p\        R^^ ^ 4      p\        V4      ! V4      p\        V\        VR4      4       V P	                  VP
                  VP
                  4       R# )z^
The docstring of the deprecated function is appended with information
about the deprecation.
c                     R# r	  rc   rc   r$   r!   localDummyCallableTDeprecationWarningsTests.test_deprecatedUpdatesDocstring.<locals>.localDummyCallable  r  r$   r   r+  N)r   r   r	   r   rP   r-   )r    r0  rg   r  s   &   r!   test_deprecatedUpdatesDocstring8DeprecationWarningsTests.test_deprecatedUpdatesDocstring  sX    	 )Q1-7#$67-/GQS/TU+33U]]Cr$   c                    \        R^^ ^ 4      p\        V4      ! \        4      pV P                  WP                  4       R# )z\
Deprecating a function adds version information to the decorated
version of that function.
r   N)r   r   r
  rP   deprecatedVersionr'  s   &  r!   test_versionMetadata-DeprecationWarningsTests.test_versionMetadata  s7    
 )Q1-7#M2"9"9:r$   c                    \        R^^ ^ 4      p\        V P                  VRR7      pV P                  V\	        V P                  4      : R24       R# )z
L{getDeprecationWarningString} takes an additional replacement parameter
that can be used to add information to the deprecation.  If the
replacement parameter is a string, it will be interpolated directly into
the result.
r   something.foobarreplacementzE was deprecated in Twisted 8.0.0; please use something.foobar insteadN)r   r   r  rP   r&  r    rg   warningStrings   &  r!   +test_getDeprecationWarningStringReplacementDDeprecationWarningsTests.test_getDeprecationWarningStringReplacement  sT     )Q1-311*

 	+D,Q,QRU	
r$   c                    \        R^^ ^ 4      p\        V P                  V\        R7      pV P	                  V\        V P                  4      : R\        : R24       R# )z
L{getDeprecationWarningString} takes an additional replacement parameter
that can be used to add information to the deprecation. If the
replacement parameter is a callable, its fully qualified name will be
interpolated into the result.
r   r:  z- was deprecated in Twisted 8.0.0; please use z.dummyReplacementMethod insteadN)r   r   r  r  rP   r&  r)   r<  s   &  r!   7test_getDeprecationWarningStringReplacementWithCallablePDeprecationWarningsTests.test_getDeprecationWarningStringReplacementWithCallable  sX     )Q1-311.

 	 "$"G"GH(T	
r$   rc   N)r)   r*   r+   r,   r  r  r#  r(  r,  r2  r6  r>  rA  r.   r/   r0   s   @r!   r  r  P  s:     


 U*W
D(;
&
 
r$   r  r   c                       ] tR tRtRtRtR# )DeprecatedClassi  zB
Class which is entirely deprecated without having a replacement.
rc   N)r)   r*   r+   r,   r-   r.   rc   r$   r!   rD  rD    s    r$   rD  c                   z   a  ] tR tRt o RtRt]! ]! R^^^4      4      R 4       t]P                  R 4       tRt
V tR# )ClassWithDeprecatedPropertyi  z*
Class with a single deprecated property.
Nr   c                    V P                   # )z+
Getter docstring.

@return: The property.
_someProtectedValuer&   s   &r!   someProperty(ClassWithDeprecatedProperty.someProperty  s     '''r$   c                    Wn         R# )z
Setter docstring.
NrH  r   s   &&r!   rJ  rK    s
    
 $) r$   rH  )r)   r*   r+   r,   r-   rI  r   r   rJ  setterr.   r/   r0   s   @r!   rF  rF    sN      	1a34( 5( ) )r$   rF  r5   c                    R# )z/
Function with a deprecated keyword parameter.
Nrc   )abcr5   bars   &&&&&r!   functionWithDeprecatedParameterrS    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# )DeprecatedDecoratorTestsi   z"
Tests for deprecated decorators.
c                    T P                  Y!P                  P                  4        Uu. uF*  q3P                  4       '       g   K  VP                  4       NK,  	  up4       R# u upi )a   
Check that C{target} object has the C{expected} docstring lines.

@param target: Object which is checked.
@type target: C{anything}

@param expected: List of lines, ignoring empty lines or leading or
    trailing spaces.
@type expected: L{list} or L{str}
N)rP   r-   
splitlinesstrip)r    targetexpectedr   s   &&& r!   assertDocstring(DeprecatedDecoratorTests.assertDocstring  sD     	..*C*C*ES*EQyqwwy*ES	
Ss   A!
A!
c                   \        4       pVP                   V P                  \         P                  . RO4       \        R^^^4      \         P                  n        RpV P                  V P                  .4      pV P                  ^\        V4      4       V P                  \        V^ ,          R,          4       V P                  W#^ ,          R,          4       R# )z
When L{deprecatedProperty} is used on a C{property}, accesses raise a
L{DeprecationWarning} and getter docstring is updated to inform the
version in which it was deprecated. C{deprecatedVersion} attribute is
also set to inform the deprecation version.
r   ktwisted.python.test.test_deprecate.ClassWithDeprecatedProperty.someProperty was deprecated in Twisted 1.2.3rv   rh   N)zGetter docstring.z@return: The property.Deprecated in Twisted 1.2.3.)
rF  rJ  r[  r   r5  rx   test_propertyGetterrP   r{   rz   )r    objrh   r   s   &   r!   r`  ,DeprecatedDecoratorTests.test_propertyGetter  s     *+'44	
 FMq!QF
#00B
; 	 %%t'?'?&@ACM*+Xa[-DE1+i"89r$   c                h   \        4       p\        4       pWn        V P                  WP                  4       RpV P                  V P                  .4      pV P                  ^\        V4      4       V P                  \        V^ ,          R,          4       V P                  W4^ ,          R,          4       R# )ze
When L{deprecatedProperty} is used on a C{property}, setter accesses
raise a L{DeprecationWarning}.
r^  rv   rh   N)
rN   rF  rJ  rD   rI  rx   test_propertySetterrP   r{   rz   )r    newValuera  rh   r   s   &    r!   rd  ,DeprecatedDecoratorTests.test_propertySetter4  s    
 8)+#h 7 78; 	 %%t'?'?&@ACM*+Xa[-DE1+i"89r$   c                p   \        4        V P                  \         RR.4       \        R^^^4      \         n        RpV P	                  V P
                  .4      pV P                  ^\        V4      4       V P                  \        V^ ,          R,          4       V P                  W^ ,          R,          4       R# )z
When L{deprecated} is used on a class, instantiations raise a
L{DeprecationWarning} and class's docstring is updated to inform the
version in which it was deprecated. C{deprecatedVersion} attribute is
also set to inform the deprecation version.
z@Class which is entirely deprecated without having a replacement.r_  r   zRtwisted.python.test.test_deprecate.DeprecatedClass was deprecated in Twisted 1.2.3rv   rh   N)	rD  r[  r   r5  rx   
test_classrP   r{   rz   )r    rh   r   s   &  r!   rh  #DeprecatedDecoratorTests.test_classH  s     	V.	
 -4Iq!Q,G). 	 %%t&78CM*+Xa[-DE1+i"89r$   c                    \        R^^ ^ 4      p\        VR4      ! \        4      pV P                  VP                  R4       R# )z
L{deprecated} takes an additional replacement parameter that can be used
to indicate the new, non-deprecated method developers should use.  If
the replacement parameter is a string, it will be interpolated directly
into the warning message.
r   r9  z
Do nothing.

This is used to test the deprecation decorators.

Deprecated in Twisted 8.0.0; please use something.foobar instead.
N)r   r   r
  rP   r-   r'  s   &  r!   test_deprecatedReplacement3DeprecatedDecoratorTests.test_deprecatedReplacementc  s@     )Q1-7$67FMM	
r$   c                    \        R^^ ^ 4      p\        V\        R7      pV! \        4      pV P	                  VP
                  RP                  \        4      4       R# )a  
L{deprecated} takes an additional replacement parameter that can be used
to indicate the new, non-deprecated method developers should use.  If
the replacement parameter is a callable, its fully qualified name will
be interpolated into the warning message.
r   r:  z
Do nothing.

This is used to test the deprecation decorators.

Deprecated in Twisted 8.0.0; please use {}.dummyReplacementMethod instead.
N)r   r   r  r
  rP   r-   r  r)   )r    rg   	decoratorr  s   &   r!   &test_deprecatedReplacementWithCallable?DeprecatedDecoratorTests.test_deprecatedReplacementWithCallablev  sQ     )Q1-w4JK	-(MM3 4:6(3C	
r$   c                L   R p\        RR7      ;_uu_ 4       p\        R4       \        ^
^4       V P                  V. 4       \        ^
^^4       V P                  V. 4       \        ^
^^(R7       V P                  \	        V4      ^4       V P                  V^ ,          P
                  \        4       V P                  \        V^ ,          P                  4      V4       VP                  4        \        ^
^^2R7       V P                  V. 4       \        ^
^^^(4       V P                  \	        V4      ^4       V P                  V^ ,          P
                  \        4       V P                  \        V^ ,          P                  4      V4       RRR4       R#   + '       g   i     R# ; i)zzThe 'foo' parameter to twisted.python.test.test_deprecate.functionWithDeprecatedParameter was deprecated in Twisted 19.2.0Tr  r  )r5   )rR  N)
r   r   rS  rP   r{   rv   rz   r   rh   r   )r    rh   wss   &  r!   test_deprecatedKeywordParameter8DeprecatedDecoratorTests.test_deprecatedKeywordParameter  s;   / 	 4((B"+B3R$+BB7R$+B;SWa(RU^^-?@SA/9HHJ+B;R$+BB;SWa(RU^^-?@SA/9+ )(((s   E1FF#	rc   N)r)   r*   r+   r,   r-   r[  r`  rd  rh  rk  ro  rs  r.   r/   r0   s   @r!   rU  rU     s3     
:@:(:6
&
&: :r$   rU  c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )AppendToDocstringTestsi  z_
Test the _appendToDocstring function.

_appendToDocstring is used to add text to a docstring.
c                \    R p\        VR4       V P                  RVP                  4       R# )z@
Appending to an empty docstring simply replaces the docstring.
c                      R # r   rc   rc   r$   r!   noDocstringGAppendToDocstringTests.test_appendToEmptyDocstring.<locals>.noDocstring  r   r$   Appended text.Nr	   rP   r-   )r    ry  s   & r!   test_appendToEmptyDocstring2AppendToDocstringTests.test_appendToEmptyDocstring  s+    
	 	;(89);+>+>?r$   c                    R p\        VR4       V P                  . ROVP                  P                  4       4       V P	                  VP                  P                  R4      4       R# )aV  
Appending to a single line docstring places the message on a new line,
with a blank line separating it from the rest of the docstring.

The docstring ends with a newline, conforming to Twisted and PEP 8
standards. Unfortunately, the indentation is incorrect, since the
existing docstring doesn't have enough info to help us indent
properly.
c                     R# );This doesn't comply with standards, but is here for a test.Nrc   rc   r$   r!   singleLineDocstringTAppendToDocstringTests.test_appendToSingleLineDocstring.<locals>.singleLineDocstring  r  r$   r{  
N)r  r+  r{  )r	   rP   r-   rW  r   r   )r    r  s   & r!    test_appendToSingleLineDocstring7AppendToDocstringTests.test_appendToSingleLineDocstring  s]    	N 	.0@A
  ''224	
 	+33<<TBCr$   c                \    R p\        VR4       V P                  RVP                  4       R# )z
Appending to a multi-line docstring places the messade on a new line,
with a blank line separating it from the rest of the docstring.

Because we have multiple lines, we have enough information to do
indentation.
c                     R# )z!
This is a multi-line docstring.
Nrc   rc   r$   r!   multiLineDocstringRAppendToDocstringTests.test_appendToMultilineDocstring.<locals>.multiLineDocstring  r  r$   r{  z1
This is a multi-line docstring.

Appended text.
Nr|  )r    r  s   & r!   test_appendToMultilineDocstring6AppendToDocstringTests.test_appendToMultilineDocstring  s/    	
 	-/?@L&&	
r$   rc   N)
r)   r*   r+   r,   r-   r}  r  r  r.   r/   r0   s   @r!   rv  rv    s      	@D2
 
r$   rv  c                   f   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R tR tR tRtV tR# )MutualArgumentExclusionTestsi  z*
Tests for L{mutuallyExclusiveArguments}.
c                    \        \        RR4      '       d!   \        \        P                  ! V4      W#4      # \	        \        P
                  ! V4      W#4      # )a  
Test an invocation of L{passed} with the given function, arguments, and
keyword arguments.

@param func: A function whose argspec will be inspected.
@type func: A callable.

@param args: The arguments which could be passed to C{func}.

@param kw: The keyword arguments which could be passed to C{func}.

@return: L{_passedSignature} or L{_passedArgSpec}'s return value
@rtype: L{dict}
	signatureN)rG   inspectr   r  r   
getargspecr    funcargskws   &&*,r!   checkPassed(MutualArgumentExclusionTests.checkPassed  sE     7K..#G$5$5d$;TFF "'"4"4T":DEEr$   c                h    R pV P                  V P                  V^^4      \        ^^R7      4       R# )zH
L{passed} identifies the arguments passed by a simple
positional test.
c                     R # r   rc   rO  rP  s   &&r!   r  GMutualArgumentExclusionTests.test_passed_simplePositional.<locals>.func
  r   r$   r  NrP   r  r   r    r  s   & r!   test_passed_simplePositional9MutualArgumentExclusionTests.test_passed_simplePositional  s.    	 	))$15ta1~Fr$   c                T    R pV P                  \        V P                  V^^^4       R# )zC
L{passed} raises a L{TypeError} if too many arguments are
passed.
c                     R # r   rc   r  s   &&r!   r  BMutualArgumentExclusionTests.test_passed_tooManyArgs.<locals>.func  r   r$   NrE   	TypeErrorr  r  s   & r!   test_passed_tooManyArgs4MutualArgumentExclusionTests.test_passed_tooManyArgs  s'    	 	)T%5%5tQ1Er$   c                T    R pV P                  \        V P                  V^^R7       R# )z[
L{passed} raises a L{TypeError} if a argument is passed both
positionally and by keyword.
c                     R # r   rc   rO  s   &r!   r  HMutualArgumentExclusionTests.test_passed_doublePassKeyword.<locals>.func   r   r$   r  Nr  r  s   & r!   test_passed_doublePassKeyword:MutualArgumentExclusionTests.test_passed_doublePassKeyword  (    	 	)T%5%5tQ!Dr$   c                T    R pV P                  \        V P                  V^^R7       R# )zl
L{passed} raises a L{TypeError} if a keyword argument not
present in the function's declaration is passed.
c                     R # r   rc   r  s   &r!   r  IMutualArgumentExclusionTests.test_passed_unspecifiedKeyword.<locals>.func+  r   r$   )zNr  r  s   & r!   test_passed_unspecifiedKeyword;MutualArgumentExclusionTests.test_passed_unspecifiedKeyword%  r  r$   c                j    R pV P                  V P                  V^^^4      \        ^RR7      4       R# )zd
L{passed} places additional positional arguments into a tuple
under the name of the star argument.
c                     R # r   rc   r  s   &*r!   r  ;MutualArgumentExclusionTests.test_passed_star.<locals>.func6  r   r$   r  N)      r  r  s   & r!   test_passed_star-MutualArgumentExclusionTests.test_passed_star0  s1    	 	))$1a8$f:MNr$   c                    R pV P                  V P                  V^^^^R7      \        ^\        ^^^R7      R7      4       R# )zV
Additional keyword arguments are passed as a dict to the star star
keyword argument.
c                     R # r   rc   r  s   &,r!   r  ?MutualArgumentExclusionTests.test_passed_starStar.<locals>.funcA  r   r$   )r   yr  r  Nr  r  s   & r!   test_passed_starStar1MutualArgumentExclusionTests.test_passed_starStar;  sC    	 	T1Q!4dQ$aSTBU6V	
r$   c           	     r    RR lpV P                  V P                  V^^^R7      \        ^^^R7      4       R# )zX
The results of L{passed} only include arguments explicitly
passed, not default values.
c                     R # r   rc   rO  rP  rQ  des   &&&&&r!   r  FMutualArgumentExclusionTests.test_passed_noDefaultValues.<locals>.funcN  r   r$   )r  )rO  rP  r  N   r  r  r  r  s   & r!   test_passed_noDefaultValues8MutualArgumentExclusionTests.test_passed_noDefaultValuesH  s6    	 	))$1):D1Q<OPr$   c                    \        R.4      RR l4       pV P                  V! ^^4      ^
4       V P                  V! ^^^4      ^4       V P                  V! ^^^R7      ^4       R# )z
L{mutuallyExclusiveArguments} does not interfere in its
decoratee's operation, either its receipt of arguments or its return
value.
c                 .    W,           V,           V,           # r   rc   )r   r  rO  rP  s   &&&&r!   r  MMutualArgumentExclusionTests.test_mutualExclusionPrimeDirective.<locals>.funcZ  s    519q= r$   rP  Nr  r     )r   rP   r  s   & r!   "test_mutualExclusionPrimeDirective?MutualArgumentExclusionTests.test_mutualExclusionPrimeDirectiveS  se     
%j\	2	! 
3	! 	aR(aA+aa"-r$   c                d    \        RR..4      RR l4       pV P                  \        V^^R7       R# )zy
L{mutuallyExclusiveArguments} raises a L{TypeError}n if its
decoratee is passed a pair of mutually exclusive arguments.
rO  rP  c                     W,           # r   rc   r  s   &&r!   r  PMutualArgumentExclusionTests.test_mutualExclusionExcludesByKeyword.<locals>.funch  s	    5Lr$   r  Nr  )r   rE   r  r  s   & r!   %test_mutualExclusionExcludesByKeywordBMutualArgumentExclusionTests.test_mutualExclusionExcludesByKeywordb  s:     
%sCj\	2	 
3	 	)TQ!4r$   c                    ! R R4      p ! R R4      pR pV! ^^4       \         P                  ! V4      P                  pVP                  4       pV! RR4      VR&   V! V4      pV P	                  \
        \        VR	/ 4       R# )
z
Create a fake signature with an invalid parameter
type to test error handling.  The valid parameter
types are specified in L{inspect.Parameter}.
c                   &   a  ] tR tRt o R tRtV tR# )MMutualArgumentExclusionTests.test_invalidParameterType.<locals>.FakeSignatureiu  c                    Wn         R # r   
parameters)r    r  s   &&r!   r"   VMutualArgumentExclusionTests.test_invalidParameterType.<locals>.FakeSignature.__init__v  s    ",r$   r  Nr)   r*   r+   r,   r"   r.   r/   r0   s   @r!   FakeSignaturer  u  s     - -r$   r  c                   &   a  ] tR tRt o R tRtV tR# )MMutualArgumentExclusionTests.test_invalidParameterType.<locals>.FakeParameteriy  c                    Wn         W n        R # r   )r|   kind)r    r|   r  s   &&&r!   r"   VMutualArgumentExclusionTests.test_invalidParameterType.<locals>.FakeParameter.__init__z  s     	 	r$   )r  r|   Nr  r0   s   @r!   FakeParameterr  y  s     ! !r$   r  c                     R # r   rc   r  s   &&r!   r  DMutualArgumentExclusionTests.test_invalidParameterType.<locals>.func~  r   r$   fakerQ  Nr  r  )r  r  r  r   rE   r  r   )r    r  r  r  r  dummyParametersfakeSigs   &      r!   test_invalidParameterType6MutualArgumentExclusionTests.test_invalidParameterTypen  sz    	- 	-	! 	!
	 	Q
&&t,77
$//+,VV<0)%5wKr$   rc   N)r)   r*   r+   r,   r-   r  r  r  r  r  r  r  r  r  r  r  r.   r/   r0   s   @r!   r  r    sO     F,	G	F	E	E	O
	Q.
5L Lr$   r  c                   0   a  ] tR tRt o RtR tR tRtV tR# )KeywordOnlyTestsi  z$
Keyword only arguments (PEP 3102).
c                B    \        \        P                  ! V4      W#4      # )ah  
Test an invocation of L{passed} with the given function, arguments, and
keyword arguments.

@param func: A function whose argspec to pass to L{_passed}.
@type func: A callable.

@param args: The arguments which could be passed to L{func}.

@param kw: The keyword arguments which could be passed to L{func}.

@return: L{_passed}'s return value
@rtype: L{dict}
)r   r  r  r  s   &&*,r!   r  KeywordOnlyTests.checkPassed  s       1 1$ 7BBr$   c                   RR/R lpRR/R lpV P                  V P                  V^^^4      \        RRR7      4       V P                  V P                  V^^^RR7      \        RRR7      4       V P                  V P                  V^^R^^^R7      \        RR^^^R	7      4       V P                  \        V P                  V^^R^^R
7       R# )zH
Keyword only arguments follow varargs.
They are specified in PEP 3102.
rP  Tc                    R# )z5
b is a keyword-only argument, with a default value.
Nrc   )rP  rO  s   $*r!   func16KeywordOnlyTests.test_passedKeywordOnly.<locals>.func1  r  r$   c                    R# )z@
b, c, d, e  are keyword-only arguments.
b has a default value.
Nrc   )rP  rQ  r  r  rO  s   $$$$*r!   func26KeywordOnlyTests.test_passedKeywordOnly.<locals>.func2  r  r$   r  Fr  )rP  rQ  r  r  r  )rP  rQ  r  Nr  r  )rP   r  r   rE   r  )r    r  r  s   &  r!   test_passedKeywordOnly'KeywordOnlyTests.test_passedKeywordOnly  s    	 	
	 	 	))%Aq94)t;TUUAq!u5ti57Q	
 	UAqEQ!qA6Ua12	
 	)T%5%5uaeqTUVr$   rc   N)	r)   r*   r+   r,   r-   r  r  r.   r/   r0   s   @r!   r  r    s     C"W Wr$   r  r  )7r-   r  r   r6   r   os.pathr   r   r   	importlibr   ImportErrorincrementalr   twisted.pythonr   twisted.python.deprecater   r	   r
   r&  r   r   r   r   r   r   r   r   r   twisted.python.filepathr   twisted.python.runtimer   twisted.python.testr   #twisted.python.test.modules_helpersr   twisted.trial.unittestr   r   r3   re   r   r   r
  r  r  rD  rF  rS  rU  rv  r  r  rc   r$   r!   <module>r     so  
  
    1+   $    - + 4 C 6 "DY* DYN_@2 _@Dl%#68K l%^c
0 c
LG
2 G
T GIq!Q'(  )) )0 GIr1a8%@ Af:2 f:R=
0 =
@]L#6 ]L@/W* /Wo#  s   D& &	D32D3