o
    ¯b
  ã                   @   s@   d Z ddlmZ ddlmZmZ ddlmZ G dd„ deƒZdS )zš
Tests for L{twisted.internet._baseprocess} which implements process-related
functionality that is useful in all platforms supporting L{IReactorProcess}.
é    )ÚBaseProcess)ÚgetWarningMethodÚsetWarningMethod)ÚTestCasec                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚBaseProcessTestsz·
    Tests for L{BaseProcess}, a parent class for other classes which represent
    processes which implements functionality common to many different process
    implementations.
    c                 C   sN   G dd„ dƒ}t dƒ}t|ƒ ƒ}| |¡ |jj t ¡ |  ||jjj¡ dS )z¸
        L{BaseProcess._callProcessExited} calls the C{processExited} method of
        its C{proto} attribute and passes it a L{Failure} wrapping the given
        exception.
        c                   @   s   e Zd ZdZdd„ ZdS )z:BaseProcessTests.test_callProcessExited.<locals>.FakeProtoNc                 S   s
   || _ d S ©N)Úreason)Úselfr   © r
   úH/usr/lib/python3/dist-packages/twisted/internet/test/test_baseprocess.pyÚprocessExited   s   
zHBaseProcessTests.test_callProcessExited.<locals>.FakeProto.processExited)Ú__name__Ú
__module__Ú__qualname__r   r   r
   r
   r
   r   Ú	FakeProto   s    r   zfake reasonN)ÚRuntimeErrorr   Ú_callProcessExitedÚprotor   ÚtrapÚassertIsÚvalue)r	   r   r   Úprocessr
   r
   r   Útest_callProcessExited   s   

z'BaseProcessTests.test_callProcessExitedc                    sŽ   G dd„ dƒ}t ƒ }t|ƒ ƒ}|  ttƒ ¡ g ‰ ‡ fdd„}t|ƒ | |¡ ˆ \\}}}|  |d|j|jf ¡ |  	|t
¡ |  |d¡ dS )zµ
        L{BaseProcess._callProcessExited} emits a L{DeprecationWarning} if the
        object referred to by its C{proto} attribute has no C{processExited}
        method.
        c                   @   s   e Zd ZdS )zABaseProcessTests.test_callProcessExitedMissing.<locals>.FakeProtoN)r   r   r   r
   r
   r
   r   r   /   s    r   c                    s   ˆ   | ||f¡ d S r   )Úappend)ÚmessageÚcategoryÚ
stacklevel©Úwarningsr
   r   Úcollect8   s   z?BaseProcessTests.test_callProcessExitedMissing.<locals>.collectzXSince Twisted 8.2, IProcessProtocol.processExited is required.  %s.%s must implement it.r   N)Úobjectr   Ú
addCleanupr   r   r   ÚassertEqualr   r   r   ÚDeprecationWarning)r	   r   r   r   r   r   r   r   r
   r   r   Útest_callProcessExitedMissing(   s"   


ÿþz.BaseProcessTests.test_callProcessExitedMissingN)r   r   r   Ú__doc__r   r$   r
   r
   r
   r   r      s    r   N)	r%   Útwisted.internet._baseprocessr   Útwisted.python.deprecater   r   Útwisted.trial.unittestr   r   r
   r
   r
   r   Ú<module>   s
   