U
    puf                     @   s`   d Z ddlZddlmZ ddlZddlmZmZ dd ZG dd dej	Z
G d	d
 d
ej	ZdS )zTests for io.py    N)StringIO)Teecapture_outputc                  C   s:   t  } d}t| dd}t|| d |  |d ks6tdS )z"Very simple check with stdout onlyHellostdoutchannelfile
N)r   r   printgetvalueAssertionError)chantexttee r   ?/tmp/pip-unpacked-wheel-bxwx4lqe/IPython/utils/tests/test_io.pytest_tee_simple   s
    r   c                   @   s   e Zd Zdd Zdd ZdS )TeeTestCasec                 C   s   t  }t  }d}tt|}tt|| t||d}t|d|d | }| | | |  tt|| tt||ks~t	d S )Nr   r    )endr
   )
r   getattrsyssetattrr   r   r   assertEqualcloser   )selfr   Ztrapr   r   Zstd_orir   Ztrap_valr   r   r   tchan   s    
zTeeTestCase.tchanc                 C   s   dD ]}|  | qd S )N)r   stderr)r   )r   r   r   r   r   test.   s    zTeeTestCase.testN)__name__
__module____qualname__r   r    r   r   r   r   r      s   r   c                   @   s   e Zd Zdd ZdS )TestIOStreamc              	   C   sH   t  }td tdtjd W 5 Q R X | |jd | |jd dS )zcapture_output() context worksz
hi, stdoutz
hi, stderrr	   zhi, stdout
zhi, stderr
N)r   r   r   r   r   r   )r   ior   r   r   test_capture_output4   s
    z TestIOStream.test_capture_outputN)r!   r"   r#   r&   r   r   r   r   r$   2   s   r$   )__doc__r   r%   r   ZunittestZIPython.utils.ior   r   r   ZTestCaser   r$   r   r   r   r   <module>   s   	