
CMc           @   s  d  Z  d d l Z d d l Z d d l Z d d l m Z d d l m Z d d l m	 Z	 d d l
 m Z d d l
 m Z d d l
 m Z m Z d d	 l
 m Z d d
 l
 m Z d d l m Z d d l m Z d d l m Z d d l m Z d   Z d   Z d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ  d e f d     YZ! d S(   sI   
Tests for Twisted's deprecation framework, L{twisted.python.deprecate}.
iN(   t   normcase(   t   TestCase(   t	   deprecate(   t   _appendToDocstring(   t   _getDeprecationDocstring(   t
   deprecatedt   getDeprecationWarningString(   t   _getDeprecationWarningString(   t   DEPRECATION_WARNING_FORMAT(   t   fullyQualifiedName(   t   Version(   t   FilePath(   t   deprecatedattributesc           C   s   d S(   sK   
    Do nothing.

    This is used to test the deprecation decorators.
    N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   dummyCallable   s    c           C   s   d S(   s[   
    Do nothing.

    This is used to test the replacement parameter to L{deprecated}.
    N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   dummyReplacementMethod$   s    t   TestDeprecationWarningsc           B   sk   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z RS(   c         C   s5   t  d d d d  } |  j t |  j |  d  d S(   s   
        L{getDeprecationWarningString} returns a string that tells us that a
        callable was deprecated at a certain released version of Twisted.
        t   Twistedi   i    s{   twisted.python.test.test_deprecate.TestDeprecationWarnings.test_getDeprecationWarningString was deprecated in Twisted 8.0.0N(   R
   t   assertEqualR   t    test_getDeprecationWarningString(   t   selft   version(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR   .   s
    	c         C   sE   t  d d d d  } t j d } |  j t |  j | |  d  d S(   s   
        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   i   i    s   : This is a messages   twisted.python.test.test_deprecate.TestDeprecationWarnings.test_getDeprecationWarningString was deprecated in Twisted 8.0.0: This is a messageN(   R
   R   R   t   assertEqualsR   R   (   R   R   t   format(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt*   test_getDeprecationWarningStringWithFormat<   s    		c            sY   t  d d d d  } t |  t      f d   } |  j t t t |  t |  d S(   sK   
        Decorating a callable with L{deprecated} emits a warning.
        R   i   i    c              s       d  S(   N(    (    (   t   dummy(    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   addStackLevelR   s    N(   R
   R   R   t   assertWarnst   DeprecationWarningR   t   __file__(   R   R   R   (    (   R   sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_deprecateEmitsWarningL   s    c         C   s]   t  d d d d  } t |  t  } |  j t j | j  |  j t t  t |   d S(   sK   
        The decorated function has the same name as the original.
        R   i   i    N(   R
   R   R   R   t   __name__R	   (   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_deprecatedPreservesName[   s
    c         C   s2   t  d d d d  } |  j d t | d   d S(   sr   
        L{_getDeprecationDocstring} returns a note about the deprecation to go
        into a docstring.
        R   i   i    s   Deprecated in Twisted 8.0.0.t    N(   R
   R   R   (   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_getDeprecationDocstringf   s    c         C   sW   t  d d d d  } t |  t  } t t t | d   |  j t j | j  d S(   sv   
        The docstring of the deprecated function is appended with information
        about the deprecation.
        R   i   i    R    N(   R
   R   R   R   R   R   t   __doc__(   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_deprecatedUpdatesDocstringq   s    c         C   s>   t  d d d d  } t |  t  } |  j | | j  d S(   st   
        Deprecating a function adds version information to the decorated
        version of that function.
        R   i   i    N(   R
   R   R   R   t   deprecatedVersion(   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_versionMetadata   s    c         C   sQ   t  d d d d  } t |  j | d d } |  j | d t |  j  f  d S(   s  
        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   i   i    t   replacements   something.foobarsG   %s was deprecated in Twisted 8.0.0; please use something.foobar insteadN(   R
   R   R   R   R	   (   R   R   t   warningString(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt+   test_getDeprecationWarningStringReplacement   s    	c         C   sQ   t  d d d d  } t |  j | d t } |  j | d t |  j  f  d S(   s  
        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   i   i    R&   sp   %s was deprecated in Twisted 8.0.0; please use twisted.python.test.test_deprecate.dummyReplacementMethod insteadN(   R
   R   R   R   R   R	   (   R   R   R'   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt7   test_getDeprecationWarningStringReplacementWithCallable   s    	c         C   sA   t  d d d d  } t | d  t  } |  j | j d  d S(   s  
        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   i   i    s   something.foobars   
    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   R   R"   (   R   R   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_deprecatedReplacement   s    c         C   sJ   t  d d d d  } t | d t } | t  } |  j | j d  d S(   s)  
        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   i   i    R&   s   
    Do nothing.

    This is used to test the deprecation decorators.

    Deprecated in Twisted 8.0.0; please use twisted.python.test.test_deprecate.dummyReplacementMethod instead.
    N(   R
   R   R   R   R   R"   (   R   R   t	   decoratorR   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt&   test_deprecatedReplacementWithCallable   s
    (   R   t
   __module__R   R   R   R   R!   R#   R%   R(   R)   R*   R,   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR   -   s   							
			t   TestAppendToDocstringc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   sk   
    Test the _appendToDocstring function.

    _appendToDocstring is used to add text to a docstring.
    c         C   s-   d   } t  | d  |  j d | j  d S(   sP   
        Appending to an empty docstring simply replaces the docstring.
        c           S   s   d  S(   N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   noDocstring   s    s   Appended text.N(   R   R   R"   (   R   R/   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_appendToEmptyDocstring   s    	c         C   sU   d   } t  | d  |  j d d d g | j j    |  j | j j d   d S(   s  
        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           S   s   d S(   s;   This doesn't comply with standards, but is here for a test.N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   singleLineDocstring   s    s   Appended text.s;   This doesn't comply with standards, but is here for a test.R    s   
N(   R   R   R"   t
   splitlinest
   assertTruet   endswith(   R   R1   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt    test_appendToSingleLineDocstring   s    	c         C   s9   d   } d   } t  | d  |  j | j | j  d S(   s   
        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           S   s   d S(   s9   
            This is a multi-line docstring.
            N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   multiLineDocstring  s    c           S   s   d S(   sU   
            This is a multi-line docstring.

            Appended text.
            N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   expectedDocstring  s    s   Appended text.N(   R   R   R"   (   R   R6   R7   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_appendToMultilineDocstring  s
    			(   R   R-   R"   R0   R5   R8   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR.      s   		t   _MockDeprecatedAttributec           B   s    e  Z d  Z d   Z d   Z RS(   sq   
    Mock of L{twisted.python.deprecate._DeprecatedAttribute}.

    @ivar value: The value of the attribute.
    c         C   s   | |  _  d  S(   N(   t   value(   R   R:   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   __init__#  s    c         C   s   |  j  S(   s$   
        Get a known value.
        (   R:   (   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   get'  s    (   R   R-   R"   R;   R<   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR9     s   	t   ModuleProxyTestsc           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s   
    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         K   sI   t  j d  } x* | j   D] \ } } t | | |  q Wt j |  S(   s   
        Create a temporary module proxy object.

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

        @rtype: L{twistd.python.deprecate._ModuleProxy}
        t   foo(   t   typest
   ModuleTypet	   iteritemst   setattrR   t   _ModuleProxy(   R   t   attrst   modt   keyR:   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt
   _makeProxy5  s    c         C   s?   |  j  d d  } |  j | j d  |  j t t | d  d S(   s   
        Getting a normal attribute on a L{twisted.python.deprecate._ModuleProxy}
        retrieves the underlying attribute's value, and raises C{AttributeError}
        if a non-existant attribute is accessed.
        t   SOME_ATTRIBUTEt   hellot   DOES_NOT_EXISTN(   RG   t   assertIdenticalRH   t   assertRaisest   AttributeErrort   getattr(   R   t   proxy(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_getattrPassthroughC  s    c         C   sE   |  j    } t j | d  } t d  | d <|  j | j d  d S(   s   
        Getting an attribute marked as being deprecated on
        L{twisted.python.deprecate._ModuleProxy} results in calling the
        deprecated wrapper's C{get} method.
        t   _deprecatedAttributesi*   R>   N(   RG   t   objectt   __getattribute__R9   R   R>   (   R   RO   RQ   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_getattrInterceptN  s
    c         C   s<   |  j    } |  j t t | d  |  j t t | d  d S(   s   
        Private attributes of L{twisted.python.deprecate._ModuleProxy} are
        inaccessible when regular attribute access is used.
        t   _moduleRQ   N(   RG   RL   RM   RN   (   R   RO   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_privateAttributes[  s    c         C   sH   |  j    } d | _ |  j t j | d  d  |  j | j d  d S(   s   
        Setting attributes on L{twisted.python.deprecate._ModuleProxy} proxies
        them through to the wrapped module.
        i   RU   N(   RG   RU   t   assertNotEqualsRR   RS   R   (   R   RO   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_setattrf  s    	c         C   sK   |  j    } t j | d  } |  j t |  d t |  j | f  d S(   s   
        L{twisted.python.deprecated._ModuleProxy.__repr__} produces a string
        containing the proxy type and a representation of the wrapped module
        object.
        RU   s   <%s module=%r>N(   RG   RR   RS   R   t   reprt   typeR   (   R   RO   t
   realModule(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt	   test_reprq  s    (	   R   R-   R"   RG   RP   RT   RV   RX   R\   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR=   /  s   					t   DeprecatedAttributeTestsc           B   sJ   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d Z d   Z	 RS(   s   
    Tests for L{twisted.python.deprecate._DeprecatedAttribute} and
    L{twisted.python.deprecate.deprecatedModuleAttribute}, which issue
    warnings for deprecated module-level attributes.
    c         C   s)   t  j |  _ t  j |  _ t d |  _ d  S(   Ns   .foo(   R   R   t   messageR   t   _testModuleName(   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   setUp  s    c         C   s)   t  t j d | t j t d t j  S(   sJ   
        Create the warning string used by deprecated attributes.
        t   .s   : (   R   R   R   R   R   R^   (   R   t   attr(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   _getWarningString  s    c            s   d } t  t | d  t j t | |  j |  j    |  j   j |    f d   } |   |  j |  j	 g  } |  j
 | d d t  |  j | d d |  j |   |  j t |  d  d S(	   s   
        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.
        t   ANOTHER_DEPRECATED_ATTRIBUTEi*   c              s     j    d  S(   N(   R<   (    (   Rb   (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR     s    i    t   categoryR^   i   N(   RB   R   R   t   _DeprecatedAttributeR   R^   R   R   t   flushWarningst   test_deprecatedAttributeHelperRK   R   Rc   t   len(   R   t   nameR   t   warningsShown(    (   Rb   sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyRh     s    c         C   s   t  j |  j |  j g  } |  j t |  d  d } t t  |  |  j |  j g  } |  j t |  d  |  j | d d t  |  j | d d |  j	 |   d S(   s  
        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.
        i    t   DEPRECATED_ATTRIBUTEi   Re   R^   N(
   R   t   ANOTHER_ATTRIBUTERg   t   test_deprecatedAttributeR   Ri   RN   RK   R   Rc   (   R   Rk   Rj   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyRn     s    c         C   s   t  j d  t j |  j <} |  j t j j |  j  t | d d  t | d d  t j	 t
 d d d d  d	 |  j d  t j |  j } |  j | |  t j	 t
 d d d d  d	 |  j d  |  j | t j |  j  d
 S(   s   
        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.
        R>   t   firsti   t   secondi   R   i   i    R^   N(   R?   R@   t   syst   modulesR_   t
   addCleanupt   popRB   R   t   deprecatedModuleAttributeR
   t   assertNotEqualRK   (   R   RE   RO   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_wrappedModule  s"    s   from twisted.python.deprecate import deprecatedModuleAttribute
from twisted.python.versions import Version

deprecatedModuleAttribute(
    Version('Package', 1, 2, 3), 'message', __name__, 'module')
c         C   s  t  |  j    } | j   | j d  } | j   | j d  j |  j  | j d  j d  } t j j d | j  |  j	 t j j
 | j  d d l m } |  j | j j d d	  d | j d  j j d d	  d  |  j |  j g  } |  j t |  d	  d
 S(   s   
        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.
        t   packages   __init__.pys	   module.pyR    i    i(   t   moduleRa   i   N(   R   t   mktempt   makedirst   childt
   setContentt   _packageInitRq   t   patht   insertRs   t   removeRx   Ry   R   R   t   rsplitRg   t   test_deprecatedModuleRi   (   R   t   baseRx   Ry   Rk   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR     s    

#(
   R   R-   R"   R`   Rc   Rh   Rn   Rw   R~   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR]   ~  s   		
			$t   WarnAboutFunctionTestsc           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s   
    Tests for L{twisted.python.deprecate.warnAboutFunction} which allows the
    callers of a function to issue a C{DeprecationWarning} about that function.
    c            s   t  |  j    j d  |  _ |  j j   |  j j d  j d  |  j j d  j d  t j j d |  j j	   j  |  j
 t j j |  j j	   j  t j j     |  j
   f d    d S(	   sY   
        Create a file that will have known line numbers when emitting warnings.
        t   twisted_private_helpers   __init__.pyR    s	   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")
i    c              s   t  j j   t  j j    f S(   N(   Rq   Rr   t   cleart   update(    (   Rr   (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   <lambda>+  s    N(   R   Rz   R|   Rx   R{   R}   Rq   R   R   t   parentRs   R   Rr   t   copy(   R   (    (   Rr   sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR`     s    "c         C   s   d   } t  j | d  |  j   } t } | j   j d  rM | d  } n  |  j t | d d  t |   |  j | d d d  d S(	   s   
        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           S   s   d  S(   N(    (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   aFunc4  s    s   A Warning Messages   .pycii    t   filenameR^   N(	   R   t   warnAboutFunctionRg   R   t   lowerR4   t   assertSamePathR   R   (   R   R   Rk   R   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_warning.  s    	c         C   s   d d l  m } | j   |  j   } |  j t | d d  |  j j d  j d   |  j	 | d d d  |  j	 | d d	 d
  |  j	 t
 |  d  d S(   s   
        L{deprecate.warnAboutFunction} emits a C{DeprecationWarning} with the
        number of a line within the implementation of the function passed to it.
        i(   Ry   i    R   R   s	   module.pyt   linenoi	   R^   s   A Warning Stringi   N(   R   Ry   t   callTestFunctionRg   R   R   Rx   t   siblingR|   R   Ri   (   R   Ry   Rk   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_warningLineNumber@  s    
c         C   s6   |  j  t | j  t | j  k d | | f  d S(   s  
        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.
        s   %r != %rN(   R3   R    R   (   R   Ro   Rp   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR   R  s    
c         C   s!  d d l  m } t j d =t j | j =|  j j |  j j d   d d l m } |  j	 t j j
 d  |  j	 t j j
 | j  | j   |  j   } t | d d  } |  j j d  j d  } |  j | |  |  j | d d d	  |  j | d d
 d  |  j t |  d  d S(   s  
        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.
        i(   Ry   R   t   twisted_renamed_helperi    R   s	   module.pyR   i	   R^   s   A Warning Stringi   N(   R   Ry   Rq   Rr   R   Rx   t   moveToR   R   Rs   Rt   R   Rg   R   R|   R   R   Ri   (   R   Ry   Rk   t
   warnedPatht   expectedPath(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_renamedFilea  s     

	c         C   s]   t  j 2t  j d d d d  d d l m } | j   |  j   } |  j t |  d  d S(	   s   
        L{deprecate.warnAboutFunction} emits a warning that will be filtered if
        L{warnings.filterwarning} is called with the module name of the
        deprecated function.
        t   actiont   ignoreRy   R   i(   Ry   i    N(	   t   warningst   filterst   filterwarningsR   Ry   R   Rg   R   Ri   (   R   Ry   Rk   (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_filteredWarning  s    		
c         C   s   t  j 2t  j d d d d  d d l m } | j   | j   |  j   } |  j t |  d  | d d } | d d	 } | d d
 } | d d } t  j	 | | | |  } |  j
 | j d  d | f  d S(   s   
        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   Ry   R   i(   Ry   i   i    R^   Re   R   R   s=   module.py:9: DeprecationWarning: A Warning String
  return a
s   Unexpected warning string: %rN(   R   R   R   R   Ry   R   Rg   R   Ri   t   formatwarningR3   R4   (   R   Ry   Rk   R^   Re   R   R   t   msg(    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   test_filteredOnceWarning  s     		

(
   R   R-   R"   R`   R   R   R   R   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyR     s   					 	("   R"   Rq   R?   R   t   os.pathR    t   twisted.trial.unittestR   t   twisted.pythonR   t   twisted.python.deprecateR   R   R   R   R   R   t   twisted.python.reflectR	   t   twisted.python.versionsR
   t   twisted.python.filepathR   t   twisted.python.testR   R   R   R   R.   RR   R9   R=   R]   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/twisted/python/test/test_deprecate.pyt   <module>   s,   			EO