
B[~Mc           @   sS  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 y d d l
 Z
 Wn e k
 r e Z
 Z n Xd d l m Z d d l m Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z d d l m Z m Z m Z d d	 l m Z d
 e j  f d     YZ! d e j" f d     YZ# d e j  f d     YZ$ d e j  f d     YZ% d e j  f d     YZ& d e j  f d     YZ' d e% f d     YZ( d e j  f d     YZ) d e) f d     YZ* d e) f d     YZ+ d e j" f d     YZ, d  e j  f d!     YZ- d" f  d#     YZ. d$ e. e j" f d%     YZ/ d& e. e j" f d'     YZ0 d( e j  f d)     YZ1 d* e j" f d+     YZ2 d, e j  f d-     YZ3 d. f  d/     YZ4 d0 e5 f d1     YZ6 d2 e5 f d3     YZ7 e e k	 rd4 e j8 f d5     YZ9 d6 e j: f d7     YZ; d8 e j< f d9     YZ= n  d: e j" f d;     YZ> d< e j" e4 f d=     YZ? d> e j" e4 f d?     YZ@ d@ e' f dA     YZA dB e j" f dC     YZB dD e j" f dE     YZC dF e j" f dG     YZD dH e j" f dI     YZE dJ e j  f dK     YZF dL e j" f dM     YZG dN ZH e jI jJ   dO k pe jK e e  reH e? _L eH e@ _L eH e0 _L eH e2 _L n  e jI jJ   dP k pe jK e e  r'eH eB _L eH e/ _L eH eD _L eH eC _L n  e jK e e  rOeH e, _L eH eG _L n  d S(Q   s   
Test running processes.
iN(   t   process(   t   verifyObject(   t   msg(   t   reactort   protocolt   errort
   interfacest   defer(   t   unittest(   t   utilt   runtimet	   procutils(   t   sett   StubProcessProtocolc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s   
    ProcessProtocol counter-implementation: all methods on this class raise an
    exception, so instances of this may be used to verify that only certain
    methods are called.
    c         C   s   t     d  S(   N(   t   NotImplementedError(   t   selft   data(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   outReceived)   s    c         C   s   t     d  S(   N(   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   errReceived,   s    c         C   s   t     d  S(   N(   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   inConnectionLost/   s    c         C   s   t     d  S(   N(   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   outConnectionLost2   s    c         C   s   t     d  S(   N(   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   errConnectionLost5   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   #   s   				t   ProcessProtocolTestsc           B   sD   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   sj   
    Tests for behavior provided by the process protocol base class,
    L{protocol.ProcessProtocol}.
    c         C   s   t  t j t j    d S(   sD   
        L{ProcessProtocol} implements L{IProcessProtocol}.
        N(   R   R   t   IProcessProtocolR   t   ProcessProtocol(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_interface?   s    c            sX   g    d t  f   f d     Y} d } |   } | j d |  |  j   | g  d S(   s   
        Verify that when stdout is delivered to
        L{ProcessProtocol.childDataReceived}, it is forwarded to
        L{ProcessProtocol.outReceived}.
        t   OutProtocolc              s   e  Z   f d    Z RS(   c            s     j  |  d  S(   N(   t   append(   R   R   (   t   received(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   N   s    (   R   R   R   (    (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   M   s   t   bytesi   N(   R   t   childDataReceivedt   assertEqual(   R   R   R    t   p(    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_outReceivedF   s    	c            sX   g    d t  f   f d     Y} d } |   } | j d |  |  j   | g  d S(   sA   
        Similar to L{test_outReceived}, but for stderr.
        t   ErrProtocolc              s   e  Z   f d    Z RS(   c            s     j  |  d  S(   N(   R   (   R   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   ]   s    (   R   R   R   (    (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR%   \   s   R    i   N(   R   R!   R"   (   R   R%   R    R#   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_errReceivedW   s    	c            sO   g    d t  f   f d     Y} |   } | j d  |  j   d g  d S(   s   
        Verify that when stdin close notification is delivered to
        L{ProcessProtocol.childConnectionLost}, it is forwarded to
        L{ProcessProtocol.inConnectionLost}.
        t   InLostProtocolc              s   e  Z   f d    Z RS(   c            s     j  d   d  S(   N(   R   t   None(   R   (   t   lost(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   n   s    (   R   R   R   (    (   R)   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR'   m   s   i    N(   R   t   childConnectionLostR"   R(   (   R   R'   R#   (    (   R)   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_inConnectionLostf   s
    	c            sO   g    d t  f   f d     Y} |   } | j d  |  j   d g  d S(   sF   
        Similar to L{test_inConnectionLost}, but for stdout.
        t   OutLostProtocolc              s   e  Z   f d    Z RS(   c            s     j  d   d  S(   N(   R   R(   (   R   (   R)   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   |   s    (   R   R   R   (    (   R)   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR,   {   s   i   N(   R   R*   R"   R(   (   R   R,   R#   (    (   R)   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_outConnectionLostv   s
    	c            sO   g    d t  f   f d     Y} |   } | j d  |  j   d g  d S(   sF   
        Similar to L{test_inConnectionLost}, but for stderr.
        t   ErrLostProtocolc              s   e  Z   f d    Z RS(   c            s     j  d   d  S(   N(   R   R(   (   R   (   R)   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR      s    (   R   R   R   (    (   R)   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR.      s   i   N(   R   R*   R"   R(   (   R   R.   R#   (    (   R)   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_errConnectionLost   s
    	(	   R   R   R   R   R$   R&   R+   R-   R/   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   :   s   					t   TrivialProcessProtocolc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s   
    Simple process protocol for tests purpose.

    @ivar outData: data received from stdin
    @ivar errData: data received from stderr
    c         C   s   | |  _  g  |  _ g  |  _ d S(   sl   
        Create the deferred that will be fired at the end, and initialize
        data structures.
        N(   t   deferredt   outDatat   errData(   R   t   d(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   __init__   s    		c         C   s   | |  _  |  j j d   d  S(   N(   t   reasonR1   t   callbackR(   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   processEnded   s    	c         C   s   |  j  j |  d  S(   N(   R2   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR      s    c         C   s   |  j  j |  d  S(   N(   R3   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR      s    (   R   R   R   R5   R8   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR0      s
   				t   TestProcessProtocolc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s2   d g |  _  d |  _ d |  _ |  j j d  d  S(   Ni   t    t   abcd(   t   stagesR   t   errt	   transportt   write(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   connectionMade   s    		c         C   s@   | d k r |  j  | 7_  n | d k r< |  j | 7_ n  d S(   s   
        Override and disable the dispatch provided by the base class to ensure
        that it is really this method which is being called, and the transport
        is not going directly to L{outReceived} or L{errReceived}.
        i   i   N(   R   R=   (   R   t   childFDR   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR!      s    c         C   s   | d k rG |  j  j d  |  j d k r4 t  n  |  j j d  n | d k r |  j  j d  |  j d k r d t |  j  GHt    n  |  j j d  |  j  j d  n | d k r |  j  j d	  n  d
 S(   s   
        Similarly to L{childDataReceived}, disable the automatic dispatch
        provided by the base implementation to verify that the transport is
        calling this method directly.
        i   i   R;   t   1234i   s   err != 1234: i   i    i   N(   R<   R   R   t   RuntimeErrorR>   R?   R=   t   repr(   R   RA   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR*      s    	c         C   s   | |  _  |  j j d   d  S(   N(   R6   R1   R7   R(   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8      s    	(   R   R   R@   R!   R*   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR9      s   			t   EchoProtocolc           B   sH   e  Z d  d Z d Z d Z d Z d   Z d   Z d   Z	 d   Z
 RS(	   t   1234567i  i
   i    c         C   s   | |  _  d |  _ d  S(   Ni    (   t   onEndedt   count(   R   RG   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5      s    	c         C   sy   |  j  d k s t  x. t |  j  d  D] } |  j j |  j  q) W|  j j |  j |  j g  |  j |  j  |  _ d  S(   Ni   (   t   nt   AssertionErrort   rangeR>   R?   t   st   writeSequencet   buffer(   R   t   i(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR@      s
    c         C   s   t  |  j  |  j t |   t  |  k rO d | |  j f |  _ |  j j   n= |  j t |  7_ |  j t |  j   k r |  j j   n  d  S(   Ns   wrong bytes received(   RN   RH   t   lent   failureR>   t
   closeStdin(   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR      s    *c         C   sE   d |  _  | j t j  s1 d t |  |  _ n  |  j j |   d  S(   Ni   s#   process didn't terminate normally: (   t   finishedt   checkR   t   ProcessDonet   strRQ   RG   R7   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8      s    	N(   R   R   RL   RI   RS   R(   RQ   R5   R@   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRE      s   
				t   SignalProtocolc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s  
    A process protocol that sends a signal when data is first received.

    @ivar deferred: deferred firing on C{processEnded}.
    @type deferred: L{defer.Deferred}

    @ivar signal: the signal to send to the process.
    @type signal: C{str}

    @ivar signaled: A flag tracking whether the signal has been sent to the
        child or not yet.  C{False} until it is sent, then C{True}.
    @type signaled: C{bool}
    c         C   s   | |  _  | |  _ t |  _ d  S(   N(   R1   t   signalt   Falset   signaled(   R   R1   t   sig(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5     s    		c         C   s=   t  d | f  |  j s9 t |  _ |  j j |  j  n  d S(   s   
        Handle the first output from the child process (which indicates it
        is set up and ready to receive the signal) by sending the signal to
        it.  Also log all output to help with debugging.
        s   Received %r from child stdoutN(   R   RZ   t   TrueR>   t   signalProcessRX   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    		c         C   s   t  d | f  d S(   s_   
        Log all data received from the child's stderr to help with
        debugging.
        s   Received %r from child stderrN(   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   #  s    c         C   sK  t  d | j   f  | j t j  sF |  j j t d | f   S| j } t	 |  j
 t  rz t t
 d |  j
  } n	 |  j
 } | j d k	 r |  j j t d |  j
 | j f   S| j
 | k r |  j j t d |  j
 | j
 | f   St j | j  | k r7|  j j t d |  j
 t j | j  f   S|  j j d  d S(   sL  
        Callback C{self.deferred} with C{None} if C{reason} is a
        L{error.ProcessTerminated} failure with C{exitCode} set to C{None},
        C{signal} set to C{self.signal}, and C{status} holding the status code
        of the exited process. Otherwise, errback with a C{ValueError}
        describing the problem.
        s   Child exited: %rs   wrong termination: %st   SIGs   SIG%s: exitCode is %s, not Nones    SIG%s: .signal was %s, wanted %ss	   SIG%s: %sN(   R   t   getTracebackRT   R   t   ProcessTerminatedR1   t   errbackt
   ValueErrort   valuet
   isinstanceRX   RV   t   getattrt   exitCodeR(   t   ost   WTERMSIGt   statusR7   (   R   R6   t   vt   signalValue(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8   +  s(    						&(   R   R   R   R5   R   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRW     s
   			t   TestManyProcessProtocolc           B   s   e  Z d    Z d   Z RS(   c         C   s   t  j   |  _ d  S(   N(   R   t   DeferredR1   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5   L  s    c         C   sB   | |  _  | j t j  r. |  j j d   n |  j j |  d  S(   N(   R6   RT   R   RU   R1   R7   R(   Ra   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8   O  s    	(   R   R   R5   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRl   K  s   	t   UtilityProcessProtocolc           B   s_   e  Z d  Z d Z d   Z e e  Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z RS(	   s   
    Helper class for launching a Python process and getting a result from it.

    @ivar program: A string giving a Python program for the child process to
    run.
    c         C   s?   t  j } |    } | j | | | d | j g | d | | S(   s9  
        Run a Python process connected to a new instance of this protocol
        class.  Return the protocol instance.

        The Python process is given C{self.program} on the command line to
        execute, in addition to anything specified by C{argv}.  C{env} is
        the complete environment.
        s   -ct   env(   t   syst
   executablet   spawnProcesst   program(   t   clsR   t   argvRo   t   exeR   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   runa  s
    			#c         C   s   g  |  _  g  |  _ d  S(   N(   R    t   requests(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5   r  s    	c         C   s   t     d S(   sR   
        Called with all bytes received on stdout when the process exits.
        N(   R   (   R   R    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   parseChunksw  s    c         C   s    t  j   } |  j j |  | S(   s{   
        Return a Deferred which will fire with the result of L{parseChunks}
        when the child process exits.
        (   R   Rm   Rx   R   (   R   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   getResult~  s    c         C   s4   |  j  } d |  _  x | D] } | j |  q Wd S(   st   
        Callback all Deferreds returned up until now by L{getResult}
        with the given result object.
        N(   Rx   R(   R7   (   R   t   resultRx   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _fireResultDeferreds  s    		c         C   s   |  j  j |  d S(   sE   
        Accumulate output from the child process in a list.
        N(   R    R   (   R   R    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s   |  j  |  j |  j   d S(   su   
        Handle process termination by parsing all received output and firing
        any waiting Deferreds.
        N(   R|   Ry   R    (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    N(   R   R   R   R(   Rs   Rw   t   classmethodR5   Ry   Rz   R|   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRn   X  s   				
		t   GetArgumentVectorc           B   s   e  Z d  Z d Z d   Z RS(   sl   
    Protocol which will read a serialized argv from a process and
    expose it to interested parties.
    sL   from sys import stdout, argv
stdout.write(chr(0).join(argv))
stdout.flush()
c         C   s   d j  |  j d  S(   s   
        Parse the output from the process to which this protocol was
        connected, which is a single unterminated line of \0-separated
        strings giving the argv of that process.  Return this as a list of
        str objects.
        R:   t    (   t   joint   split(   R   t   chunks(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRy     s    (   R   R   R   Rs   Ry   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR~     s   t   GetEnvironmentDictionaryc           B   s   e  Z d  Z d Z d   Z RS(   sx   
    Protocol which will read a serialized environment dict from a process
    and expose it to interested parties.
    s   from sys import stdout
from os import environ
items = environ.iteritems()
stdout.write(chr(0).join([k + chr(0) + v for k, v in items]))
stdout.flush()
c         C   sy   d j  |  } | s i  St | j d   } i  } x> y | j   } Wn t k
 r[ Pq7 X| j   } | | | <q7 | S(   s  
        Parse the output from the process to which this protocol was
        connected, which is a single unterminated line of \0-separated
        strings giving key value pairs of the environment from that process.
        Return this as a dictionary.
        R:   R   (   R   t   iterR   t   nextt   StopIteration(   R   R   t   environStringt   environR4   t   kRj   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRy     s    (   R   R   R   Rs   Ry   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s   t   ProcessTestCasec           B   s   e  Z d  Z e Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d Z d	 Z g  i  d
  Z d   Z d   Z d   Z RS(   s   Test running a process.c      
      s   t  j } t j t d  } t    t j   }  _ i t	 j
 j t  j  d 6} t j  | | d | g d | d d d   j  j j d   j j d   j j d	   j j      f d
   } | j |  S(   s   twisted.internet.stdio test.s   process_twisted.pyt
   PYTHONPATHs   -uRo   t   patht   usePTYs   hello, worldt   abct   123c            s<     j   j j   d d  j j    j j   f  d  S(   Ns   hello, worldabc123sB   Output follows:
%s
Error message from process_twisted follows:
%s
(   t   assertEqualst   outFt   getvaluet   errF(   t   ign(   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    N(   Rp   Rq   R	   t   sibpatht   __file__t   AccumulatorR   Rm   t   endedDeferredRg   t   pathsepR   R   R   Rr   R(   R   R>   R?   RR   t   addCallback(   R   Rv   t
   scriptPathR4   Ro   R8   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   testStdio  s    		!c            s   t  j   } t |  } t j } t j t d  } t j	 | | | | g d d    j  j     f d   } | j j   | j |  S(   s   
        Test if pid is None/non-None before/after process termination.  This
        reuses process_echoer.py to get a process that blocks on stdin.
        s   process_echoer.pyRo   c            s     j   j d   d  S(   N(   R"   t   pidR(   (   t   ignored(   R   t	   procTrans(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   afterProcessEnd  s    N(   R   Rm   R0   Rp   Rq   R	   R   R   R   Rr   R(   t
   failUnlessR   R>   RR   R   (   R   RS   R#   Rv   R   R   (    (   R   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_unsetPid  s    	c            s~   t  j } t j t d  } t j   } t    |  _ t	 j
  | | d | g d d    f d   } | j |  | S(   sp   
        Test running a process: check its output, it exitCode, some property of
        signalProcess.
        s   process_tester.pys   -uRo   c            s     j   j d d d d d g   j } | j t j    j  | j j d    j t j	  j
 j d  yF d d  l } d d  l } x' | j | j  D] } t j |  q WWn n Xd  S(	   Ni   i   i   i   i   i   t   INTi(   R   R<   R6   t   trapR   R`   Rc   Rf   t   assertRaisest   ProcessExitedAlreadyR>   R]   t   process_testert   globt   test_file_matchRg   t   remove(   R   t   fR   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRT     s    "	N(   Rp   Rq   R	   R   R   R   Rm   R9   R1   R   Rr   R(   R   (   R   Rv   R   R4   RT   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_process  s    			"c   
         s     f d   } t  j } t j t d  } | d | g } g  } g  } xS t d  D]E } t   } | j |  t j	 | | | d d  | j | j  qR Wt j | d t }	 |	 j | |  |	 S(   Nc            s   x~ | D]v }   j  | j d d d d d g d t | j  t | j  f  | j } | j t j    j  | j	 j
 d  q Wd  S(   Ni   i   i   i   i   s   [%d] stages = %si   (   R   R<   t   idR>   RV   R6   R   R   R`   Rc   Rf   (   t   resultst	   protocolsR#   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _check,  s
    A	s   process_tester.pys   -ui2   Ro   t   consumeErrors(   Rp   Rq   R	   R   R   t   xrangeRl   R   R   Rr   R(   R1   R   t   DeferredListR\   R   (
   R   R   Rv   R   t   argsR   t	   deferredsRO   R#   t   deferredList(    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testManyProcesses*  s    		c            s   t  j   } t |   t j } t j t d  } t j	  | | | g d d    f d   }  f d   } | j |  j |  S(   s   
        A spawning a subprocess which echoes its stdin to its stdout via
        C{reactor.spawnProcess} will result in that echoed output being
        delivered to outReceived.
        s   process_echoer.pyRo   c            sb     j   j  j    j t  d     j t d j  j   t  j  j	   d  S(   NRN   R:   (
   t   failIfRQ   R   t   hasattrR   RP   R   RN   RL   RI   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   assertsR  s    c            s     j  j   |  S(   N(   R>   RR   (   R=   (   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   takedownProcessW  s    N(   R   Rm   RE   Rp   Rq   R	   R   R   R   Rr   R(   R   t
   addErrback(   R   RS   Rv   R   R   R   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   test_echoE  s    	c      	      s   d d d d d d d d d	 g	  t  j } t j t d
  } t    t j   }  _ t	 j
  | | d | g  d d  d d      f d   } | j |  S(   Ns   a\"b s   a\b s    a\\"bs    a\\bs   "foo bar" "s   	abs   "\s   a"bs   a'bs   process_cmdline.pys   -uRo   R   c            sB     j   j j   d   j j   j   }   j  |   d  S(   NR:   (   R   R   R   R   t
   splitlines(   R   t	   recvdArgs(   R   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8   g  s    (   Rp   Rq   R	   R   R   R   R   Rm   R   R   Rr   R(   R   (   R   t   pyExeR   R4   R8   (    (   R   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testCommandLine^  s    !		%c      	   C   s=  t  j } t j   } i d d 6i d d 6i d d 6i d d 6g } | d g d | d g g } d	 } y | j t  j    WnL t k
 r | j i d
 | 6 | j i | d 6 | j | | g  n Xx9 | D]1 } |  j t	 t
 j | | | d d g d | q Wx0 | D]( } |  j t	 t
 j | | | d d qWd S(   s   
        Test invalid arguments to spawnProcess: arguments and environment
        must only contains string or unicode, and not null bytes.
        i   t   foot   egg at   bari   t   bar foot   spamt   foo baru   ☃s   value for bad unicode keys   key for bad unicode values   -cR:   Ro   N(   Rp   Rq   R   R   t   encodet   getdefaultencodingt   UnicodeEncodeErrorR   R   t	   TypeErrorR   Rr   R(   (   R   Rv   R#   t   badEnvst   badArgst
   badUnicodeRo   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_wrongArgumentsn  s0    	


		&u   UNICODEt   UNICODEc         C   sS   |  j  |  j j t j    |  j  |  j t d t | j	 t
 | |  } | j   S(   s  
        Check that a deprecation warning is emitted when passing unicode to
        spawnProcess for an argv value or an environment key or value.
        Check that the warning is of the right type, has the right message,
        and refers to the correct file.  Unfortunately, don't check that the
        line number is correct, because that is too hard for me to figure
        out.

        @param processProtocolClass: A L{UtilityProcessProtocol} subclass
        which will be instantiated to communicate with the child process.

        @param argv: The argv argument to spawnProcess.

        @param env: The env argument to spawnProcess.

        @return: A Deferred which fires when the test is complete.
        sg   Argument strings and environment keys/values passed to reactor.spawnProcess should be str, not unicode.(   R"   t   okayUnicodeR   Rp   R   t   encodedValuet   assertWarnst   DeprecationWarningR   Rw   R   Rz   (   R   t   processProtocolClassRu   Ro   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _deprecatedUnicodeSupportTest  s    
	c            s;     j  t d   j g }   f d   } | j |  | S(   s   
        Test that a unicode string passed for an argument value is allowed
        if it can be encoded with the default system encoding, but that a
        deprecation warning is emitted.
        Ru   c            s     j  |  d   j g  d  S(   Ns   -c(   R"   R   (   Ru   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   gotArgVector  s    (   R   R~   R   R   (   R   R4   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt!   test_deprecatedUnicodeArgvSupport  s    c            sB     j  t d i   j   j 6}   f d   } | j |  | S(   s   
        Test that a unicode string passed for the key of the environment
        dictionary is allowed if it can be encoded with the default system
        encoding, but that a deprecation warning is emitted.
        Ro   c            s     j  |    j   j  d  S(   N(   R"   R   (   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   gotEnvironment  s    (   R   R   R   R   R   (   R   R4   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt#   test_deprecatedUnicodeEnvKeySupport  s
    c            sB     j  t d i   j   j 6}   f d   } | j |  | S(   s   
        Test that a unicode string passed for the value of the environment
        dictionary is allowed if it can be encoded with the default system
        encoding, but that a deprecation warning is emitted.
        Ro   c            s     j  |    j   j  d  S(   N(   R"   R   (   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    (   R   R   R   R   R   (   R   R4   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt%   test_deprecatedUnicodeEnvValueSupport  s
    (   R   R   R   RY   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s   							6 		t   TwoProcessProtocolc           B   s/   e  Z d  Z d Z d   Z d   Z d   Z RS(   ii    c         C   s   t  j   |  _ d  S(   N(   R   Rm   R1   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5     s    c         C   s   d  S(   N(    (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s   d |  _  |  j j d   d  S(   Ni   (   RS   R1   R7   R(   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    	(   R   R   t   numRS   R5   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s
   		t   TestTwoProcessesBasec           B   s8   e  Z d    Z d d  Z d   Z d   Z d   Z RS(   c         C   s4   d  d  g |  _ d  d  g |  _ d |  _ d |  _ d  S(   Ni    (   R(   t	   processest   ppt   donet   verbose(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   setUp  s    	i    c      	   C   s   t  j } t j t d  } xl d D]d } t   |  j | <| |  j | _ t j	 |  j | | | d | g d d  d | } | |  j | <q" Wd  S(   Ns   process_reader.pyi    i   s   -uRo   R   (   i    i   (   Rp   Rq   R	   R   R   R   R   R   R   Rr   R(   R   (   R   R   Rv   R   R   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   createProcesses  s    		c         C   sy   |  j  r d | GHn  |  j | } |  j | } |  j | j d  | j   |  j  ru |  j d j G|  j d j GHn  d  S(   Ns   closing stdin [%d]s   Process finished too earlyi    i   (   R   R   R   R   RS   t   loseConnection(   R   R   R#   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   close  s    	 
	 c         C   s&   t  j g  |  j D] } | j ^ q  S(   N(   R   t   gatherResultsR   R1   (   R   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _onClose  s    c         C   sQ   |  j  r d GHn  |  j   t j d |  j d  t j d |  j d  |  j   S(   Ns   starting processesi   i    i   (   R   R   R   t	   callLaterR   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   testClose  s    	 
(   R   R   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR      s
   			t   TestTwoProcessesNonPosixc           B   s   e  Z RS(    (   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   $  s   t   TestTwoProcessesPosixc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   sj   x] t  |  j |  j  D]F \ } } | j s y t j | j t j  Wq\ t	 k
 rX q\ Xq q W|  j
   S(   N(   t   zipR   R   RS   Rg   t   killR   RX   t   SIGTERMt   OSErrorR   (   R   R   t   pr(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   tearDown(  s    "	c         C   s   |  j  r d | GHn  |  j | } |  j | } |  j | j d  t j | j t j	  |  j  r |  j d j G|  j d j GHn  d  S(   Ns   kill [%d] with SIGTERMs   Process finished too earlyi    i   (
   R   R   R   R   RS   Rg   R   R   RX   R   (   R   R   R#   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   3  s    	 	 c         C   sW   |  j  r d GHn  |  j d d  t j d |  j d  t j d |  j d  |  j   S(   Ns   starting processesR   i    i   i   (   R   R   R   R   R   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testKill;  s    	 c         C   sW   |  j  r d GHn  |  j d d  t j d |  j d  t j d |  j d  |  j   S(   Ns   starting processesR   i   i    i   (   R   R   R   R   R   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testClosePtyB  s    	 c         C   sW   |  j  r d GHn  |  j d d  t j d |  j d  t j d |  j d  |  j   S(   Ns   starting processesR   i   i    i   (   R   R   R   R   R   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testKillPtyI  s    	 (   R   R   R   R   R   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   '  s
   				t	   FDCheckerc           B   sP   e  Z d  Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(	   i    R:   c         C   s   | |  _  d  S(   N(   R1   (   R   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5   U  s    c         C   s   | |  _  |  j j d   d  S(   N(   t   failedR1   R7   R(   (   R   t   why(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   failX  s    	c         C   s    |  j  j d d  d |  _ d  S(   Ni    R;   i   (   R>   t   writeToChildt   state(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR@   \  s    c         C   s  |  j  d k r | d k r6 |  j d | | f  d  S|  j | 7_ t |  j  d k r |  j d k r |  j d |  j  d  Sd |  _ d |  _  |  j j d d	  d  Sn  |  j  d k r |  j d
 | | f  d  S|  j  d k rh| d k r|  j d | | f  d  S|  j | 7_ t |  j  d k rd|  j d k rX|  j d |  j  d  Sd |  _  n  d  S|  j  d k r|  j d | | f  d  Sd  S(   Ni   s)   read '%s' on fd %d (not 1) during state 1i   t   rightos"   got '%s' on fd1, expected 'righto'R:   i   i   t   efghs!   read '%s' on fd %s during state 2s)   read '%s' on fd %s (not 1) during state 3t   closeds"   got '%s' on fd1, expected 'closed'i   s!   read '%s' on fd %s during state 4(   R   R   R   RP   R>   R   (   R   RA   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR!   `  sD    						c         C   su   |  j  d k r$ |  j d |  d  S|  j  d k rq | d k rT |  j d |  d  Sd |  _  |  j j d  d  Sd  S(   Ni   s%   got connectionLost(%d) during state 1i   i   s-   got connectionLost(%d) (not 4) during state 2i   i   (   R   R   R>   t   closeChildFD(   R   RA   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR*     s    		c         C   s   | j  j } |  j d k r0 |  j d |  d  S| j  j d  k r] |  j d | j  j  d  S| d k r~ |  j d |  d  S|  j j d   d  S(   Ni   s   processEnded early, rc %ds   processEnded with signal %si    s   processEnded with rc %d(   Rc   Rf   R   R   RX   R(   R1   R7   (   R   Ri   t   rc(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    N(   R   R   R   R   R(   R   R5   R   R@   R!   R*   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   P  s   				&	t   FDTestc           B   s   e  Z d    Z d   Z RS(   c            s   t  j } t j t d  } t j   } t |   t j	  | | d | g d d  d d  d i d d 6d d	 6d
 d
 6d d 6d d 6d d 6| j    f d    | S(   Ns   process_fds.pys   -uRo   R   t   childFDst   wi    t   ri   i   i   i   i   c            s     j   j  j  S(   N(   R   R   (   t   x(   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   <lambda>  s    (   Rp   Rq   R	   R   R   R   Rm   R   R   Rr   R(   R   (   R   Rv   R   R4   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testFD  s    	!c            s   t  j } t j t d  } t    t j   }  _ t	 j
  | | d | g d d  d d  d i d d 6d d 6   f d	   } | j |  S(
   Ns   process_linger.pys   -uRo   R   R  R  i   i   c            s     j   j j   d  d  S(   Ns   here is some text
goodbye
(   t   failUnlessEqualR   R   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    (   Rp   Rq   R	   R   R   R   R   Rm   R   R   Rr   R(   R   (   R   Rv   R   R4   R8   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt
   testLinger  s    		!(   R   R   R  R	  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   	R   c           B   sP   e  Z d  Z d Z d Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z RS(	   s   Accumulate data from a process.i    c         C   s"   t  j    |  _ t  j    |  _ d  S(   N(   t   StringIOR   R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR@     s    c         C   s   |  j  j |  d  S(   N(   R   R?   (   R   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s   |  j  j |  d  S(   N(   R   R?   (   R   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s   d  S(   N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s   d  S(   N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    c         C   s?   d |  _  |  j d  k	 r; |  j d  } |  _ | j d   n  d  S(   Ni   (   R   R   R(   R7   (   R   R6   R4   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    	N(   R   R   R   R   R(   R   R@   R   R   R   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s   					t   PosixProcessBasec           B   sw   e  Z d  Z 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(   s!   
    Test running processes.
    c         C   si   t  j j d | f  r) d | f } n< t  j j d | f  rR d | f } n t d | f   | S(   sq   
        Return the path of the shell command named C{commandName}, looking at
        common locations.
        s   /bin/%ss   /usr/bin/%ss    %s not found in /bin or /usr/bin(   Rg   R   t   existsRC   (   R   t   commandNamet   cmd(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt
   getCommand  s    c            so     j  d  } t j   } t |   t j  | d g d d  d   j    f d   } | j |  | S(   Nt   trueRo   R   c            sI    j  j t j    j  j  j j d    j  j  j j d   d  S(   Ni    (	   R6   R   R   RU   R   Rc   Rf   RX   R(   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRT     s    (	   R  R   Rm   R0   R   Rr   R(   R   R   (   R   R  R4   RT   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testNormalTermination  s    
c            so   t  j } t j   } t |   t j  | | d d g d d d   j    f d   } | j	 |  | S(   s   
        When a process terminates with a system exit code set to 1,
        C{processEnded} is called with a L{error.ProcessTerminated} error,
        the C{exitCode} attribute reflecting the system exit code.
        s   -cs   import sys; sys.exit(1)Ro   R   c            sI    j  j t j    j  j  j j d    j  j  j j d   d  S(   Ni   (	   R6   R   R   R`   R   Rc   Rf   RX   R(   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRT     s    N(
   Rp   Rq   R   Rm   R0   R   Rr   R(   R   R   (   R   Rv   R4   RT   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_abnormalTermination  s    	c         C   se   t  j } t j t d  } t j   } t | |  } t j	 | | | d | g d d  d |  j | S(   Ns   process_signal.pys   -uRo   R   (   Rp   Rq   R	   R   R   R   Rm   RW   R   Rr   R(   R   (   R   R[   Rv   R   R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _testSignal  s    	!
c         C   s   |  j  d  S(   si  
        Sending the SIGHUP signal to a running process interrupts it, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} set to C{None} and the C{signal} attribute set to
        C{signal.SIGHUP}. C{os.WTERMSIG} can also be used on the C{status}
        attribute to extract the signal value.
        t   HUP(   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_signalHUP!  s    c         C   s   |  j  d  S(   si  
        Sending the SIGINT signal to a running process interrupts it, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} set to C{None} and the C{signal} attribute set to
        C{signal.SIGINT}. C{os.WTERMSIG} can also be used on the C{status}
        attribute to extract the signal value.
        R   (   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_signalINT,  s    c         C   s   |  j  d  S(   sk  
        Sending the SIGKILL signal to a running process interrupts it, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} set to C{None} and the C{signal} attribute set to
        C{signal.SIGKILL}. C{os.WTERMSIG} can also be used on the C{status}
        attribute to extract the signal value.
        t   KILL(   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_signalKILL7  s    c         C   s   |  j  d  S(   sk  
        Sending the SIGTERM signal to a running process interrupts it, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} set to C{None} and the C{signal} attribute set to
        C{signal.SIGTERM}. C{os.WTERMSIG} can also be used on the C{status}
        attribute to extract the signal value.
        t   TERM(   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_signalTERMB  s    c         C   sG   t  j } t  j  | t  j  } |  j t  j  t  j |  |  j t  j  S(   s   
        The disposition of signals which are ignored in the parent
        process is reset to the default behavior for the child
        process.
        (   RX   t   SIGUSR1t   SIG_IGNt
   addCleanupR  (   R   t   whicht   handler(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_childSignalHandlingM  s    	c            s     j  d  } t j   } t |   d   } t j } | t _ zH t j  | d g d d d   j	    f d   } | j
 |  Wd | t _ X| S(   sJ   
        Raise an error during execvpe to check error management.
        t   falsec         S   s   t  d   d  S(   Nt   Ouch(   RC   (   t   commandR   t   environment(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   buggyexecvpep  s    Ro   R   c            s=   d j   j  j  }   j d |    j d |  d  S(   NR:   s   Upon execvpeR"  (   R   R3   R2   t   assertIn(   R   R3   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRT   x  s    N(   R  R   Rm   R0   Rg   t   execvpeR   Rr   R(   R   R   (   R   R  R4   R%  t
   oldexecvpeRT   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_executionErrorh  s    			

c            s   t  j    t  j    t j } t j t d  } d t j f   f d     Y} t	 j
 |   | | | g d d d d g      f d   }  j |     f d   }  j |   S(	   s   
        The handler which reaps a process is removed when the process is
        reaped, even if the protocol's C{processEnded} method raises an
        exception.
        s   process_twisted.pyt   ErrorInProcessEndedc              s,   e  Z d  Z  f d   Z   f d   Z RS(   sM   
            A protocol that raises an error in C{processEnded}.
            c            s     j  |  d  S(   N(   R7   (   R   R>   (   t	   connected(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   makeConnection  s    c            s&   t  j d   j d   t d   d  S(   Ni    s   Deliberate error(   R   R   R7   R(   RC   (   R   R6   (   t   ended(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    (   R   R   R   R,  R8   (    (   R-  R+  (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR*    s   Ro   R   c            s4    j  |  j    j |  j t j  |  j   d  S(   N(   R   R   R&  R    t   reapProcessHandlersR   (   R>   (   R   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   cbConnected  s    c            s@     j  t  }   j t |  d    j  d t j  d  S(   Ni   i    (   t   flushLoggedErrorsRC   R"   RP   t   assertNotInR    R.  (   R   t   excs(   R   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   checkTerminated  s    N(   R   Rm   Rp   Rq   R	   R   R   R   R   R   Rr   R(   R   (   R   t   pythonExecutableR   R*  R/  R3  (    (   R   R   R-  R+  s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_errorInProcessEnded  s    	"	(   R   R   R   RY   R   R  R  R  R  R  R  R  R  R   R)  R5  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   				
						t
   MockSignalc           B   s    e  Z d  Z d   Z d   Z RS(   sF   
    Neuter L{signal.signal}, but pass other attributes unscathed
    c         C   s   t  j |  S(   N(   RX   t	   getsignal(   R   R[   t   action(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRX     s    c         C   s   t  t |  S(   N(   Re   RX   (   R   t   attr(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   __getattr__  s    (   R   R   R   RX   R:  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR6    s   	t   MockOSc           B   sj  e  Z d  Z e Z e Z d" Z e Z	 d" Z
 d" Z d" Z d Z d Z d" Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d   Z- d    Z. d!   Z/ RS(#   sh  
    The mock OS: overwrite L{os}, L{fcntl} and {sys} functions with fake ones.

    @ivar exited: set to True when C{_exit} is called.
    @type exited: C{bool}

    @ivar O_RDWR: dumb value faking C{os.O_RDWR}.
    @type O_RDWR: C{int}

    @ivar O_NOCTTY: dumb value faking C{os.O_NOCTTY}.
    @type O_NOCTTY: C{int}

    @ivar WNOHANG: dumb value faking C{os.WNOHANG}.
    @type WNOHANG: C{int}

    @ivar raiseFork: if not C{None}, subsequent calls to fork will raise this
        object.
    @type raiseFork: C{NoneType} or C{Exception}

    @ivar raiseExec: if set, subsequent calls to execvpe will raise an error.
    @type raiseExec: C{bool}

    @ivar fdio: fake file object returned by calls to fdopen.
    @type fdio: C{StringIO.StringIO}

    @ivar actions: hold names of some actions executed by the object, in order
        of execution.

    @type actions: C{list} of C{str}

    @ivar closed: keep track of the file descriptor closed.
    @param closed: C{list} of C{int}

    @ivar child: whether fork return for the child or the parent.
    @type child: C{bool}

    @ivar pipeCount: count the number of time that C{os.pipe} has been called.
    @type pipeCount: C{int}

    @ivar raiseWaitPid: if set, subsequent calls to waitpid will raise an
        the error specified.
    @type raiseWaitPid: C{None} or a class

    @ivar waitChild: if set, subsequent calls to waitpid will return it.
    @type waitChild: C{None} or a tuple

    @ivar euid: the uid returned by the fake C{os.geteuid}
    @type euid: C{int}

    @ivar egid: the gid returned by the fake C{os.getegid}
    @type egid: C{int}

    @ivar seteuidCalls: stored results of C{os.seteuid} calls.
    @type seteuidCalls: C{list}

    @ivar setegidCalls: stored results of C{os.setegid} calls.
    @type setegidCalls: C{list}

    @ivar path: the path returned by C{os.path.expanduser}.
    @type path: C{str}
    i    c         C   sd   g  |  _  g  |  _ d |  _ d |  _ d |  _ d |  _ d   |  _ d   |  _ g  |  _ g  |  _	 d S(   s-   
        Initialize data structures.
        i    iiic         S   s   d S(   Ni    (    (   R  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s    c         S   s   d S(   Ni   (    (   R  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s    N(
   t   actionsR   t	   pipeCountt   O_RDWRt   O_NOCTTYt   WNOHANGt   WEXITSTATUSt	   WIFEXITEDt   seteuidCallst   setegidCalls(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5   
  s    							c         C   s   d S(   se   
        Fake C{os.open}. Return a non fd number to be sure it's not used
        elsewhere.
        i(    (   R   t   devt   flags(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   open  s    c         C   s   t  j d  S(   sT   
        Fake C{os.fstat}.  Return a C{os.stat_result} filled with garbage.
        i    i
   (   i    (
   i    i    i    i    i    i    i    i    i    i    (   Rg   t   stat_result(   R   t   fd(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   fstat"  s    c         C   s   t  j    |  _ |  j S(   sy   
        Fake C{os.fdopen}. Return a StringIO object whose content can be tested
        later via C{self.fdio}.
        (   R
  t   fdio(   R   RI  t   flag(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   fdopen)  s    c         C   s   d S(   s0   
        Fake C{os.setsid}. Do nothing.
        N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   setsid2  s    c         C   sL   |  j  j d t j   f  |  j d k	 r7 |  j  n |  j rD d Sd Sd S(   s   
        Fake C{os.fork}. Save the action in C{self.actions}, and return 0 if
        C{self.child} is set, or a dumb number.
        t   forki    i   N(   R<  R   t   gct	   isenabledt	   raiseForkR(   t   child(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRO  8  s    	c         C   s   |  j  j |  d S(   sK   
        Fake C{os.close}, saving the closed fd in C{self.closed}.
        N(   R   R   (   R   RI  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   G  s    c         C   s   d S(   s.   
        Fake C{os.dup2}. Do nothing.
        N(    (   R   t   fd1t   fd2(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   dup2N  s    c         C   s   d S(   s/   
        Fake C{os.write}. Do nothing.
        N(    (   R   RI  R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR?   T  s    c         C   s,   |  j  j d  |  j r( t d   n  d S(   sn   
        Fake C{os.execvpe}. Save the action, and raise an error if
        C{self.raiseExec} is set.
        t   exect   BarN(   R<  R   t	   raiseExecRC   (   R   R#  R   Ro   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR'  Z  s    	c         C   s+   |  j  d 7_  d |  j  d d |  j  f S(   s   
        Fake C{os.pipe}. Return non fd numbers to be sure it's not used
        elsewhere, and increment C{self.pipeCount}. This is used to uniquify
        the result.
        i   i(   R=  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   piped  s    c         C   s   d S(   s;   
        Fake C{os.ttyname}. Return a dumb string.
        R   (    (   R   RI  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   ttynamen  s    c         C   s&   |  j  j d  t |  _ t    d S(   ss   
        Fake C{os._exit}. Save the action, set the C{self.exited} flag, and
        raise C{SystemError}.
        t   exitN(   R<  R   R\   t   exitedt   SystemError(   R   t   code(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _exitu  s    	c         C   s   d S(   s6   
        Override C{fcntl.ioctl}. Do nothing.
        N(    (   R   RI  RF  t   arg(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   ioctl  s    c         C   s   d S(   s?   
        Override C{fdesc.setNonBlocking}. Do nothing.
        N(    (   R   RI  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   setNonBlocking  s    c         C   sE   |  j  j d  |  j d k	 r+ |  j  n  |  j d k	 rA |  j Sd S(   s   
        Override C{os.waitpid}. Return values meaning that the child process
        has exited, save executed action.
        t   waitpidi   i    N(   i   i    (   R<  R   t   raiseWaitPidR(   t	   waitChild(   R   R   t   options(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRd    s    c         C   s   d S(   sD   
        Override C{sys.settrace} to keep coverage working.
        N(    (   R   Ra  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   settrace  s    c         C   s   d S(   s>   
        Override C{os.getgid}. Return a dumb number.
        i  (    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   getgid  s    c         C   s   d S(   s>   
        Override C{os.getuid}. Return a dumb number.
        i  (    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   getuid  s    c         C   s   |  j  j d | f  d S(   s4   
        Override C{os.setuid}. Do nothing.
        t   setuidN(   R<  R   (   R   t   val(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRk    s    c         C   s   |  j  j d | f  d S(   s4   
        Override C{os.setgid}. Do nothing.
        t   setgidN(   R<  R   (   R   Rl  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRm    s    c         C   s   |  j  j d | | f  d S(   s6   
        Override C{os.setregid}. Do nothing.
        t   setregidN(   R<  R   (   R   t   val1t   val2(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRn    s    c         C   s   |  j  j d | | f  d S(   s<   
        Override C{os.setreuid}.  Save the action.
        t   setreuidN(   R<  R   (   R   Ro  Rp  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRq    s    c         C   s   |  j  j d | | f  d S(   s>   
        Override C{util.switchuid}. Save the action.
        t	   switchuidN(   R<  R   (   R   t   uidt   gid(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   switchUID  s    c         C   s   d S(   sK   
        Override C{pty.openpty}, returning fake file descriptors.
        ii(   ii(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   openpty  s    c         C   s   |  j  S(   sE   
        Mock C{os.geteuid}, returning C{self.euid} instead.
        (   t   euid(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   geteuid  s    c         C   s   |  j  S(   sE   
        Mock C{os.getegid}, returning C{self.egid} instead.
        (   t   egid(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   getegid  s    c         C   s   |  j  j |  d S(   s3   
        Mock C{os.seteuid}, store result.
        N(   RC  R   (   R   Ry  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   seteuid  s    c         C   s   |  j  j |  d S(   s3   
        Mock C{os.setegid}, store result.
        N(   RD  R   (   R   Ry  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   setegid  s    c         C   s   |  j  S(   s-   
        Mock C{os.path.expanduser}.
        (   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt
   expanduser  s    c         C   s   d S(   s'   
        Mock C{pwd.getpwnam}.
        i    i   i   (   i    i    i   i   (    (   R   t   user(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   getpwnam  s    c         C   s   d S(   sN   
        Override C{os.listdir}, returning fake contents of '/dev/fd'
        s   -1s   -2(   s   -1s   -2(    (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   listdir  s    N(0   R   R   R   RY   R]  RY  R(   RK  R\   RS  Re  RR  Rf  Rw  Ry  R   R5   RG  RJ  RM  RN  RO  R   RV  R?   R'  RZ  R[  R`  Rb  Rc  Rd  Rh  Ri  Rj  Rk  Rm  Rn  Rq  Ru  Rv  Rx  Rz  R{  R|  R}  R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR;    sV   =											
	
																				t   DumbProcessWriterc           B   s   e  Z d  Z d   Z RS(   sA   
        A fake L{process.ProcessWriter} used for tests.
        c         C   s   d S(   sD   
            Here's the faking: don't do anything here.
            N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   startReading  s    (   R   R   R   R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  
  s   t   DumbProcessReaderc           B   s   e  Z d  Z d   Z RS(   sA   
        A fake L{process.ProcessReader} used for tests.
        c         C   s   d S(   sD   
            Here's the faking: don't do anything here.
            N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s    (   R   R   R   R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   t   DumbPTYProcessc           B   s   e  Z d  Z d   Z RS(   s>   
        A fake L{process.PTYProcess} used for tests.
        c         C   s   d S(   sD   
            Here's the faking: don't do anything here.
            N(    (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  '  s    (   R   R   R   R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  "  s   t   MockProcessTestCasec           B   s   e  Z d  Z e d k r! d Z n  d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   s?   
    Mock a process runner to test forked child code path.
    s1   twisted.internet.process is never used on Windowsc         C   s,  t  j   r |  j t  j  n |  j t  j  t   |  _ d |  j _ d |  j _ |  j	 t
 d |  j  |  j	 t
 d |  j  |  j	 t
 d |  j  |  j	 t
 d |  j j  |  j	 t
 d |  j  |  j	 t
 j d t  |  j	 t
 j d	 t  |  j	 t
 d
 |  j  t   |  _ |  j	 t
 d |  j  d S(   s|   
        Replace L{process} os, fcntl, sys, switchUID, fdesc and pty modules
        with the mock class L{MockOS}.
        i  i  Rg   t   fcntlRp   Ru  t   fdesct   processReaderFactoryt   processWriterFactoryt   ptyRX   N(   RP  RQ  R  t   enablet   disableR;  t   mockosRw  Ry  t   patchR    Ru  t   ProcessR  R  R6  t   mocksig(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   5  s     c         C   s   i  t  _ d S(   s6   
        Reset processes registered for reap.
        N(   R    R.  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   N  s    c         C   s   t  j   d } t j   } t |  } y& t j | | d g d d	 d t WnI t	 k
 r |  j
 |  j j  |  j |  j j d t f d d g  n X|  j d  |  j t  j    d	 S(
   sk   
        Test a classic spawnProcess. Check the path of the client code:
        fork, exec, exit.
        s
   /mock/oucht   ouchRo   R   RO  RW  R\  s   Should not be hereN(   RP  R  R   Rm   R0   R   Rr   R(   RY   R^  t   assert_R  R]  R   R<  R   t   assertFalseRQ  (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkU  s    
#c         C   s   t  |  j _ d } t j   } t |  } t j | | d g d d
 d t  |  j	 t
 |  j j  t
 d d d g   |  j |  j j d t  f d	 g  d
 S(   s   
        Assert that in the main process, spawnProcess disables the garbage
        collector, calls fork, closes the pipe file descriptors it created for
        the child process, and calls waitpid.
        s
   /mock/ouchR  Ro   R   iiiRO  Rd  N(   RY   R  RS  R   Rm   R0   R   Rr   R(   R"   R   R   R   R<  (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _mockForkInParentTestn  s    +c         C   s+   t  j   |  j   |  j t  j    d S(   s   
        The garbage collector should be enabled when L{reactor.spawnProcess}
        returns if it was initially enabled.

        @see L{_mockForkInParentTest}
        N(   RP  R  R  t
   assertTrueRQ  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt,   test_mockForkInParentGarbageCollectorEnabled  s    

c         C   s+   t  j   |  j   |  j t  j    d S(   s   
        The garbage collector should be disabled when L{reactor.spawnProcess}
        returns if it was initially disabled.

        @see L{_mockForkInParentTest}
        N(   RP  R  R  R  RQ  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt-   test_mockForkInParentGarbageCollectorDisabled  s    

c         C   s   d } t  j   } t |  } y& t j | | d g d d	 d t WnI t k
 r |  j |  j	 j
  |  j |  j	 j d t f d d g  n X|  j d  d	 S(
   sg   
        Test a TTY spawnProcess: check the path of the client code:
        fork, exec, exit.
        s
   /mock/ouchR  Ro   R   RO  RW  R\  s   Should not be hereN(   R   Rm   R0   R   Rr   R(   R\   R^  R  R  R]  R   R<  RY   R   (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkTTY  s    #c         C   s`   t  t j d  |  j _ t d  } |  j t  t j	 | d  |  j
 |  j j d t f g  d S(   s   
        Assert that if the fork call fails, no other process setup calls are
        made and that spawnProcess raises the exception fork raised.
        RO  N(   R   t   errnot   EAGAINR(   R  RR  R0   R   R   Rr   R"   R<  RY   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   _mockWithForkError  s    c         C   s+   t  j   |  j   |  j t  j    d S(   s   
        The garbage collector should be enabled when L{reactor.spawnProcess}
        raises because L{os.fork} raised, if it was initially enabled.
        N(   RP  R  R  R  RQ  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt-   test_mockWithForkErrorGarbageCollectorEnabled  s    

c         C   s+   t  j   |  j   |  j t  j    d S(   s   
        The garbage collector should be disabled when
        L{reactor.spawnProcess} raises because L{os.fork} raised, if it was
        initially disabled.
        N(   RP  R  R  R  RQ  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt.   test_mockWithForkErrorGarbageCollectorDisabled  s    

c      	   C   sB   |  j    |  j t |  j j  t d d d d d d g   d S(   s}   
        When C{os.fork} raises an exception, the file descriptors created
        before are closed and don't leak.
        iiiiiiN(   R  R"   R   R  R   (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkErrorCloseFDs  s    
c      	   C   s   t  t j d  |  j _ t d  } |  j t  t j	 | d d i d d 6d d 6d d 6|  j
 |  j j d t f g  |  j
 |  j j g   |  j t  t j	 | d d i d	 d 6d d 6d d 6|  j
 t |  j j  t d
 d g   d S(   s   
        When C{os.forks} raises an exception and that file descriptors have
        been specified with the C{childFDs} arguments of
        L{reactor.spawnProcess}, they are not closed.
        R  ii    ii   ii   RO  R  iiN(   R   R  R  R(   R  RR  R0   R   R   Rr   R"   R<  RY   R   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkErrorGivenFDs  s    c         C   s   t  t j d  |  j _ t d  } |  j t  t j	 | d d t
 |  j |  j j d t f g  |  j t |  j j  t d d g   d S(   s   
        When C{os.fork} raises an exception, the file descriptors created by
        C{pty.openpty} are closed and don't leak, when C{usePTY} is set to
        C{True}.
        R   RO  iiN(   R   R  R  R(   R  RR  R0   R   R   Rr   R\   R"   R<  RY   R   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkErrorClosePTY  s    c      	   C   s|   t  t j d  |  j _ t d  } |  j t  t j	 | d d d |  j
 |  j j d t f g  |  j
 |  j j g   d S(   s   
        If a tuple is passed to C{usePTY} to specify slave and master file
        descriptors and that C{os.fork} raises an exception, these file
        descriptors aren't closed.
        R   iiR   RO  N(   iis   foo(   R   R  R  R(   R  RR  R0   R   R   Rr   R"   R<  RY   R   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockForkErrorPTYGivenFDs  s    c         C   s  d } t  j   } t |  } t |  j _ y& t j | | d g d d d t	 Wn t
 k
 r |  j |  j j  |  j |  j j d t	 f d d g  |  j d |  j j  |  j d	 |  j j  |  j d
 |  j j  |  j d |  j j j    n X|  j d  d S(   s   
        Spawn a process but simulate an error during execution in the client
        path: C{os.execvpe} raises an error. It should close all the standard
        fds, try to print the error encountered, and exit cleanly.
        s
   /mock/ouchR  Ro   R   RO  RW  R\  i    i   i   s   RuntimeError: Bars   Should not be hereN(   R   Rm   R0   R\   R  RY  R   Rr   R(   RY   R^  R  R]  R   R<  R&  R   RK  R   R   (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockWithExecError  s      c      
   C   s   d } t  j   } t |  } y, t j | | d g d d d t d d WnR t k
 r |  j |  j	 j
  |  j |  j	 j d d d
 t f d d d g  n X|  j d  d S(   s   
        Try creating a process with setting its uid: it's almost the same path
        as the standard path, but with a C{switchUID} call before the exec.
        s
   /mock/ouchR  Ro   R   Rs  i  Rk  i    Rm  RO  Rr  i  RW  R\  s   Should not be hereN(   s   setuidi    (   s   setgidi    (   s	   switchuidi  i  (   R   Rm   R0   R   Rr   R(   RY   R^  R  R  R]  R   R<  R   (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockSetUid   s    c      
   C   s   t  |  j _ d } t j   } t |  } t j | | d g d d d t  d d |  j	 |  j j
 d d d
 t  f d d d g  d S(   s   
        Try creating a process with setting its uid, in the parent path: it
        should switch to root before fork, then restore initial uid/gids.
        s
   /mock/ouchR  Ro   R   Rs  i  Rk  i    Rm  RO  Rn  i  i  Rq  i  i  Rd  N(   s   setuidi    (   s   setgidi    (   s   setregidi  i  (   s   setreuidi  i  (   RY   R  RS  R   Rm   R0   R   Rr   R(   R   R<  (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockSetUidInParent5  s    c      
   C   s   d } t  j   } t |  } y, t j | | d g d d d t d d WnR t k
 r |  j |  j	 j
  |  j |  j	 j d d d
 t f d d d g  n X|  j d  d S(   s   
        Try creating a PTY process with setting its uid: it's almost the same
        path as the standard path, but with a C{switchUID} call before the
        exec.
        s
   /mock/ouchR  Ro   R   Rs  i  Rk  i    Rm  RO  Rr  i  RW  R\  s   Should not be hereN(   s   setuidi    (   s   setgidi    (   s	   switchuidi  i  (   R   Rm   R0   R   Rr   R(   R\   R^  R  R  R]  R   R<  RY   R   (   R   R  R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockPTYSetUidF  s    c      
   C   s   t  |  j _ d } t j   } t |  } t j } z5 t t _ t	 j
 | | d g d d d t d d Wd | t _ X|  j |  j j d d d t  f d d d g  d S(   s   
        Try creating a PTY process with setting its uid, in the parent path: it
        should switch to root before fork, then restore initial uid/gids.
        s
   /mock/ouchR  Ro   R   Rs  i  NRk  i    Rm  RO  Rn  i  i  Rq  i  i  Rd  (   s   setuidi    (   s   setgidi    (   s   setregidi  i  (   s   setreuidi  i  (   RY   R  RS  R   Rm   R0   R    t
   PTYProcessR  R   Rr   R(   R\   R   R<  (   R   R  R4   R#   t   oldPTYProcess(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockPTYSetUidInParent\  s    		
c         C   s   t  |  j _ d } d
 |  j _ t j   } t |  } t j | | d g d d	 d t  } |  j
 |  j j d t  f d g  t   |  j _ | j   |  j   } |  j
 t |  d  | d j t  d	 S(   s;   
        Test that reapProcess logs errors raised.
        s
   /mock/ouchi    R  Ro   R   RO  Rd  i   N(   i    i    (   RY   R  RS  Rf  R   Rm   R0   R   Rr   R(   R   R<  R   Re  t   reapProcessR0  RP   R   (   R   R  R4   R#   t   proct   errors(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockWithWaitErrorr  s    	"
c         C   s   t  |  j _ d } d	 |  j _ t j   } t |  } t j | | d g d d d t  } |  j
 |  j j d t  f d g  t   |  j _ t j |  j j _ | j   d S(
   s{   
        Test that reapProcess doesn't log anything when waitpid raises a
        C{OSError} with errno C{ECHILD}.
        s
   /mock/ouchi    R  Ro   R   RO  Rd  N(   i    i    (   RY   R  RS  Rf  R   Rm   R0   R   Rr   R(   R   R<  R   Re  R  t   ECHILDR  (   R   R  R4   R#   R  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt!   test_mockErrorECHILDInReapProcess  s    	"c            s   d d d d g     f d   } | |  j  _ t d  } |  j t t j | d  |  j |  j  j	 g   |  j t
 |  j  j  t
 d d d d g   d S(   s   
        If C{os.pipe} raises an exception after some pipes where created, the
        created pipes are closed and don't leak.
        iiiic              sA   y    j  d    j  d  f SWn t k
 r< t    n Xd  S(   Ni    (   t   popt
   IndexErrorR   (    (   t   pipes(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyRZ    s     N(   R  RZ  R0   R(   R   R   R   Rr   R"   R<  R   R   (   R   RZ  R   (    (   R  s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockErrorInPipe  s    c      	   C   sr   t  t j d  |  j _ t d  } |  j t  t j	 | d d d |  j
 |  j j d d d t f d d g  d S(   s   
        If C{os.fork} raises an exception and a UID change has been made, the
        previous UID and GID are restored.
        Rs  i  Rk  i    Rm  RO  Rn  i  i  Rq  i  i  N(   s   setuidi    (   s   setgidi    (   s   setregidi  i  (   s   setreuidi  i  (   R   R  R  R(   R  RR  R0   R   R   Rr   R"   R<  RY   (   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_mockErrorInForkRestoreUID  s    N(   R   R   R   R    R(   t   skipR   R   R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  .  s4   										
														t   PosixProcessTestCasec           B   s   e  Z d    Z d   Z RS(   c      
      s   t  j } d  t    t j   }  _ t j  | | d d  f g d d	 d d d   j	     f d   } | j
 |  S(
   s   
        Bytes written to stderr by the spawned process are passed to the
        C{errReceived} callback on the C{ProcessProtocol} passed to
        C{spawnProcess}.
        t   42s   -cs"   import sys; sys.stderr.write('%s')Ro   R   s   /tmpR   c            s     j    j j    d  S(   N(   R   R   R   (   R   (   R   Rc   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    N(   Rp   Rq   R   R   Rm   R   R   Rr   R(   R   R   (   R   R  R4   R8   (    (   R   Rc   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_stderr  s    		
c      
      s     j  d  } d d  t    t j   }  _ t j  | | d g d d  d d d   j  j	 j
    j	 j       f d	   } | j |  S(
   Nt   gzips   there's no place like home!
i   s   -cRo   R   s   /tmpR   c            sE     j  } | j d d  t j d |  }  j | j     d  S(   Ni    t   fileobj(   R   t   seekR  t   GzipFileR   t   read(   R   R   t   gf(   R#   R   RL   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    	(   R  R   R   Rm   R   R   Rr   R(   R   R>   R?   RR   R   (   R   R  R4   R8   (    (   R   R#   RL   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testProcess  s    
	$
(   R   R   R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   	t   PosixProcessTestCasePTYc           B   s&   e  Z d  Z e Z d   Z d   Z RS(   sH   
    Just like PosixProcessTestCase, but use ptys instead of pipes.
    c      
      s   t  j } t j t d  } t    t j   }  _ t	 j
  | | d | g d d  d d  d   j  j j d     f d   } | j |  S(   Ns   process_tty.pys   -uRo   R   R   s   hello world!
c            sI     j  t j  j j d    j  j j   d d  j j    d  S(   NR  s   hello world!
hello world!
s-   Error message from process_tty follows:

%s

(   R   R   R   R>   R]   R   R   R   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    (   Rp   Rq   R	   R   R   R   R   Rm   R   R   Rr   R(   R   R>   R?   R   (   R   Rv   R   R4   R8   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testOpeningTTY  s    		!c         C   sW   t  j } | d d d g } t   } |  j t t j | | | d d d i d d 6d  S(   Ns   -us   -cs   print 'hello'R   i   R  R  (   Rp   Rq   R   R   Rb   R   Rr   (   R   R   t   pyArgsR#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testBadArgs	  s
    		(   R   R   R   R\   R   R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   	t   Win32SignalProtocolc           B   s   e  Z d  Z d   Z RS(   s   
    A win32-specific process protocol that handles C{processEnded}
    differently: processes should exit with exit code 1.
    c         C   s{   | j  t j  s/ |  j j t d | f   S| j } | j d k rg |  j j t d | j f   S|  j j d  d S(   s   
        Callback C{self.deferred} with C{None} if C{reason} is a
        L{error.ProcessTerminated} failure with C{exitCode} set to 1.
        Otherwise, errback with a C{ValueError} describing the problem.
        s   wrong termination: %si   s   Wrong exit code: %sN(
   RT   R   R`   R1   Ra   Rb   Rc   Rf   R7   R(   (   R   R6   Rj   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    			(   R   R   R   R8   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   t   Win32ProcessTestCasec           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   s?   
    Test process programs that are packaged with twisted.
    c            s   t  j } t j t d  } t    t j   }  _ t	 j
  | | d | g d d  d d   j j d   j j      f d   } | j |  S(   Ns   process_stdinreader.pys   -uRo   R   s   hello, worldc            s6     j   j j   d    j   j j   d  d  S(   Ns   err
err
s   out
hello, world
out
(   R   R   R   R   (   R   (   R   R#   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8   8  s    (   Rp   Rq   R	   R   R   R   R   Rm   R   R   Rr   R(   R>   R?   RR   R   (   R   R   R   R4   R8   (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testStdinReader.  s    		!c      
   C   s   t  j } | d d d g } t   } |  j t t j | | | d d |  j t t j | | | d d |  j t t j | | | d d |  j t t j | | | d i d	 d 6d  S(
   Ns   -us   -cs   print 'hello'Rs  i   Rt  R   R  R  (   Rp   Rq   R   R   Rb   R   Rr   (   R   R   R  R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  >  s    						c         C   s\   t  j } t j t d  } t j   } t | |  } t j	 | | | d | g d d  | S(   Ns   process_signal.pys   -uRo   (   Rp   Rq   R	   R   R   R   Rm   R  R   Rr   R(   (   R   R[   Rv   R   R4   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  L  s    	"c         C   s   |  j  d  S(   s   
        Sending the SIGTERM signal terminates a created process, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} attribute set to 1.
        R  (   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  U  s    c         C   s   |  j  d  S(   s   
        Sending the SIGINT signal terminates a created process, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} attribute set to 1.
        R   (   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  ^  s    c         C   s   |  j  d  S(   s   
        Sending the SIGKILL signal terminates a created process, and
        C{processEnded} is called with a L{error.ProcessTerminated} instance
        with the C{exitCode} attribute set to 1.
        R  (   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  g  s    c            s   d d l   t j    t j    d t j f   f d     Y} |   } t j } | d d d g } t j | | |       f d   }  j	 |      f d	   }  j	 |  t j
   g  S(
   sU   
        The win32 handles should be properly closed when the process exits.
        iNt   SimpleProtocolc              s,   e  Z d  Z  f d   Z   f d   Z RS(   sZ   
            A protocol that fires deferreds when connected and disconnected.
            c            s     j  |  d  S(   N(   R7   (   R   R>   (   R+  (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR,  }  s    c            s     j  d   d  S(   N(   R7   R(   (   R   R6   (   R-  (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8     s    (   R   R   R   R,  R8   (    (   R-  R+  (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  y  s   s   -us   -cs   print 'hello'c            sL     j  |     j  j   j  j   j   _  j   _ d  S(   N(   t   assertIdenticalt   GetHandleInformationt   hProcesst   hThread(   R>   (   R   R  t   win32api(    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR/    s
    c            su     j   j d     j   j d     j   j d     j  j  j   j    j  j  j   j  d  S(   N(   R  R   R(   R  R  R   R   R  (   R   (   R   R  R  (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR3    s    (   R  R   Rm   R   R   Rp   Rq   R   Rr   R   R   (   R   R  R#   R   R  R/  R3  (    (   R   R-  R+  R  R  s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_closeHandlesp  s    "
		
(
   R   R   R   R  R  R  R  R  R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  )  s   										t   Win32UnicodeEnvironmentTestc           B   s#   e  Z d  Z d Z d Z d   Z RS(   s2   
    Tests for Unicode environment on Windows
    u   UNICODEc            sf     j  t j   j <  j t j t j   j  t j t	 g  i   }   f d   } | j
   j |  S(   s   
        Test C{os.environ} (inherited by every subprocess on Windows) that
        contains an ascii-encodable Unicode string. This is different from
        passing Unicode environment explicitly to spawnProcess (which is not
        supported).
        c            s0     j  |    j j d    j j d   d  S(   Nt   ascii(   R   t   goodKeyR   t	   goodValue(   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s    (   R  Rg   R   R  R  t   operatort   delitemR   Rw   R   Rz   R   (   R   R#   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt    test_encodableUnicodeEnvironment  s
    (   R   R   R   R  R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   t   Dumbwin32procPidTestc           B   s   e  Z d  Z d   Z RS(   s@   
    Simple test for the pid attribute of Process on win32.
    c   
         s   d d l  m } d d l m }   j | d |  t j } t j t	 d  } t
 j   } t |  } t t j d  } | d | | g } | j t | d | i  d     j d  j    j d	 t       f d
   }	 | j |	  S(   s   
        Launch process with mock win32process. The only mock aspect of this
        module is that the pid of the process created will always be 42.
        i(   t   _dumbwin32proc(   t   mock_win32processt   win32processs   process_cmdline.pyt   COMSPECs   /ci*   s   <Process pid=42>c            s    j  d    j  d  S(   N(   R   R(   R   (   R{   (   R#   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   pidCompleteCb  s    N(   t   twisted.internetR  t   twisted.testR  R  Rp   Rq   R	   R   R   R   Rm   R0   RV   Rg   R   R  R   R(   R   R   RD   R   (
   R   R  R  Rv   R   R4   t   processProtot   comspecR  R  (    (   R   R#   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_pid  s&    			(   R   R   R   R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   t   UtilTestCasec           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s\   
    Tests for process-related helper functions (currently only
    L{procutils.which}.
    c         C   s  t  j j } |  j   } | | d  |  _ | | d  |  _ | |  j d  |  _ | |  j d  |  _ | |  j d  |  _ | |  j d  |  _	 x3 |  j |  j |  j |  j	 f D] } t  j
 |  q Wx | |  j d  d f | |  j d  d f | |  j d  d f | |  j d  d f | |  j	 d  d f g D]5 \ } } t | d  } | j   t  j | |  q6Wt  j j d	 d
  |  _ t  j j |  j |  j |  j |  j	 f  t  j d	 <d
 S(   s   
        Create several directories and files, some of which are executable
        and some of which are not.  Save the current PATH setting.
        R   t   bazR   Rq   i  s   executable.bini    R  t   PATHN(   Rg   R   R   t   mktempR   R  t   foobart   foobazt   bazfoot   bazbart   makedirst   fileR   t   chmodR   t   getR(   t   oldPathR   (   R   t   jt   baseR4   t   namet   modeR   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR     s*    %%
	c         C   sm   t  j t  j j |  j d  t j  |  j d k rY y t  j	 d =Wqi t
 k
 rU qi Xn |  j t  j	 d <d S(   s   
        Restore the saved PATH setting, and set all created files readable
        again so that they can be deleted easily.
        Rq   R  N(   Rg   R  R   R   R  t   statt   S_IWUSRR  R(   R   t   KeyError(   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   	  s    %c         C   s'   t  j d =|  j t j d  g   d S(   s}   
        Test that if C{os.environ} does not have a C{'PATH'} key,
        L{procutils.which} returns an empty list.
        R  Rq   N(   Rg   R   R"   R   R  (   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_whichWithoutPATH	  s    
c         C   s~   t  j j } t j d  } | |  j d  | |  j d  g } t j j	   rj | j
 | |  j d   n  |  j | |  d  S(   NRq   (   Rg   R   R   R   R  R  R  R
   t   platformt	   isWindowsR   R  R   (   R   R  t   pathst   expectedPaths(    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt	   testWhich	  s    c         C   s   t  j j } t  j j d d   } t  j j d  t  j d <z t j d  } Wd  | d  k ri t  j d =n | t  j d <X| |  j	 d  | |  j
 d  | |  j
 d  g } t j j   r | j | |  j d   n  |  j | |  d  S(   Nt   PATHEXTs   .bins   .exes   .shRq   s   executable.bin(   s   .bins   .exes   .sh(   Rg   R   R   R   R  R(   R   R   R  R  R  R
   R  R  R   R  R   (   R   R  t   oldR  R  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   testWhichPathExt)	  s    (   R   R   R   R   R   R  R  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR    s   	!				
t   ClosingPipesProcessProtocolc           B   s8   e  Z d  Z d  Z d   Z d   Z d   Z d   Z RS(   R:   c         C   s   t  j   |  _ | |  _ d  S(   N(   R   Rm   R1   t   outOrErr(   R   R  (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR5   A	  s    c         C   s   |  j  j |  d  S(   N(   R1   R7   (   R   R6   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR8   E	  s    c         C   s   |  j  | 7_  d  S(   N(   t   output(   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   H	  s    c         C   s   |  j  | 7_  d  S(   N(   t   errput(   R   R   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   K	  s    (   R   R   R  R   R5   R8   R   R   (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  =	  s   			t   ClosingPipesc           B   s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C   s   t  t  } |  j | j t j  | j j |  j |  t j	 | t
 j t
 j d d d | f g d d | d k r | j j   n" | d k r | j j   n t  | j j d  | j j   | j S(	   s  
        Create a child process and close one of its output descriptors using
        L{IProcessTransport.closeStdout} or L{IProcessTransport.closeStderr}.
        Return a L{Deferred} which fires after verifying that the descriptor was
        really closed.
        s   -us   -css   raw_input()
import sys, os, time
for i in range(1000):
    os.write(%d, "foo\n")
    time.sleep(0.01)
sys.exit(42)
Ro   i   i   s   go
N(   R  R\   t   assertFailureR1   R   R`   R   t   _endProcessR   Rr   Rp   Rq   R(   R>   t   closeStdoutt   closeStderrRC   R?   RR   (   R   RI  R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   doitR	  s"    		c         C   s4   |  j  | j d d |  |  j | j d  | j S(   so   
        Check that a failed write prevented the process from getting to its
        custom exit code.
        i*   s   process reason was %rR:   (   t   assertNotEqualsRf   R   R  R   (   R   R6   R#   (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  {	  s    c            s/     j  d  }   f d   } | j |  | S(   sQ   
        ProcessProtocol.transport.closeStdout actually closes the pipe.
        i   c            s<     j  d |   t j j   d k r8   j  d |   n  d  S(   NR   t   win32s   Broken pipe(   R&  R
   R  t   getType(   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   	  s    (   R  R   (   R   R4   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   test_stdout	  s    c            s/     j  d  }   f d   } | j |  | S(   sQ   
        ProcessProtocol.transport.closeStderr actually closes the pipe.
        i   c            s     j  |  d  d  S(   NR:   (   R   (   R   (   R   (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR   	  s    (   R  R   (   R   R4   R   (    (   R   s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  	  s    (   R   R   R  R  R
  R  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyR  P	  s   	)		s9   wrong platform or reactor doesn't support IReactorProcesst   posixR  (M   R   R  Rg   Rp   RX   R
  R  RP  R  R  R  t   ImportErrorR(   R    R  t   zope.interface.verifyR   t   twisted.python.logR   R   R   R   R   R   t   twisted.trialR   t   twisted.pythonR	   R
   R   t   twisted.python.compatR   R   R   t   TestCaseR   R0   R9   RE   RW   Rl   Rn   R~   R   R   R   R   R   R   R   R  R   R  t   objectR6  R;  t   ProcessWriterR  t   ProcessReaderR  R  R  R  R  R  R  R  R  R  R  R  R  t   skipMessageR  R	  t   IReactorProcessR  (    (    (    s=   /usr/lib/python2.7/dist-packages/twisted/test/test_process.pyt   <module>   s   (Y.%IL$ $)Q! I -(z$\Q(			(				