File: //lib/python3/dist-packages/twisted/application/runner/test/__pycache__/test_exit.cpython-38.pyc
U
W[� � @ s^ d Z ddlmZ ddlmZ ddlmZmZ ddlZG dd � d ej j
j�ZG d
d� de
�ZdS )z0
Tests for L{twisted.application.runner._exit}.
� )�NativeStringIO� )�_exit� )�exit�
ExitStatusNc @ sH e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Zdd
� Z dd� Z
dS )� ExitTestsz
Tests for L{exit}.
c C s t � | _| �td| j� d S )NZsysexit)� DummyExitr �patchr ��self� r
�K/usr/lib/python3/dist-packages/twisted/application/runner/test/test_exit.py�setUp s zExitTests.setUpc C s d}t |� | �| j j|� dS )zR
L{exit} given an L{int} status code will pass it to L{sys.exit}.
�� N�r �assertEqual�arg�r Zstatusr
r
r �test_exitStatusInt s zExitTests.test_exitStatusIntc C s | � ttd� dS )zn
L{exit} given a L{str} status code that isn't a string integer raises
L{ValueError}.
ZfooN)ZassertRaises�
ValueErrorr r r
r
r �test_exitStatusStringNotInt# s z%ExitTests.test_exitStatusStringNotIntc C s t d� | �| j jd� dS )z�
L{exit} given a L{str} status code that is a string integer passes the
corresponding L{int} to L{sys.exit}.
Z1234r Nr r r
r
r �test_exitStatusStringInt+ s z"ExitTests.test_exitStatusStringIntc C s$ t j}t|� | �| jj|j� dS )zu
L{exit} given a L{ValueConstant} status code passes the corresponding
value to L{sys.exit}.
N)r � EX_CONFIGr r r �valuer r
r
r �test_exitConstant4 s zExitTests.test_exitConstantc C s: t � }| �td|� d}td|� | �|�� |d � dS )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�messager
r
r �test_exitMessageZero>