Current File : //lib/python3/dist-packages/twisted/application/runner/test/__pycache__/test_exit.cpython-312.pyc |
�
Ϫ�f� � � � d Z ddlmZ ddlmZmZ ddlZddlm Z ddl m
Z
mZ G d � d
ej j j � Z G d� d� Zy)
z0
Tests for L{twisted.application.runner._exit}.
� )�StringIO)�Optional�UnionN� )�_exit� )�
ExitStatus�exitc �8 � e Zd ZdZdd�Zdd�Zdd�Zdd�Zdd�Zy) � ExitTestsz
Tests for L{exit}.
Nc �d � t � | _ | j t d| j � y )N�sysexit)� DummyExitr
�patchr ��selfs �K/usr/lib/python3/dist-packages/twisted/application/runner/test/test_exit.py�setUpzExitTests.setUp s � ��K�� ��
�
�5�)�T�Y�Y�/� 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_exitStatusIntzExitTests.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_exitConstantzExitTests.test_exitConstant! s2 � �
�%�%���V�������������5r c � � t � }| j t d|� d}t d|� | j |j � |dz � 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_exitMessageZerozExitTests.test_exitMessageZero* sD � �
�j���
�
�5�(�C�(�!���Q�����������4��8r c � � t � }| j t d|� d}t d|� | j |j � |dz � y)zj
L{exit} given a non-zero status code writes the given message to
standard error.
�stderrr"