
[XMc           @   s6  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 y d d l Z 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 d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m  Z  d d l! m" Z" d d l# m$ Z$ y d d l m% Z% Wn e
 k
 re Z% n Xy d d l m& Z& Wn e
 k
 re Z& n! Xd d l' m( Z( d d l' m) Z) y d d l* Z* Wn e
 k
 re Z* n Xy d d l+ Z+ d d l, Z+ Wn e
 e- f k
 r;e Z+ n Xy d d l. Z. d d l/ Z/ Wn e
 k
 rqe Z/ n Xe0 e d e  e k rd Z1 n e Z1 d   Z2 d e3 f d     YZ4 d e j5 f d     YZ6 d e j7 f d     YZ8 d e j9 f d     YZ: d e j9 f d     YZ; d  e3 f d!     YZ< d" e j= f d#     YZ> d$ e j9 f d%     YZ? d& e j9 f d'     YZ@ d( e j9 f d)     YZA d* e j9 f d+     YZB d, e3 f d-     YZC d. e j9 f d/     YZD d0   ZE d1 e j9 f d2     YZF d3 e j9 f d4     YZG d5 e j9 f d6     YZH d S(7   sE   
Tests for L{twisted.application.app} and L{twisted.scripts.twistd}.
iN(   t
   implements(   t   verifyObject(   t   unittest(   t   servicet   app(   t   twistd(   t   log(   t
   UsageError(   t   ILogObserver(   t   Version(   t   Componentized(   t   Deferred(   t   UserDatabase(   t   syslog(   t   _twistd_unix(   t   UnixApplicationRunner(   t   UnixAppLoggert   setuids5   Platform does not support --uid/--gid twistd options.c            s   t  j t j    } t j t j      t   } | j | | j	 | | j
 | j | j | j      f d   } |  t  d | j  |  t d |  d S(   su  
    Patch L{pwd.getpwnam} so that it behaves as though only one user exists
    and patch L{grp.getgrnam} so that it behaves as though only one group
    exists.

    @param patch: A function like L{TestCase.patch} which will be used to
        install the fake implementations.

    @type user: C{str}
    @param user: The name of the single user which will exist.

    @type uid: C{int}
    @param uid: The UID of the single user which will exist.

    @type group: C{str}
    @param group: The name of the single user which will exist.

    @type gid: C{int}
    @param gid: The GID of the single group which will exist.
    c            sS   t    }   | | j  j  < | | j  j  <t |  } i |   6|  S(   N(   t   listt   indext   gr_namet   gr_gidt   tuple(   t   namet   result(   t   groupt   grentt   gid(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   getgrnamg   s
    t   getpwnamR   N(   t   pwdt   getpwuidt   ost   getuidt   grpt   getgrgidt   getgidR   t   addUsert	   pw_passwdt   pw_gidt   pw_gecost   pw_dirt   pw_shellR   (   t   patcht   usert   uidR   R   t   pwentt   databaseR   (    (   R   R   R   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   patchUserDatabaseF   s    	t   MockServiceMakerc           B   s   e  Z d  Z d Z d   Z RS(   sO   
    A non-implementation of L{twisted.application.service.IServiceMaker}.
    t   ueoac         C   s   | |  _  t j   |  _ |  j S(   se   
        Take a L{usage.Options} instance and return a
        L{service.IService} provider.
        (   t   optionsR   t   Service(   t   selfR3   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   makeServicey   s    	(   t   __name__t
   __module__t   __doc__t   tapnameR6   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR1   s   s   t   CrippledAppLoggerc           B   s   e  Z d  Z d   Z RS(   s*   
    @see: CrippledApplicationRunner.
    c         C   s   d  S(   N(    (   R5   t   application(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   start   s    (   R7   R8   R9   R=   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR;      s   t   CrippledApplicationRunnerc           B   s&   e  Z d  Z e Z d   Z d   Z RS(   s   
    An application runner that cripples the platform-specific runner and
    nasty side-effect-having code so that we can use it without actually
    running any environment-affecting code.
    c         C   s   d  S(   N(    (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   preApplication   s    c         C   s   d  S(   N(    (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   postApplication   s    (   R7   R8   R9   R;   t   loggerFactoryR?   R@   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR>      s   	t   ServerOptionsTestc           B   sp   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z e	 d k rn d Z e e _ e _ e _ n  RS(	   sT   
    Non-platform-specific tests for the pltaform-specific ServerOptions class.
    c         C   s7   t  j   } d | _ | j   |  j | d t  d S(   sS   
        postOptions should set no_save to True when a subcommand is used.
        R2   t   no_saveN(   R   t   ServerOptionst
   subCommandt   postOptionst   assertEqualst   True(   R5   t   config(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt&   test_postOptionsSubCommandCausesNoSave   s    	
c         C   s.   t  j   } | j   |  j | d t  d S(   sR   
        If no sub command is used, postOptions should not touch no_save.
        RC   N(   R   RD   RF   RG   t   False(   R5   RI   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt(   test_postOptionsNoSubCommandSavesAsUsual   s    
c         C   sC   t  j   } t |  } x$ t j j D] } |  j | |  q% Wd S(   sq   
        All the profilers that can be used in L{app.AppProfiler} are listed in
        the help output.
        N(   R   RD   t   strR   t   AppProfilert	   profilerst   assertIn(   R5   RI   t
   helpOutputt   profiler(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_listAllProfilers   s    c         C   s$   t  j   } |  j | d d  d S(   sG   
        The default value for the C{umask} option is C{None}.
        t   umaskN(   R   RD   t   assertEqualt   None(   R5   RI   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_defaultUmask   s    c         C   s^   t  j   } | j d d g  |  j | d d  | j d d g  |  j | d d  d S(   sh   
        The value given for the C{umask} option is parsed as an octal integer
        literal.
        s   --umaskt   123RT   iS   t   0123N(   R   RD   t   parseOptionsRU   (   R5   RI   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt
   test_umask   s
    c         C   s,   t  j   } |  j t | j d d g  d S(   s   
        If a value is given for the C{umask} option which cannot be parsed as
        an integer, L{UsageError} is raised by L{ServerOptions.parseOptions}.
        s   --umaskt   abcdefN(   R   RD   t   assertRaisesR   RZ   (   R5   RI   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_invalidUmask   s    s   twistd unix not availableN(   R7   R8   R9   RJ   RL   RS   RW   R[   R^   R   RV   t   msgt   skip(    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRB      s   	
						t   TapFileTestc           B   s    e  Z d  Z d   Z d   Z RS(   sM   
    Test twistd-related functionality that requires a tap file on disk.
    c         C   sH   |  j    |  _ t |  j d  } t j t j d  |  | j   d S(   sP   
        Create a trivial Application and put it in a tap file on disk.
        t   wbs   Hi!N(   t   mktempt   tapfilet   filet   cPicklet   dumpR   t   Applicationt   close(   R5   t   f(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   setUp   s    c         C   sT   t  j   } | j d |  j g  t |  j   } |  j t j |  j	 d  d S(   s   
        Ensure that the createOrGetApplication call that 'twistd -f foo.tap'
        makes will load the Application out of foo.tap.
        s   -fs   Hi!N(
   R   RD   RZ   Rd   R>   t   createOrGetApplicationRG   R   t   IServiceR   (   R5   RI   R<   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt&   test_createOrGetApplicationWithTapFile   s    (   R7   R8   R9   Rk   Rn   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRa      s   	
t   TestLoggerFactoryc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s8   
    A logger factory for L{TestApplicationRunner}.
    c         C   s   | |  _  d  S(   N(   t   runner(   R5   Rp   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   __init__  s    c         C   s/   |  j  j j d  t |  j  d  |  j  _ d S(   sC   
        Save the logging start on the C{runner} instance.
        R   R<   N(   Rp   t   ordert   appendt   hasattrt   hadApplicationLogObserver(   R5   R<   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR=     s    	c         C   s   d S(   s%   
        Don't log anything.
        N(    (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   stop  s    (   R7   R8   R9   Rq   R=   Rv   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRo      s   			t   TestApplicationRunnerc           B   s)   e  Z d  Z d   Z d   Z d   Z RS(   s`   
    An ApplicationRunner which tracks the environment in which its methods are
    called.
    c         C   s/   t  j j |  |  g  |  _ t |   |  _ d  S(   N(   R   t   ApplicationRunnerRq   Rr   Ro   t   logger(   R5   R3   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRq     s    	c         C   s&   |  j  j d  t |  d  |  _ d  S(   Nt   preR<   (   Rr   Rs   Rt   t   hadApplicationPreApplication(   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR?   $  s    c         C   s&   |  j  j d  t |  d  |  _ d  S(   Nt   postR<   (   Rr   Rs   Rt   t   hadApplicationPostApplication(   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR@   )  s    (   R7   R8   R9   Rq   R?   R@   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRw     s   		t   ApplicationRunnerTestc           B   s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z e e _	 d   Z
 e e
 _	 d   Z RS(   sR   
    Non-platform-specific tests for the platform-specific ApplicationRunner.
    c         C   sM   t  j   } t   |  _ i |  j d 6| _ t   | _ d | _ | |  _ d  S(   Nt   test_command(	   R   RD   R1   t   serviceMakert   loadedPluginst   objectt
   subOptionsRE   RI   (   R5   RI   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRk   3  s    	c         C   sh   t  |  j  } | j   |  j |  j j |  j j d  |  j |  j j t j | j	  j
 d d  d S(   s   
        Ensure that a twistd plugin gets used in appropriate ways: it
        is passed its Options instance, and the service it returns is
        added to the application.
        sK   ServiceMaker.makeService needs to be passed the correct sub Command object.i    sP   ServiceMaker.makeService's result needs to be set as a child of the Application.N(   R>   RI   t   runt   assertIdenticalR   R3   R   R   Rm   R<   t   services(   R5   t   arunner(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt,   test_applicationRunnerGetsCorrectApplication=  s    
	c         C   si   t  |  j  } | j   |  j | j  |  j | j  |  j | j  |  j | j	 d d d g  d S(   s   
        Test thet preApplication and postApplication methods are
        called by ApplicationRunner.run() when appropriate.
        Rz   R   R|   N(
   Rw   RI   R   t   assertFalseR{   t
   assertTrueR}   Ru   RG   Rr   (   R5   t   s(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_preAndPostApplicationQ  s    
c            s   |  j  j |  g    d t j f   f d     Y} d t f   f d     Y} |   } t t j |  t t j |  | |  j   } | j	   | | _
 | j   |  j   d d d t | | f d d	 g  d
 S(   s.  
        Assert that given a particular command line, an application is started
        as a particular UID/GID.

        @param argv: A list of strings giving the options to parse.
        @param uid: An integer giving the expected UID.
        @param gid: An integer giving the expected GID.
        t   FakeUnixApplicationRunnerc              s>   e  Z   f d    Z   f d   Z   f d   Z d   Z RS(   c            s     j  d  d  S(   Nt   environment(   Rs   (   R5   t   chroott   rundirt   nodaemonRT   t   pidfile(   t   events(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   setupEnvironmentk  s    c            s     j  d | | | f  d  S(   Nt
   privileges(   Rs   (   R5   t   euidR-   R   (   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   shedPrivilegeso  s    c            s     j  d  d  S(   Nt   reactor(   Rs   (   R5   R   t	   oldstdoutt	   oldstderr(   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   startReactorr  s    c         S   s   d  S(   N(    (   R5   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt	   removePIDu  s    (   R7   R8   R   R   R   R   (    (   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   j  s   t   FakeServicec              so   e  Z e e j e j  d Z d Z d Z	 d    Z
 d   Z d   Z   f d   Z   f d   Z d   Z RS(   c         S   s   d  S(   N(    (   R5   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   setName  s    c         S   s   d  S(   N(    (   R5   t   parent(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   setServiceParent  s    c         S   s   d  S(   N(    (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   disownServiceParent  s    c            s     j  d  d  S(   Nt   privilegedStartService(   Rs   (   R5   (   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    c            s     j  d  d  S(   Nt   startService(   Rs   (   R5   (   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    c         S   s   d  S(   N(    (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   stopService  s    N(   R7   R8   R    R   Rm   t   IProcessRV   t   processNameR-   R   R   R   R   R   R   R   (    (   R   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   y  s   			R   R   R   R   R   N(   RI   RZ   R   t   _SomeApplicationRunnerR   R   R   Rm   R   R?   R<   R@   RU   RK   (   R5   t   argvR-   R   R   R   R<   Rp   (    (   R   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt"   _applicationStartsWithConfiguredID^  s    		
	
c         C   s;   d } d } |  j  d t |  d t |  g | |  d S(   s  
        L{postApplication} should change the UID and GID to the values
        specified as numeric strings by the configuration after running
        L{service.IService.privilegedStartService} and before running
        L{service.IService.startService}.
        i  i  s   --uids   --gidN(   R   RM   (   R5   R-   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt.   test_applicationStartsWithConfiguredNumericIDs  s    c         C   sT   d } d } d } d } t  |  j | | | |  |  j d | d | g | |  d S(   s  
        L{postApplication} should change the UID and GID to the values
        specified as user and group names by the configuration after running
        L{service.IService.privilegedStartService} and before running
        L{service.IService.startService}.
        t   fooi  t   bari  s   --uids   --gidN(   R0   R+   R   (   R5   R,   R-   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt+   test_applicationStartsWithConfiguredNameIDs  s    c         C   sW   t    } t j i t d 6d d 6t d 6 } | j | d d  |  j | j d  d S(   s7   
        L{startReactor} calls L{reactor.run}.
        t   profileRR   t   debugs'   startReactor did not call reactor.run()N(   t   DummyReactorR   Rx   RK   R   RV   R   t   called(   R5   R   Rp   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_startReactorRunsTheReactor  s    		(   R7   R8   R9   Rk   R   R   R   R   t
   setuidSkipR`   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR~   /  s   	
			C				t*   UnixApplicationRunnerSetupEnvironmentTestsc           B   s   e  Z d  Z e d k r! d Z n  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 RS(   s  
    Tests for L{UnixApplicationRunner.setupEnvironment}.

    @ivar root: The root of the filesystem, or C{unset} if none has been
        specified with a call to L{os.chroot} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests.chroot ).

    @ivar cwd: The current working directory of the process, or C{unset} if
        none has been specified with a call to L{os.chdir} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.chdir).

    @ivar mask: The current file creation mask of the process, or C{unset} if
        none has been specified with a call to L{os.umask} (patched for this
        TestCase with L{UnixApplicationRunnerSetupEnvironmentTests.umask).

    @ivar daemon: A boolean indicating whether daemonization has been performed
        by a call to L{_twistd_unix.daemonize} (patched for this TestCase with
        L{UnixApplicationRunnerSetupEnvironmentTests.
    s   twistd unix not availablec            s     j    _   j    _   j    _ t   _ t j     _   j	 t d   f d      j	 t d   f d      j	 t d   f d      j	 t
 d   j  t i     _ d  S(   NR   c            s   t    d |   S(   Nt   root(   t   setattr(   t   path(   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   <lambda>  s    t   chdirc            s   t    d |   S(   Nt   cwd(   R   (   R   (   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    RT   c            s   t    d |   S(   Nt   mask(   R   (   R   (   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    t	   daemonize(   t   unsetR   R   R   RK   t   daemonR    t   getpidt   pidR+   R   R   R   Rp   (   R5   (    (   R5   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRk     s    	c            s)   t    _   j t d   f d    d S(   s   
        Indicate that daemonization has happened and change the PID so that the
        value written to the pidfile can be tested in the daemonization case.
        R   c              s     j  d S(   Ni   (   R   (    (   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    N(   RH   R   R+   R    (   R5   (    (   R5   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    	c         C   s3   |  j  j d d t d d  |  j |  j d  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} changes the root of the
        filesystem if passed a non-C{None} value for the C{chroot} parameter.
        s   /foo/bart   .N(   Rp   R   RH   RV   RU   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_chroot  s    c         C   s6   |  j  j d d t d d  |  j |  j |  j  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} does not change the root of
        the filesystem if passed C{None} for the C{chroot} parameter.
        R   N(   Rp   R   RV   RH   R   R   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_noChroot  s    c         C   s3   |  j  j d d t d d  |  j |  j d  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} changes the working directory
        of the process to the path given for the C{rundir} parameter.
        s   /foo/barN(   Rp   R   RV   RH   RU   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_changeWorkingDirectory  s    c         C   s0   |  j  j d d t d d  |  j |  j  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} daemonizes the process if
        C{False} is passed for the C{nodaemon} parameter.
        R   N(   Rp   R   RV   RK   R   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_daemonize  s    c         C   s0   |  j  j d d t d d  |  j |  j  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} does not daemonize the
        process if C{True} is passed for the C{nodaemon} parameter.
        R   N(   Rp   R   RV   RH   R   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_noDaemonize"  s    c         C   sg   |  j    } |  j j d d t d |  t |  } t | j    } | j   |  j	 | |  j
  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} writes the process's PID to
        the file specified by the C{pidfile} parameter.
        R   N(   Rc   Rp   R   RV   RH   Re   t   intt   readRi   RU   R   (   R5   R   t   fObjR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_nonDaemonPIDFile+  s    
c         C   sk   |  j    } |  j j d d t d |  t |  } t | j    } | j   |  j	 | |  j
 d  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} writes the daemonized
        process's PID to the file specified by the C{pidfile} parameter if
        C{nodaemon} is C{False}.
        R   i   N(   Rc   Rp   R   RV   RK   Re   R   R   Ri   RU   R   (   R5   R   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_daemonPIDFile8  s    
c         C   s3   |  j  j d d t d d  |  j |  j d  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} changes the process umask to
        the value specified by the C{umask} parameter.
        R   i{   N(   Rp   R   RV   RK   RU   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR[   F  s    c         C   s6   |  j  j d d t d d  |  j |  j |  j  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} doesn't change the process
        umask if C{None} is passed for the C{umask} parameter and C{True} is
        passed for the C{nodaemon} parameter.
        R   N(   Rp   R   RV   RH   R   R   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_noDaemonizeNoUmaskO  s    c         C   s3   |  j  j d d t d d  |  j |  j d  d S(   s   
        L{UnixApplicationRunner.setupEnvironment} changes the process umask to
        C{0077} if C{None} is passed for the C{umask} parameter and C{False} is
        passed for the C{nodaemon} parameter.
        R   i?   N(   Rp   R   RV   RK   RU   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_daemonizedNoUmaskY  s    N(   R7   R8   R9   R   RV   R`   R   R   Rk   R   R   R   R   R   R   R   R   R[   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    																				
t*   UnixApplicationRunnerStartApplicationTestsc           B   s,   e  Z d  Z e d k r! d Z n  d   Z RS(   s>   
    Tests for L{UnixApplicationRunner.startApplication}.
    s   twistd unix not availablec      
      s  t  j   } | j d d d d d d d d d	 g	  t j d
  } t |  |  _ g      f d   } |  j t j	 |  j j
  t j	 |   |  j t d |  |  j t d d    |  j t d d    |  j j |  |  j   d d t d d	 g  d S(   s   
        L{UnixApplicationRunner.startApplication} calls
        L{UnixApplicationRunner.setupEnvironment} with the chroot, rundir,
        nodaemon, umask, and pidfile parameters from the configuration it is
        constructed with.
        s
   --nodaemons   --umaskt   0070s   --chroots   /foo/chroots   --rundirs   /foo/rundirs	   --pidfiles   /foo/pidfilet   test_setupEnvironmentc            s      j  | | | | | f  d  S(   N(   t   extend(   R5   R   R   R   RT   R   (   t   args(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   fakeSetupEnvironment}  s    R   R   c          _   s   d  S(   N(   RV   (   t   at   kw(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    t   startApplicationc          _   s   d  S(   N(   RV   (   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    i8   N(   R   RD   RZ   R   Rh   R   Rp   RU   t   inspectt
   getargspecR   R+   R   R   RH   (   R5   R3   R<   R   (    (   R   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   k  s*    N(   R7   R8   R9   R   RV   R`   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   d  s   	t   UnixApplicationRunnerRemovePIDc           B   s5   e  Z d  Z e d k r! d Z n  d   Z d   Z RS(   s7   
    Tests for L{UnixApplicationRunner.removePID}.
    s   twistd unix not availablec         C   sw   t  i   } |  j   } t j |  t j j | d  } t | d  j   | j |  |  j	 t j j
 |   d S(   sp   
        L{UnixApplicationRunner.removePID} deletes the file the name of
        which is passed to it.
        s   foo.pidt   wN(   R   Rc   R    t   makedirsR   t   joinRe   Ri   R   R   t   exists(   R5   Rp   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_removePID  s    c         C   s_   t  i   } | j d  |  j t  } |  j t |  d  |  j | d j j t j  d S(   sr   
        Calling L{UnixApplicationRunner.removePID} with a non-existent filename logs
        an OSError.
        t   fakepidi   i    N(	   R   R   t   flushLoggedErrorst   OSErrorRG   t   lent   valuet   errnot   ENOENT(   R5   Rp   t   errors(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_removePIDErrors  s
    N(   R7   R8   R9   R   RV   R`   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s
   		R   c           B   s   e  Z d  Z e Z d   Z RS(   s   
    A dummy reactor, only providing a C{run} method and checking that it
    has been called.

    @ivar called: if C{run} has been called or not.
    @type called: C{bool}
    c         C   s%   |  j  r t d   n  t |  _  d S(   sV   
        A fake run method, checking that it's been called one and only time.
        s   Already calledN(   R   t   RuntimeErrorRH   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s    	(   R7   R8   R9   RK   R   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR     s   t   AppProfilingTestCasec           B   sU  e  Z d  Z d   Z e d k r- d e _ n  d   Z d   Z e d k rW d e _ n  d   Z	 d   Z
 e d k r d e
 _ n  d   Z e d k r d e _ n  d	   Z e d k r d e _ n  d
   Z d   Z e d k r d e _ n  d   Z e d k rd e _ n  d   Z e d k r/d e _ n  d   Z d   Z d   Z d   Z RS(   s'   
    Tests for L{app.AppProfiler}.
    c         C   s   t  j   } |  j   | d <d | d <t j |  } t   } | j |  |  j | j  t	 | d  j
   } |  j d |  |  j d |  d S(   s   
        L{app.ProfileRunner.run} should call the C{run} method of the reactor
        and save profile data in the specified file.
        R   RR   s   DummyReactor.runs   function callsN(   R   RD   Rc   R   RN   R   R   R   R   Re   R   RP   (   R5   RI   RR   R   t   data(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_profile  s    
	s   profile module not availablec         C   sq   t  j    } |  j t d |  } | |  } | j   | j   | j   } |  j d |  |  j d |  d  S(   Nt   stdouts   function callss   (run)(   t   StringIOR+   t   syst   print_statst   restoret   getvalueRP   (   R5   t
   statsClassR   t   outR   t   statsR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt
   _testStats  s    

c         C   s   t  j   } |  j   | d <d | d <t | d <t j |  } t   } | j |  |  j | j	  |  j
 t j | d  d S(   s   
        With the C{savestats} option specified, L{app.ProfileRunner.run}
        should save the raw stats object instead of a summary output.
        R   RR   t	   savestatsN(   R   RD   Rc   RH   R   RN   R   R   R   R   R   t   pstatst   Stats(   R5   RI   RR   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_profileSaveStats  s    

	c         C   s   t  j j   } t j   } d | d <t j |  } d t  j d <z |  j t	 | j
 d  Wd t  j j   t  j j |  Xd S(   s   
        When the C{profile} module is not present, L{app.ProfilerRunner.run}
        should raise a C{SystemExit} exception.
        R   RR   N(   R   t   modulest   copyR   RD   R   RN   RV   R]   t
   SystemExitR   t   cleart   update(   R5   t   savedModulesRI   RR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_withoutProfile	  s    
c         C   s   d t  j f d     Y} |  j t  d |  t j   } |  j   | d <d | d <t j |  } t   } t	 j
 } |  j t | j |  |  j t	 j
 |  d S(   s   
        When an error happens during the print of the stats, C{sys.stdout}
        should be restored to its initial value.
        t   ErroneousProfilec           B   s   e  Z d    Z RS(   c         S   s   t  d   d  S(   Nt   Boom(   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   "  s    (   R7   R8   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR  !  s   t   ProfileR   RR   N(   R   R  R+   R   RD   Rc   R   RN   R   R   R   R]   R   R   R   (   R5   R  RI   RR   R   t	   oldStdout(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_profilePrintStatsError  s    
		c         C   s   t  j   } |  j   | d <d | d <t j |  } t   } | j |  |  j | j  t	 | d  j
   } |  j d |  |  j d |  d S(   s   
        L{app.HotshotRunner.run} should call the C{run} method of the reactor
        and save profile data in the specified file.
        R   t   hotshotRR   R   s   function callsN(   R   RD   Rc   R   RN   R   R   R   R   Re   R   RP   (   R5   RI   RR   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_hotshot4  s    
	s   hotshot module not availablec         C   s   t  j   } |  j   | d <d | d <t | d <t j |  } t   } | j |  |  j | j	  |  j
 t j j | d  d S(   s   
        With the C{savestats} option specified, L{app.HotshotRunner.run} should
        save the raw stats object instead of a summary output.
        R   R  RR   R   N(   R   RD   Rc   RH   R   RN   R   R   R   R   R   R  R   t   load(   R5   RI   RR   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_hotshotSaveStatsJ  s    

	c         C   s   t  j j   } d t  j d <t j   } d | d <t j |  } z |  j t	 | j
 d  Wd t  j j   t  j j |  Xd S(   s   
        When the C{hotshot} module is not present, L{app.HotshotRunner.run}
        should raise a C{SystemExit} exception and log the C{ImportError}.
        R  RR   N(   R   R   R   RV   R   RD   R   RN   R]   R   R   R   R   (   R5   R   RI   RR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_withoutHotshot_  s    
c         C   s   d t  j f d     Y} |  j t  d |  t j   } |  j   | d <d | d <t j |  } t   } t	 j
 } |  j t | j |  |  j t	 j
 |  d S(   s   
        When an error happens while printing the stats, C{sys.stdout}
        should be restored to its initial value.
        t   ErroneousStatsc           B   s   e  Z d    Z RS(   c         S   s   t  d   d  S(   NR  (   R   (   R5   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   w  s    (   R7   R8   R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR  v  s   R   R   R  RR   N(   R   R   R+   R   RD   Rc   R   RN   R   R   R   R]   R   R   R   (   R5   R  RI   RR   R   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_hotshotPrintStatsErrorq  s    
		c         C   s   t  j   } |  j   | d <d | d <t j |  } t   } | j |  |  j | j  t	 | d  j
   } |  j d |  |  j d |  d S(   s   
        L{app.CProfileRunner.run} should call the C{run} method of the
        reactor and save profile data in the specified file.
        R   t   cProfileRR   R   s   function callsN(   R   RD   Rc   R   RN   R   R   R   R   Re   R   RP   (   R5   RI   RR   R   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_cProfile  s    
	s   cProfile module not availablec         C   s   t  j   } |  j   | d <d | d <t | d <t j |  } t   } | j |  |  j | j	  |  j
 t j | d  d S(   s   
        With the C{savestats} option specified,
        L{app.CProfileRunner.run} should save the raw stats object
        instead of a summary output.
        R   R  RR   R   N(   R   RD   Rc   RH   R   RN   R   R   R   R   R   R   R   (   R5   RI   RR   R   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_cProfileSaveStats  s    

	c         C   s   t  j j   } d t  j d <t j   } d | d <t j |  } z |  j t	 | j
 d  Wd t  j j   t  j j |  Xd S(   s   
        When the C{cProfile} module is not present,
        L{app.CProfileRunner.run} should raise a C{SystemExit}
        exception and log the C{ImportError}.
        R  RR   N(   R   R   R   RV   R   RD   R   RN   R]   R   R   R   R   (   R5   R   RI   RR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_withoutCProfile  s    
c         C   sX   t  j   } |  j   | d <d | d <|  j t t j |  } |  j t |  d  d S(   sq   
        Check that L{app.AppProfiler} raises L{SystemExit} when given an
        unknown profiler name.
        R   t   foobarRR   s!   Unsupported profiler name: foobarN(	   R   RD   Rc   R]   R   R   RN   RG   RM   (   R5   RI   t   error(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_unknownProfiler  s
    
c         C   s&   t  j i   } |  j | j d  d S(   sT   
        L{app.Profiler} defaults to the hotshot profiler if not specified.
        R  N(   R   RN   RG   RR   (   R5   RR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_defaultProfiler  s    c         C   s-   t  j i d d 6 } |  j | j d  d S(   se   
        The case of the profiler name passed to L{app.AppProfiler} is not
        relevant.
        t   HotShotRR   R  N(   R   RN   RG   RR   (   R5   RR   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_profilerNameCaseInsentive  s    N(   R7   R8   R9   R   R   RV   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_twistd.pyR     s@   														c            s5   g   t  j      f d   } |  t  d |   S(   s  
    Patch L{log.FileLogObserver} to record every call and keep a reference to
    the passed log file for tests.

    @param patch: a callback for patching (usually L{unittest.TestCase.patch}).

    @return: the list that keeps track of the log files.
    @rtype: C{list}
    c            s    j  |     |   S(   N(   Rs   (   t   logFile(   t   oldFileLobObservert   logFiles(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   FileLogObserver  s    R  (   R   R  (   R+   R  (    (   R  R  s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   _patchFileLogObserver  s
    
	t   AppLoggerTestCasec           B   sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s   
    Tests for L{app.AppLogger}.

    @ivar observers: list of observers installed during the tests.
    @type observers: C{list}
    c            s/   g    _    f d   }   j t d |  d S(   sx   
        Override L{log.addObserver} so that we can trace the observers
        installed in C{self.observers}.
        c            s!     j  j |   t j |   d  S(   N(   t	   observersRs   R   t   addObserver(   t   observer(   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   startLoggingWithObserver	  s    R   N(   R  R+   R   (   R5   R   (    (   R5   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRk     s    	c         C   s%   x |  j  D] } t j |  q
 Wd S(   s1   
        Remove all installed observers.
        N(   R  R   t   removeObserver(   R5   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   tearDown  s    c         C   sU   |  j  |  j | j g  |  j d | d d d  |  j d | d d d  d S(   s   
        Ensure that initial C{twistd} logs are written to the given list.

        @type logs: C{list}
        @param logs: The list whose C{append} method was specified as the
            initial log observer.
        s   starting upi    t   messages   reactor classi   N(   RG   R  Rs   RP   (   R5   t   logs(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   _checkObserver  s    c            sH   t  j i   } g      f d   | _ | j t    |  j    d S(   s   
        L{app.AppLogger.start} calls L{log.addObserver}, and then writes some
        messages about twistd and the reactor.
        c              s     j  S(   N(   Rs   (    (   R  (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR   +  s    N(   R   t	   AppLoggert   _getLogObserverR=   R
   R%  (   R5   Ry   (    (   R  s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt
   test_start$  s
    c         C   sO   t    } g  } | j t | j  t j i   } | j |  |  j |  d S(   s   
        When the L{ILogObserver} component is available on the application,
        that object will be used as the log observer instead of constructing a
        new one.
        N(   R
   t   setComponentR   Rs   R   R&  R=   R%  (   R5   R<   R$  Ry   (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt$   test_startUsesApplicationLogObserver0  s    	c         C   s   t  j i d d 6 } t |  j  } | j   } |  j t |  d  |  j | d t j	  t  j i d d 6 } | j   } |  j t |  d  |  j | d t j	  d S(   s   
        When logfile is empty or set to C{-}, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at C{sys.stdout}.
        t   -t   logfilei   i    t    i   N(
   R   R&  R  R+   R'  RG   R   R   R   R   (   R5   Ry   R  R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_getLogObserverStdout>  s    c         C   sz   t  |  j  } |  j   } t j i | d 6 } | j   } |  j t |  d  |  j | d j t	 j j
 |   d S(   s   
        When passing the C{logfile} option, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path.
        R,  i   i    N(   R  R+   Rc   R   R&  R'  RG   R   R   R    t   abspath(   R5   R  t   filenameRy   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_getLogObserverFileR  s    c            s   g    t    }   f d   } |  j t d |  t j i   } | | _ | j   |  j   | g  | j   |  j   | g  |  j | j d  d S(   s   
        L{app.AppLogger.stop} removes the observer created in C{start}, and
        reinitialize its C{_observer} so that if C{stop} is called several
        times it doesn't break.
        c            s     j  |   d  S(   N(   Rs   (   R  (   t   removed(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   removej  s    R!  N(
   R   R+   R   R   R&  t	   _observerRv   RG   R   RV   (   R5   R  R3  Ry   (    (   R2  s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt	   test_stopb  s    		

(   R7   R8   R9   Rk   R"  R%  R(  R*  R.  R1  R5  (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR    s   							t   UnixAppLoggerTestCasec           B   sz   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 e d
 k rx d	 e _ n  RS(   sw   
    Tests for L{UnixAppLogger}.

    @ivar signals: list of signal handlers installed.
    @type signals: C{list}
    s   twistd unix not availablec            s/   g    _    f d   }   j t d |  d S(   ss   
        Fake C{signal.signal} for not installing the handlers but saving them
        in C{self.signals}.
        c            s     j  j |  | f  d  S(   N(   t   signalsRs   (   t   sigRj   (   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt
   fakeSignal  s    t   signalN(   R7  R+   R:  (   R5   R9  (    (   R5   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRk     s    	c         C   s   t  |  j  } t i d d 6t d 6 } | j   } |  j t |  d  |  j | d t j	  t i d d 6t d 6 } | j   } |  j t |  d  |  j | d t j	  d S(	   s   
        When non-daemonized and C{logfile} is empty or set to C{-},
        L{UnixAppLogger._getLogObserver} returns a log observer pointing at
        C{sys.stdout}.
        R+  R,  R   i   i    R-  i   N(
   R  R+   R   RH   R'  RG   R   R   R   R   (   R5   R  Ry   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR.    s    c         C   sI   t  i d d 6t d 6 } |  j t | j  } |  j t |  d  d S(   s   
        When daemonized and C{logfile} is set to C{-},
        L{UnixAppLogger._getLogObserver} raises C{SystemExit}.
        R+  R,  R   s&   Daemons cannot log to stdout, exiting!N(   R   RK   R]   R   R'  RG   RM   (   R5   Ry   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_getLogObserverStdoutDaemon  s    c            s   t  |  j  } |  j   } t i | d 6 } | j   } |  j t |  d  |  j | d j t j j	 |   |  j t |  j
  d  |  j |  j
 d d t j  t       f d   } | | d _ |  j
 d d } | d d    S(   s   
        When C{logfile} contains a file name, L{app.AppLogger._getLogObserver}
        returns a log observer pointing at the specified path, and a signal
        handler rotating the log is installed.
        R,  i   i    c              s     j  d   d  S(   N(   t   callbackRV   (    (   t   d(    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   rotate  s    N(   R  R+   Rc   R   R'  RG   R   R   R    R/  R7  R:  t   SIGUSR1R   R>  RV   (   R5   R  R0  Ry   R  R>  t	   rotateLog(    (   R=  s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR1    s    	c            sd     f d   }   j  t d |    j   } t i | d 6 } | j   }   j   j g   d S(   sy   
        If a signal handler is already installed,
        L{UnixAppLogger._getLogObserver} doesn't override it.
        c            s     j  |  t j  t   S(   N(   RG   R:  R?  R   (   R8  (   R5   (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   fakeGetSignal  s    t	   getsignalR,  N(   R+   R:  Rc   R   R'  RG   R7  (   R5   RA  R0  Ry   R  (    (   R5   s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt,   test_getLogObserverDontOverrideSignalHandler  s    c         C   sr   t  |  j  } t i d d 6t d 6 } | j   } |  j t |  d  |  j | d j t j j	 d   d S(   s   
        When daemonized and C{logfile} is empty, the observer returned by
        L{UnixAppLogger._getLogObserver} points at C{twistd.log} in the current
        directory.
        R-  R,  R   i   i    s
   twistd.logN(
   R  R+   R   RK   R'  RG   R   R   R    R/  (   R5   R  Ry   R  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_getLogObserverDefaultFile  s    c            sl   d t  f   f d     Y  |  j t d    t i t d 6d d 6 } | j   } |  j   j d  d S(   s   
        If C{syslog} is set to C{True}, L{UnixAppLogger._getLogObserver} starts
        a L{syslog.SyslogObserver} with given C{prefix}.
        t   fakesyslogobserverc              s    e  Z   f d    Z d   Z RS(   c            s   |   _  d  S(   N(   t   prefix(   R5   RF  (   RE  (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRq     s    c         S   s   d  S(   N(    (   R5   t	   eventDict(    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   emit  s    (   R7   R8   Rq   RH  (    (   RE  (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRE    s   t   SyslogObserverR   s   test-prefixRF  N(   R   R+   R   R   RH   R'  RG   RF  (   R5   Ry   R  (    (   RE  s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_getLogObserverSyslog  s
    s   Syslog not availableN(   R7   R8   R9   R   RV   R`   Rk   R.  R;  R1  RC  RD  RJ  R   (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyR6  w  s   				
				t   DeprecationTestsc           B   s   e  Z d  Z d   Z RS(   s(   
    Tests for deprecated features.
    c         C   s   g  } t  j | j  |  j t  j | j  |  j t d d d d  t j  |  j	 t
 |  d  |  j d | d d d  |  j d | d d d  d	 S(
   s2   
        L{app.initialLog} is deprecated.
        t   Twistedi   i   i    s   starting upR#  s   reactor classi   N(   R   R  Rs   t
   addCleanupR!  t   callDeprecatedR	   R   t
   initialLogRG   R   RP   (   R5   R$  (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   test_initialLog  s    "(   R7   R8   R9   RP  (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyRK    s   (I   R9   R:  R   R   R    R   Rf   R   R   R"   t   ImportErrorRV   t   zope.interfaceR    t   zope.interface.verifyR   t   twisted.trialR   t   twisted.applicationR   R   t   twisted.scriptsR   t   twisted.pythonR   t   twisted.python.usageR   t   twisted.python.logR   t   twisted.python.versionsR	   t   twisted.python.componentsR
   t   twisted.internet.deferR   t   twisted.python.fakepwdR   R   R   t   twisted.scripts._twistd_unixR   R   R   R  t   hotshot.statsR   R   R  t   getattrR   R0   R   R1   R&  R;   R   R>   t   TestCaseRB   Ra   Ro   Rx   Rw   R~   R   R   R   R   R   R  R  R6  RK  (    (    (    s<   /usr/lib/python2.7/dist-packages/twisted/test/test_twistd.pyt   <module>   s   $0




		-
E,# !	|