+
    Dfjnk                    \   R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHtHtH	t	H
t
Ht ^ RIHt ^ RIHtHtHt ^ RIHtHt ^ RIHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHtHt ^ RI H!t! ]! ]4       ! R R4      4       t" ! R R]]4      t# ! R R]!PH                  4      t% ! R R]!PL                  4      t'R# )z&
Tests for L{twisted.runner.procmon}.
)annotationsN)AnyStrMappingOptionalSequenceUnion)implementer)ProcessDoneProcessExitedAlreadyProcessTerminated)IProcessProtocolIProcessTransport)Clock)MemoryReactor)globalLogPublisher)Failure)LoggingProtocolProcessMonitor)unittestc                  <    ] tR t^tRt^tRt^tRR ltR t	R t
RtR# )DummyProcessa  
An incomplete and fake L{IProcessTransport} implementation for testing how
L{ProcessMonitor} behaves when its monitored processes exit.

@ivar _terminationDelay: the delay in seconds after which the DummyProcess
    will appear to exit when it receives a TERM signal
Nc                	~    W`n         Wn        W n        W0n        W@n        WPn        Wpn        Wn        Wn        Wn	        R # N)
proto_reactor_executable_args_environment_path_uid_gid_usePTY	_childFDs)selfreactor
executableargsenvironmentpathr   uidgidusePTYchildFDss   &&&&&&&&&&&B/usr/lib/python3/dist-packages/twisted/runner/test/test_procmon.py__init__DummyProcess.__init__)   s8     
%
'
		!    c                    RV P                   ^ 3RR/pV P                  f   \        4       hW9   d8   W!,          w  r4V P                  P	                  W0P
                  V4      V n        R# R# )a  
A partial implementation of signalProcess which can only handle TERM and
KILL signals.
 - When a TERM signal is given, the dummy process will appear to exit
   after L{DummyProcess._terminationDelay} seconds with exit code 0
 - When a KILL signal is given, the dummy process will appear to exit
   immediately with exit code 1.

@param signalID: The signal name or number to be issued to the process.
@type signalID: C{str}
TERMKILLN)       )_terminationDelaypidr
   r   	callLaterprocessEnded_signalHandler)r#   signalIDparamsdelaystatuss   &&   r-   signalProcessDummyProcess.signalProcessB   sg     41115vvF88&((",ME"&--"9"9((&#D r0   c                    RV n         ^ \        ^\        /pV P                  P	                  \        W!,          ! V4      4      4       R# )z3
Deliver the process ended event to C{self.proto}.
N)r7   r	   r   r   r9   r   )r#   r>   	statusMaps   && r-   r9   DummyProcess.processEndedY   s>     { 
	 	

	(9&(A BCr0   )r   r"   r   r   r    r   r   r:   r   r!   r7   r   )NNr4   N)__name__
__module____qualname____firstlineno____doc__r7   r   r6   r.   r?   r9   __static_attributes__ r0   r-   r   r      s)     CE"2.	Dr0   r   c                  L    ] tR t^et$ RtR]R&   R]R&   R R ltRR	 R
 lltRtR# )DummyProcessReactorz
@ivar spawnedProcesses: a list that keeps track of the fake process
    instances built by C{spawnProcess}.

@ivar spawnProcessException: An exception which spawnProcess() will raise.
zlist[DummyProcess]spawnedProcesseszException | NonespawnProcessExceptionc                   V ^8  d   QhRR/#    returnNonerJ   )formats   "r-   __annotate__ DummyProcessReactor.__annotate__p   s     * *$ *r0   c                	z    \         P                  ! V 4       \        P                  ! V 4       . V n        R V n        R # r   )r   r.   r   rM   rN   r#   s   &r-   r.   DummyProcessReactor.__init__p   s,    t$t "%)"r0   Nc               @    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRR/
# )rQ   processProtocolr   r%   zUnion[bytes, str]r&   zSequence[Union[bytes, str]]envz!Optional[Mapping[AnyStr, AnyStr]]r(   zUnion[None, bytes, str]r)   zOptional[int]r*   r+   boolr,   z'Optional[Mapping[int, Union[int, str]]]rR   r   rJ   )rT   s   "r-   rU   rV   v   sn     ! !)! &! *	!
 /! &! ! ! ! :! 
!r0   c
                    V P                   e   V P                   h\        V VVVVVVVVV	4
      p
VP                  V
4       V P                  P	                  V
4       V
# )zb
Fake L{reactor.spawnProcess}, that logs all the process
arguments and returns a L{DummyProcess}.
)rN   r   makeConnectionrM   append)r#   r[   r%   r&   r\   r(   r)   r*   r+   r,   procs   &&&&&&&&&& r-   spawnProcess DummyProcessReactor.spawnProcessv   sm      %%1,,,
 	&&t,$$T*r0   )rN   rM   )NNNNFN)	rD   rE   rF   rG   rH   __annotations__r.   rb   rI   rJ   r0   r-   rL   rL   e   s$     )(++*! !r0   rL   c                      ] tR t^tRtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR R ltR R ltR tR tR tR tR tR tR tR tR tR tR tR t R  t!R! t"R" t#R# t$R$ t%R% t&R&t'R'# )(ProcmonTestsz
Tests for L{ProcessMonitor}.
c                    \        4       V n        \        V P                  R7      V n        ^V P                  n        ^
V P                  n        ^
V P                  n        R# )z<
Create an L{ProcessMonitor} wrapped around a fake reactor.
r$   N)rL   r$   r   pmminRestartDelaymaxRestartDelay	thresholdrX   s   &r-   setUpProcmonTests.setUp   sB     +, 6"#"$r0   c                    V P                   P                  RRR.^^/ R7       \        V P                   4      pV P                  RV4       V P                  RV4       V P                  RV4       R# )z
Repr includes all details
fooarg1arg2r)   r*   r\   12N)ri   
addProcessreprassertInr#   representations   & r-   test_reprLooksGoodProcmonTests.test_reprLooksGood   s]     	566"2qbIdgge^,c>*c>*r0   c                    V P                   P                  RRR./ R7       \        V P                   4      pV P                  RV4       V P                  RV4       R# )z
Repr does not include unneeded details.

Values of attributes that just mean "inherit from launching
process" do not appear in the repr of a process.
rp   rq   rr   )r\   ()N)ri   rv   rw   assertNotInry   s   & r-   test_simpleReprLooksGood%ProcmonTests.test_simpleReprLooksGood   sO     	566"2;dggn-n-r0   c                    V P                   P                  RRR.^^/ R7       V P                  V P                   P                  4       R,          RRR.^^/ 3/4       R# )zG
The list of monitored processes must be included in the pickle state.
rp   rq   rr   rs   	processesN)ri   rv   assertEqual__getstate__rX   s   &r-   test_getStateIncludesProcesses+ProcmonTests.test_getStateIncludesProcesses   s_     	566"2qbIGG  ";/%66:JAqRT9U1V	
r0   c                Z    V P                  RV P                  P                  4       4       R# )zf
The private L{ProcessMonitor._reactor} instance variable should not be
included in the pickle state.
r   N)r   ri   r   rX   s   &r-   test_getStateExcludesReactor)ProcmonTests.test_getStateExcludesReactor   s!    
 	TWW%9%9%;<r0   c                   V P                   P                  RRR.^^/ R7       V P                  V P                   P                  / 4       V P                  V P                   P                  RRR.^^/ 3/4       V P                   P                  4        V P                  P                  ^ 4       V P                  \        V P                   P                  P                  4       4      R.4       R# )zo
L{ProcessMonitor.addProcess} only starts the named program if
L{ProcessMonitor.startService} has been called.
rp   rq   rr   rs   N)
ri   rv   r   	protocolsr   startServicer$   advancelistkeysrX   s   &r-   test_addProcessProcmonTests.test_addProcess   s    
 	566"2qbI**B/**Uff5Eq!R4P,QRQdgg//4467%Ar0   c           
         V P                   P                  RRR.^^/ R7       V P                  \        V P                   P                  RRR.^^/ R7       R# )zd
L{ProcessMonitor.addProcess} raises a C{KeyError} if a process with the
given name already exists.
rp   rq   rr   rs   N)ri   rv   assertRaisesKeyErrorrX   s   &r-    test_addProcessDuplicateKeyError-ProcmonTests.test_addProcessDuplicateKeyError   sX    
 	566"2qbIdgg((%&&1AqaUW 	 	
r0   c                (   RR/pV P                   P                  4        V P                   P                  RR.^^VR7       V P                  P	                  ^ 4       V P                  V P                  P                  ^ ,          P                  V4       R# )zk
L{ProcessMonitor.addProcess} takes an C{env} parameter that is passed to
L{IReactorProcess.spawnProcess}.
KEYvaluerp   rs   N)ri   r   rv   r$   r   r   rM   r   )r#   fakeEnvs   & r-   test_addProcessEnvProcmonTests.test_addProcessEnv   st    
 '"55'qaWEQ66q9FFPr0   c                   V P                   P                  4        V P                   P                  RR.RR7       V P                  P	                  ^ 4       V P                  V P                  P                  ^ ,          P                  R4       R# )zk
L{ProcessMonitor.addProcess} takes an C{cwd} parameter that is passed
to L{IReactorProcess.spawnProcess}.
rp   z	/mnt/lala)cwdN)ri   r   rv   r$   r   r   rM   r   rX   s   &r-   test_addProcessCwdProcmonTests.test_addProcessCwd   sf    
 	55'{;Q66q9??Mr0   c                f   V P                   P                  4        V P                   P                  RR.4       V P                  \	        V P                   P
                  4      ^4       V P                   P                  R4       V P                  \	        V P                   P
                  4      ^ 4       R# )zU
L{ProcessMonitor.removeProcess} removes the process from the public
processes list.
rp   N)ri   r   rv   r   lenr   removeProcessrX   s   &r-   test_removeProcessProcmonTests.test_removeProcess   sz    
 	55'*TWW../3e$TWW../3r0   c                    V P                   P                  4        V P                  \        V P                   P                  R4       R# )zb
L{ProcessMonitor.removeProcess} raises a C{KeyError} if the given
process name isn't recognised.
rp   N)ri   r   r   r   r   rX   s   &r-   !test_removeProcessUnknownKeyError.ProcmonTests.test_removeProcessUnknownKeyError  s0    
 	(DGG$9$95Ar0   c                @   V P                   P                  RR.4       V P                   P                  R4       V P                  V P                   P                  R,          \
        4       V P                  RV P                   P                  P                  4       4       R# )z
When a process has been started, an instance of L{LoggingProtocol} will
be added to the L{ProcessMonitor.protocols} dict and the start time of
the process will be recorded in the L{ProcessMonitor.timeStarted}
dictionary.
rp   N)	ri   rv   startProcessassertIsInstancer   r   rx   timeStartedr   rX   s   &r-   test_startProcessProcmonTests.test_startProcess  sl     	55'*U#dgg//6HeTWW005578r0   c                    V P                   P                  RR.4       V P                   P                  R4       V P                  V P                   P                  R4      4       R# )zZ
L{ProcessMonitor.startProcess} silently returns if the named process is
already started.
rp   N)ri   rv   r   assertIsNonerX   s   &r-   test_startProcessAlreadyStarted,ProcmonTests.test_startProcessAlreadyStarted  sI    
 	55'*U#$''..u56r0   c                \    V P                  \        V P                  P                  R4       R# )za
L{ProcessMonitor.startProcess} raises a C{KeyError} if the given
process name isn't recognised.
rp   N)r   r   ri   r   rX   s   &r-    test_startProcessUnknownKeyError-ProcmonTests.test_startProcessUnknownKeyError"  s     
 	(DGG$8$8%@r0   c                   V ^8  d   QhRR/# rP   rJ   )rT   s   "r-   rU   ProcmonTests.__annotate__)  s     C Ct Cr0   c                   \        \        P                  \        P                  ! \        P                  4      4      V P
                  n        ^{V P                  n        ^{V P                  n	        V P                  P                  RR.4       V P                  P                  R4       V P                  V P                  P                  R,          ^{4       V P                  \        V P                  \         4      4      ^4       R# )zg
L{IReactorProcess.spawnProcess} might raise C{OSError}, ensure it
is caught and process is restarted.
rp   N)OSErrorerrnoEAGAINosstrerrorr$   rN   ri   rj   rk   rv   r   assertEqualsr=   r   flushLoggedErrorsrX   s   &r-   %test_startProcessSpawnCaughtException2ProcmonTests.test_startProcessSpawnCaughtException)  s    
 .5LL"++ell3.
* #&"%55'*U#$''--.4#d44W=>Br0   c                   V ^8  d   QhRR/# rP   rJ   )rT   s   "r-   rU   r   9  s     D D Dr0   c                    \        R4      V P                  n        V P                  P	                  RR.4       V P                  \         V P                  P                  R4       R# )za
L{IReactorProcess.spawnProcess} might raise C{OSError}, ensure other
exceptions are not caught.
zJust another exceptionrp   N)SystemErrorr$   rN   ri   rv   r   r   rX   s   &r-   'test_startProcessSpawnUncaughtException4ProcmonTests.test_startProcessSpawnUncaughtException9  sH    
 .99Q-R*55'*+tww';';UCr0   c                   V P                   P                  4        V P                   P                  RR.4       V P                  RV P                   P                  4       ^;qP                   P                  R,          P
                  n        V P                  P                  V P                   P                  4       V P                   P                  R4       V P                  P                  V4       V P                  P                  ^ 4       V P                  V P                  P                  4       V P                   P                  R,          4       R# )zU
L{ProcessMonitor.stopProcess} immediately sends a TERM signal to the
named process.
rp   N)ri   r   rv   rx   r   	transportr6   r$   r   rl   stopProcessr   secondsr   )r#   	timeToDies   & r-   "test_stopProcessNaturalTermination/ProcmonTests.test_stopProcessNaturalTerminationB  s    
 	55'*eTWW../ LML	GG%%e,66H 	TWW../E" 	Y'
 	Q 	--/1D1DU1KLr0   c                   V P                   P                  4        V P                   P                  RR.4       V P                  RV P                   P                  4       V P
                  P                  V P                   P                  4       V P                   P                  R,          P                  pV P                   P                  ^,           Vn
        V P                   P                  R4       V P
                  P                  V P                   P                  ^,
          4       V P                  RV P                   P                  R,          4       V P
                  P                  ^4       V P
                  P                  ^ ^ .4       V P                  V P
                  P                  4       V P                   P                  R,          4       R# )z}
L{ProcessMonitor.stopProcess} kills a process which fails to terminate
naturally within L{ProcessMonitor.killTime} seconds.
rp   g        N)ri   r   rv   rx   r   r$   r   rl   r   killTimer6   r   r   r   pumpr   )r#   ra   s   & r-   test_stopProcessForcedKill'ProcmonTests.test_stopProcessForcedKill`  s9   
 	55'*eTWW../TWW../ww  '11!%!1!1A!5E" 	TWW--12dgg11%89Q 	1a&!--/1D1DU1KLr0   c                \    V P                  \        V P                  P                  R4       R# )z`
L{ProcessMonitor.stopProcess} raises a C{KeyError} if the given process
name isn't recognised.
rp   N)r   r   ri   r   rX   s   &r-   test_stopProcessUnknownKeyError,ProcmonTests.test_stopProcessUnknownKeyError}  s     
 	(DGG$7$7?r0   c                    V P                   P                  RR.4       V P                  V P                   P                  R4      4       R# )z
L{ProcessMonitor.stopProcess} silently returns if the named process
is already stopped. eg Process has crashed and a restart has been
rescheduled, but in the meantime, the service is stopped.
rp   N)ri   rv   r   r   rX   s   &r-   test_stopProcessAlreadyStopped+ProcmonTests.test_stopProcessAlreadyStopped  s7     	55'*$''--e45r0   c                   . pV P                  \        P                  VP                  4       \        P                  ! VP                  4       V P
                  P                  RR.4       V P
                  P                  4        V P                  P                  ^ 4       V P                  RV P
                  P                  4       V P                  P                  V P
                  P                  4       V P
                  P                  R,          P                  R4       V P                  \        V4      ^4       V^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV P                  VR4       V P                  VR4       V P                  VR4       V P                  VR	4       R
# )zC
Getting a complete output line on stdout generates a log message.
rp      hello world!
log_namespacestreamtagline%twisted.runner.procmon.ProcessMonitorstdouthello world!N)
addCleanupr   removeObserverr`   addObserverri   rv   r   r$   r   rx   r   rl   outReceivedr   r   r#   events	namespacer   r   r   s   &     r-   test_outputReceivedCompleteLine,ProcmonTests.test_outputReceivedCompleteLine  K    *996==I&&v}}555'*QeTWW../TWW../% ,,->?#f+q)1Io.	8$Qiay )%LM&(+#u%$/r0   c                   . pV P                  \        P                  VP                  4       \        P                  ! VP                  4       V P
                  P                  RR.4       V P
                  P                  4        V P                  P                  ^ 4       V P                  RV P
                  P                  4       V P                  P                  V P
                  P                  4       V P
                  P                  R,          P                  R4       V P                  \        V4      ^4       V^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV P                  VR4       V P                  VR4       V P                  VR4       V P                  VR	4       R
# )zC
Getting a complete output line on stderr generates a log message.
rp   r   r   r   r   r   r   stderrr   N)r   r   r   r`   r   ri   rv   r   r$   r   rx   r   rl   errReceivedr   r   r   s   &     r-   !test_ouputReceivedCompleteErrLine.ProcmonTests.test_ouputReceivedCompleteErrLine  r   r0   c                v   . pV P                  \        P                  VP                  4       \        P                  ! VP                  4       V P
                  P                  RR.4       V P
                  P                  4        V P                  P                  ^ 4       V P                  RV P
                  P                  4       V P                  P                  V P
                  P                  4       V P
                  P                  R,          P                  R4       V P                  \        V4      ^4       V^ ,          pVR,          pVR,          pVR,          pVR,          pV P                  VR4       V P                  VR4       V P                  VR4       V P                  V\!        R	4      4       R
# )z>
Getting invalid UTF-8 results in the repr of the raw message
rp   s   hello world!
r   r   r   r   r   r   s   hello world!N)r   r   r   r`   r   ri   rv   r   r$   r   rx   r   rl   r   r   r   rw   )r#   r   messager   r   r   outputs   &      r-   *test_outputReceivedCompleteLineInvalidUTF87ProcmonTests.test_outputReceivedCompleteLineInvalidUTF8  sH    *996==I&&v}}555'*QeTWW../TWW../% ,,-BC#f+q))O,	"en)%LM&(+#u%&$':";<r0   c                <   . pV P                  \        P                  VP                  4       \        P                  ! VP                  4       V P
                  P                  RR.4       V P
                  P                  4        V P                  P                  ^ 4       V P                  RV P
                  P                  4       V P                  P                  V P
                  P                  4       V P
                  P                  R,          P                  R4       V P                  \        V4      ^ 4       V P
                  P                  R,          P!                  \#        \%        ^ 4      4      4       V P                  \        V4      ^4       V^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV^ ,          R,          pV P                  VR4       V P                  VR4       V P                  VR4       V P                  VR	4       R
# )z=
Getting partial line results in no events until process end
rp   s   hello world!r   r   r   r   r   r   r   N)r   r   r   r`   r   ri   rv   r   r$   r   rx   r   rl   r   r   r   r9   r   r	   r   s   &     r-   test_outputReceivedPartialLine+ProcmonTests.test_outputReceivedPartialLine  s    *996==I&&v}}555'*QeTWW../TWW../% ,,_=#f+q)% --gk!n.EF#f+q)1Io.	8$Qiay )%LM&(+#u%$/r0   c                   V P                   P                  RR.4       V P                   P                  4        V P                  P	                  ^ 4       V P                  RV P                   P                  4       V P                  P	                  V P                   P                  4       V P                   P                  R,          P                  \        \        ^ 4      4      4       V P                  RV P                   P                  4       V P                  P	                  ^ 4       V P                  RV P                   P                  4       R# )z
L{ProcessMonitor.processExit} should immediately restart a process
if it has been running longer than L{ProcessMonitor.threshold} seconds.
rp   N)ri   rv   r   r$   r   rx   r   rl   r9   r   r	   r   rX   s   &r-   #test_connectionLostLongLivedProcess0ProcmonTests.test_connectionLostLongLivedProcess  s    
 	55'*QeTWW../TWW../% --gk!n.EF 1 12QeTWW../r0   c                   V P                   P                  RR.4       V P                   P                  4        V P                  P	                  ^4       V P                   P                  R4       V P                  RV P                   P                  4       V P                   P                  R,          pV P                  VP                  4       4       V P                  P	                  V P                   P                  R,          P                  P                  4       V P                  VP                  4       4       V P                  RV P                   P                  4       R# )z
L{ProcessMonitor.processExit} cancels a scheduled process killer and
deletes the DelayedCall from the L{ProcessMonitor.murder} list.
rp   N)ri   rv   r   r$   r   r   rx   murder
assertTrueactiver   r   r6   assertFalser   )r#   delayedCalls   & r-   test_connectionLostMurderCancel,ProcmonTests.test_connectionLostMurderCancel  s    
 	55'*QE"eTWW^^,ggnnU+**,-TWW..u5??QQR++-./r0   c                   V P                   P                  4        V P                   P                  RR.4       V P                  RV P                   P                  4       V P                   P                  R,          P
                  P                  R4       V P                  P                  V P                   P                  R,          P
                  P                  4       V P                  RV P                   P                  4       R# )z}
L{ProcessMonitor.processExit} removes the corresponding
ProcessProtocol instance from the L{ProcessMonitor.protocols} list.
rp   r3   N)ri   r   rv   rx   r   r   r?   r$   r   r6   r   rX   s   &r-   #test_connectionLostProtocolDeletion0ProcmonTests.test_connectionLostProtocolDeletion%  s    
 	55'*eTWW../% **88@TWW..u5??QQR 1 12r0   c                   ^V P                   n        ^V P                   n        V P                   P                  4        V P                   P	                  RR.4       V P                  V P                   P                  R,          V P                   P                  4       V P                  P                  V P                   P                  ^,
          4       V P                   P                  R,          P                  \        \        ^ 4      4      4       V P                  V P                   P                  R,          V P                   P                  4       R# )zb
L{ProcessMonitor.processExit} will wait at least minRestartDelay s
and at most maxRestartDelay s
rp   N)ri   rj   rk   r   rv   r   r=   r$   r   rl   r   r9   r   r	   rX   s   &r-   %test_connectionLostMinMaxRestartDelay2ProcmonTests.test_connectionLostMinMaxRestartDelay1  s    
 #$"#55'*u-tww/F/FGTWW..23% --gk!n.EFu-tww/F/FGr0   c                   V P                   P                  4        V P                   P                  RR.4       V P                  P	                  V P                   P
                  ^,
          4       V P                  RV P                   P                  4       V P                  V P                   P                  R,          V P                   P                  4       V P                   P                  R,          P                  \        \        ^ 4      4      4       V P                  V P                   P                  R,          V P                   P                  ^,          4       R# )za
L{ProcessMonitor.processExit} doubles the restart delay each time
the process dies too quickly.
rp   N)ri   r   rv   r$   r   rl   rx   r   r   r=   rj   r9   r   r	   rX   s   &r-   &test_connectionLostBackoffDelayDoubles3ProcmonTests.test_connectionLostBackoffDelayDoublesA  s    
 	55'*TWW..23eTWW../u-tww/F/FG% --gk!n.EFu-tww/F/F/JKr0   c                    V P                   P                  RR.4       V P                   P                  4        V P                  P	                  ^ 4       V P                  RV P                   P                  4       R# )z@
L{ProcessMonitor.startService} starts all monitored processes.
rp   N)ri   rv   r   r$   r   rx   r   rX   s   &r-   test_startServiceProcmonTests.test_startServiceO  sT     	55'*QeTWW../r0   c                   V P                   P                  RR.4       V P                   P                  RR.4       V P                   P                  4        V P                  P	                  V P                   P
                  4       V P                  RV P                   P                  4       V P                  RV P                   P                  4       V P                  P	                  ^4       V P                   P                  4        V P                  P	                  V P                   P                  ^,           4       V P                  / V P                   P                  4       R# )zD
L{ProcessMonitor.stopService} should stop all monitored processes.
rp   barN)ri   rv   r   r$   r   rl   rx   r   stopServicer   r   rX   s   &r-   test_stopServiceProcmonTests.test_stopServiceZ  s     	55'*55'*TWW../eTWW../eTWW../Q 	TWW--12TWW../r0   c                   V P                   P                  RR.4       V P                   P                  4        V P                  P	                  ^4       V P                   P                  4        V P                  P	                  ^4       \        V P                  P                  4      pVP                  4       pV P                  V. 4       V P                  VP                  4       R# )zB
L{ProcessMonitor.restartAll} succeeds when there is one process.
rp   N)ri   rv   r   r$   r   
restartAllr   rM   popr   r   r7   )r#   r   	myProcesss   &  r-   !test_restartAllRestartsOneProcess.ProcmonTests.test_restartAllRestartsOneProcessp  s     	55'*Q 	Q667	MMO	)R()--(r0   c                   V P                   P                  RR.4       V P                   P                  4        V P                  P	                  V P                   P
                  4       V P                  RV P                   P                  4       V P                  P	                  ^4       V P                   P                  R,          P                  \        \        ^ 4      4      4       V P                  V P                   P                  R,          P                  4       4       V P                   P                  4        V P                  V P                   P                  R,          P                  4       4       R# )zM
L{ProcessMonitor.stopService} should cancel any scheduled process
restarts.
rp   N)ri   rv   r   r$   r   rl   rx   r   r9   r   r	   r   restartr  r  r  rX   s   &r-   test_stopServiceCancelRestarts+ProcmonTests.test_stopServiceCancelRestarts  s    
 	55'*TWW../eTWW../Q% --gk!n.EF.5578/6689r0   c                   ^V P                   n        ^V P                   n        V P                   P                  4        V P                   P	                  RR.4       V P
                  P                  ^4       V P                   P                  R4       V P
                  P                  ^4       V P                   P                  4        V P
                  P                  ^4       V P                  V P                   P                  / 4       R# )zM
L{ProcessMonitor.stopService} should cancel all scheduled process
restarts.
rp   N)ri   rl   rj   r   rv   r$   r   r   r  r   r   rX   s   &r-   (test_stopServiceCleanupScheduledRestarts5ProcmonTests.test_stopServiceCleanupScheduledRestarts  s    
 "#55'*QE"QQ 	**B/r0   ri   r$   N)(rD   rE   rF   rG   rH   rm   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r
  r  r  r  r  r  r"  rI   rJ   r0   r-   rf   rf      s    +
.
=
B
	QN	4B
97AC DM<M:@60606=80:0(0*
3H L	00,) :(0r0   rf   c                  2    ] tR tRtRtR tR tR tR tRt	R# )	DeprecationTestsi  zI
Tests that check functionality that should be deprecated is deprecated.
c                Z    \        4       V n        \        V P                  R7      V n        R# )z%
Create reactor and process monitor.
rh   N)rL   r$   r   ri   rX   s   &r-   rm   DeprecationTests.setUp  s     +, 6r0   c                r   V P                   P                  RR.4       V P                   P                  pV P                  \	        V4      ^4       V P                  4       pRpV F2  pV P                  VR,          \        4       RVR,          9   g   K0  RpK4  	  V P                  VR\        V4       24       R# )	z
_Process.toTuple is deprecated.

When getting the deprecated processes property, the actual
data (kept in the class _Process) is converted to a tuple --
which produces a DeprecationWarning per process so converted.
rp   FcategorytoTupler   Tzno tuple deprecation found:N)
ri   rv   r   r   r   flushWarningsassertIsDeprecationWarningr   rw   )r#   myprocesseswarningsfoundToTuplewarnings   &    r-   test_toTupleDeprecationTests.test_toTuple  s     	55'*gg''#k*A.%%'GMM'*-/ABGI..#   	(CDNCS&TUr0   c                    V P                   P                  pV P                  V/ 4       V P                  4       pVP	                  ^ 4      pV P                  VR,          \        4       V P                  V. 4       R# )z
Accessing L{ProcessMonitor.processes} results in deprecation warning

Even when there are no processes, and thus no process is converted
to a tuple, accessing the L{ProcessMonitor.processes} property
should generate its own DeprecationWarning.
r*  N)ri   r   r   r,  r  r-  r.  )r#   myProcessesr0  firsts   &   r-   test_processesDeprecationTests.test_processes  sb     gg''+r*%%'QeJ');<(B'r0   c                    \         P                  ! V P                  4       V P                  4       pV F   pV P	                  VR,          \
        4       K"  	  R# )z?
Pickling an L{ProcessMonitor} results in deprecation warnings
r*  N)pickledumpsri   r,  r-  r.  )r#   r0  r2  s   &  r-   test_getstateDeprecationTests.test_getstate  s@     	TWW%%'GMM'*-/AB  r0   r$  N)
rD   rE   rF   rG   rH   rm   r3  r8  r=  rI   rJ   r0   r-   r&  r&    s    7V&(Cr0   r&  )(rH   
__future__r   r   r   r;  typingr   r   r   r   r   zope.interfacer   twisted.internet.errorr	   r
   r   twisted.internet.interfacesr   r   twisted.internet.taskr   twisted.internet.testingr   twisted.loggerr   twisted.python.failurer   twisted.runner.procmonr   r   twisted.trialr   r   rL   TestCaserf   SynchronousTestCaser&  rJ   r0   r-   <module>rL     s    #  	  = = & W W K ' 2 - * B " GD GD  GDT2- 2jO08$$ O0d5Cx33 5Cr0   