ó
Û¤[c           @  sá   d  d l  m Z d  d l Z d  d l Z d  d l m Z d  d l m Z d  d l m	 Z	 d  d l
 m Z d  d l m Z d  d l m Z d  d	 l m Z e j r´ d  d
 l m Z n d  d
 l m Z d e j f d „  ƒ  YZ d S(   iÿÿÿÿ(   t   print_functionN(   t   BlockingInProcessKernelClient(   t   InProcessKernelManager(   t   InProcessKernel(   t   assemble_output(   t   skipif_not_matplotlib(   t   capture_output(   t	   py3compat(   t   StringIOt   InProcessKernelTestCasec           B  s;   e  Z d  „  Z e d „  ƒ Z d „  Z d „  Z d „  Z RS(   c         C  sI   t  ƒ  |  _ |  j j ƒ  |  j j ƒ  |  _ |  j j ƒ  |  j j ƒ  d  S(   N(   R   t   kmt   start_kernelt   clientt   kct   start_channelst   wait_for_ready(   t   self(    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   setUp   s
    c         C  s?   |  j  } | j d ƒ t | j ƒ \ } } |  j d | ƒ d S(   s*   Does %pylab work in the in-process kernel?s   %pylabt
   matplotlibN(   R   t   executeR   t   iopub_channelt   assertIn(   R   R   t   outt   err(    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt
   test_pylab    s    	c         C  s†   t  d ƒ } t j } | t _ z0 t j r= |  j j d ƒ n |  j j d ƒ Wd | t _ X|  j j j	 j
 j d ƒ d k s‚ t ‚ d S(   s@    Does the in-process kernel handle raw_input correctly?
        s   foobar
s   x = input()s   x = raw_input()Nt   xt   foobar(   R   t   syst   stdinR   t   PY3R   R   R
   t   kernelt   shellt   user_nst   gett   AssertionError(   R   t   iot	   sys_stdin(    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   test_raw_input(   s    			
c         C  s    t  ƒ  } t ƒ   } | j j d ƒ Wd QX| j d k s@ t ‚ t d | d | j ƒ } | j j	 | ƒ | j
 d ƒ t | j ƒ \ } } | d k sœ t ‚ d S(   s:    Does the in-process kernel correctly capture IO?
        s   print("foo")Ns   foo
R   t   sessions   print("bar")s   bar
(   R   R   R   t   run_cellt   stdoutR"   R   R&   t	   frontendst   appendR   R   R   (   R   R   R#   R   R   R   (    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   test_stdout7   s    	c         C  s2   t  ƒ  } t | _ d „  | _ | j d d ƒ d S(   s5   Tests that kernel getpass accept the stream parameterc          _  s   d  S(   N(   t   None(   t   argst   kwargs(    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   <lambda>J   s    t   streams	   non emptyN(   R   t   Truet   _allow_stdint   _input_requestt   getpass(   R   R   (    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   test_getpass_streamF   s    		(   t   __name__t
   __module__R   R   R   R%   R+   R5   (    (    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyR	      s
   			(   t
   __future__R    R   t   unittestt   ipykernel.inprocess.blockingR   t   ipykernel.inprocess.managerR   t   ipykernel.inprocess.ipkernelR   t   ipykernel.tests.utilsR   t   IPython.testing.decoratorsR   t   IPython.utils.ioR   t   ipython_genutilsR   R   R#   R   t   TestCaseR	   (    (    (    sD   lib/python2.7/site-packages/ipykernel/inprocess/tests/test_kernel.pyt   <module>   s   	