
    Yf                         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dS )z0
Tests for L{twisted.application.runner._exit}.
    )StringIO)OptionalUnionN   )_exit   )
ExitStatusexitc                   :    e Zd ZdZd	dZd	dZd	dZd	dZd	dZdS )
	ExitTestsz
    Tests for L{exit}.
    returnNc                 n    t                      | _        |                     t          d| j                   d S )Nsysexit)	DummyExitr
   patchr   selfs    [/var/www/html/env/lib/python3.11/site-packages/twisted/application/runner/test/test_exit.pysetUpzExitTests.setUp   s+    KK	

5)TY/////    c                 h    d}t          |           |                     | j         j        |           dS )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   s4     V/////r   c                     t           j        }t          |           |                     | j        j        |j                   dS )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!   s9    
 %V55555r   c                     t                      }|                     t          d|           d}t          d|           |                     |                                |dz              dS )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*   s`    
 jj

5(C(((!Q488888r   c                     t                      }|                     t          d|           d}t          d|           |                     |                                |dz              dS )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   s`    
 jj

5(C(((!R488888r   r   N)	__name__
__module____qualname____doc__r   r   r    r*   r.    r   r   r   r      s         0 0 0 00 0 0 06 6 6 69 9 9 99 9 9 9 9 9r   r   c                   H    e Zd ZdZddZddeeeef                  ddfdZ	dS )	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| _         d S )NF)exitedr   s    r   __init__zDummyExit.__init__K   s    r   r   c                 4    | j         rJ || _        d| _         d S )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   sf         
    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      s           " " " " " " " "           $ $ $ $ $ $ $ $29 29 29 29 29&/ 29 29 29j         r   