
    Vh                         d Z ddlmZ ddlmZmZ ddlZddlm	Z	 ddl	m
Z
mZ  G d	 d
ej                  j                  j                        Z G d d      Zy)z0
Tests for L{twisted.application.runner._exit}.
    )StringIO)OptionalUnionN   )_exit   )
ExitStatusexitc                   8    e Zd ZdZddZddZddZddZddZy)		ExitTestsz
    Tests for L{exit}.
    Nc                 d    t               | _        | j                  t        d| j                         y )Nsysexit)	DummyExitr
   patchr   selfs    Y/home/dcms/DCMS/lib/python3.12/site-packages/twisted/application/runner/test/test_exit.pysetUpzExitTests.setUp   s    K	

5)TYY/    c                 j    d}t        |       | j                  | j                   j                  |       y)zR
        L{exit} given an L{int} status code will pass it to L{sys.exit}.
        i  N)r
   assertEqualargr   statuss     r   test_exitStatusIntzExitTests.test_exitStatusInt   s(     V/r   c                     t         j                  }t        |       | j                  | j                  j                  |j
                         y)zu
        L{exit} given a L{ValueConstant} status code passes the corresponding
        value to L{sys.exit}.
        N)r	   	EX_CONFIGr
   r   r   valuer   s     r   test_exitConstantzExitTests.test_exitConstant!   s2    
 %%V5r   c                     t               }| j                  t        d|       d}t        d|       | j	                  |j                         |dz          y)zq
        L{exit} given a status code of zero (C{0}) writes the given message to
        standard output.
        stdoutHello, world.r   
Nr   r   r   r
   r   getvaluer   outmessages      r   test_exitMessageZerozExitTests.test_exitMessageZero*   sD    
 j

5(C(!Q48r   c                     t               }| j                  t        d|       d}t        d|       | j	                  |j                         |dz          y)zj
        L{exit} given a non-zero status code writes the given message to
        standard error.
        stderrr"   @   r#   Nr$   r&   s      r   test_exitMessageNonZeroz!ExitTests.test_exitMessageNonZero7   sD    
 j

5(C(!R48r   returnN)	__name__
__module____qualname____doc__r   r   r   r)   r-    r   r   r   r      s     00699r   r   c                   :    e Zd ZdZddZddeeeef      ddfdZ	y)	r   zv
    Stub for L{sys.exit} that remembers whether it's been called and, if it
    has, what argument it was given.
    r/   Nc                     d| _         y )NF)exitedr   s    r   __init__zDummyExit.__init__K   s	    r   r   c                 <    | j                   rJ || _        d| _         y )NT)r7   r   )r   r   s     r   __call__zDummyExit.__call__N   s    ;;r   r.   )N)
r0   r1   r2   r3   r8   r   r   intstrr:   r4   r   r   r   r   E   s,    
HU38_5  r   r   )r3   ior   typingr   r   twisted.trial.unittesttwistedrunnerr   r	   r
   trialunittestTestCaser   r   r4   r   r   <module>rE      sB     "   $29&&// 29j r   