ó
&9_[c           @@ sU  d  Z  d d l m Z d d l m Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 m Z m Z d d l Z d d l j Z d d l m Z m Z m Z d d l m Z m Z m Z d d l m Z m Z d d	 l m Z e rŝ d d
 l m Z n d d
 l m Z d   Z d e j  f d     YZ! d   Z" e d    Z# d   Z$ d S(   s   Tests for io.pyi    (   t   print_function(   t   absolute_importN(   t   Popent   PIPE(   t   skipift
   skip_win32t   py3_only(   t   IOStreamt   Teet   capture_output(   t   doctest_refactor_printt   PY3(   t   TemporaryDirectory(   t   StringIOc          C@ sO   t    }  d } t |  d d } t | d |  t j |  j   | d  d S(   s"   Very simple check with stdout onlyt   Hellot   channelt   stdoutt   files   
N(   R   R   t   printt   ntt   assert_equalt   getvalue(   t   chant   textt   tee(    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   test_tee_simple   s
    	t   TeeTestCasec           B@ s   e  Z d  d  Z d   Z RS(   t   closec   	      C@ sħ   t    } t    } d } t t |  } t t | |  t | d | } t | d d d | t t | |  | j   } t j | j   |  | d k rŞ | j	   n ~ d  S(   NR   R   t   endt    R   R   (
   R   t   getattrt   syst   setattrR   R   R   R   R   R   (	   t   selfR   t   checkt   trapR   R   t   std_oriR   t   trap_val(    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   tchan*   s    		c         C@ sB   x; d d g D]- } x$ d d g D] } |  j  | |  q  Wq Wd  S(   NR   t   stderrR   t   del(   R&   (   R!   R   R"   (    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   test<   s    (   t   __name__t
   __module__R&   R)   (    (    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyR   (   s   c          C@ s   x| d	 D]t }  t  d |   } t t j d | g d t } | j   | j j   j   j	 d  } d | k s t
 |   q Wd S(
   s+   Test that io.stdin/out/err exist at startupt   stdinR   R'   s2   from IPython.utils import io;print io.%s.__class__s   -ct   asciis   IPython.utils.io.IOStreamN(   R,   R   R'   (   R
   R   R   t
   executableR   t   waitR   t   readt   stript   decodet   AssertionError(   t   namet   cmdt   pt	   classname(    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   test_io_initA   s    	
c          @ sU   d t  j f   f d     Y  t      }  |  j d  t |  d  sQ t  d S(   sA   IOStream initializes from a file-like object missing attributes. t   BadStringIOc           @ s   e  Z   f d    Z RS(   c         @ s&   t    |   j   } | j d  | S(   NR4   (   t   supert   __dir__t   append(   R!   t   attrs(   R9   (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyR;   R   s    (   R*   R+   R;   (    (   R9   (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyR9   Q   s   u   hi, bad iostream
R4   N(   t	   stdlib_ioR   R   t   writet   hasattrR3   (   t   iostream(    (   R9   s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   test_IOStream_initM   s    c          C@ sY   t    $ }  t d  t d d t j Wd QXt j |  j d  t j |  j d  d S(   s   capture_output() context workss
   hi, stdouts
   hi, stderrR   Ns   hi, stdout
s   hi, stderr
(   R	   R   R   R'   R   R   R   (   t   io(    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   test_capture_output[   s
    
(%   t   __doc__t
   __future__R    R   RC   R>   t   os.patht   ost   statR   t
   subprocessR   R   t   unittestt
   nose.toolst   toolsR   t   IPython.testing.decoratorsR   R   R   t   IPython.utils.ioR   R   R	   t   IPython.utils.py3compatR
   R   t   IPython.utils.tempdirR   R   R   t   TestCaseR   R8   RB   RD   (    (    (    s:   lib/python2.7/site-packages/IPython/utils/tests/test_io.pyt   <module>   s*   			