File: //usr/local/lib/python3.10/test/__pycache__/test_code_module.cpython-310.opt-1.pyc
o
�i# � @ sx d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlm Z e �
d�ZG dd � d ej�Z
ed
kr:e�� dS dS )zCTest InteractiveConsole and InteractiveInterpreter from code module� N)�dedent)� ExitStack)�mock)�
import_helper�codec @ sd e Zd Zdd� Zdd� Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dS )�TestInteractiveConsolec C s t �� | _| �� d S )N)r ZInteractiveConsole�console�mock_sys��self� r �2/usr/local/lib/python3.10/test/test_code_module.py�setUp s
zTestInteractiveConsole.setUpc C s� t � }| �|j� |�tjddd��| _|�t�d��| _|�t�d��| _tjdt j
t j
d�}|�|�| _t
jt
j
u rB| jj
| j_| j`| j`dS ) z.Mock system environment for InteractiveConsolez
code.inputT)Zcreatezcode.sys.stdoutzcode.sys.stderrzcode.sys)�wraps�specN)r Z
addCleanup�close�
enter_contextr Zpatch�infunc�stdout�stderrr �sys�sysmod�
excepthook�__excepthook__�ps1�ps2)r �stackZprepatchr r r
r s
�
zTestInteractiveConsole.mock_sysc C sL t d�| j_| j�� | �| jjd� d| j_| j�� | �| jjd� d S )N�Finishedz>>> z custom1> )�EOFErrorr �side_effectr �interact�assertEqualr r r
r r r
�test_ps1# �
zTestInteractiveConsole.test_ps1c C sL t d�| j_| j�� | �| jjd� d| j_| j�� | �| jjd� d S )Nr z... z custom2> ) r r r r r r! r r r r
r r r
�test_ps2+ r# zTestInteractiveConsole.test_ps2c C sN ddt d�g| j_| j�� t| jj�D ]}dd�|d �v r" d S qt d��)Nz 'antioch'� r Zantioch� zno console stdout)
r r r r r �listr �method_calls�join�AssertionError�r �callr r r
�test_console_stderr3 s
�z*TestInteractiveConsole.test_console_stderrc C sH dt d�g| j_| j�� | jjD ]}dd�|d �v r d S qtd��)NZ undefinedr � NameErrorr% r&