ó
&9_[c           @   s   d  Z  d d l Z d d l Z d d l Z d d l j Z d d l m Z d d l	 m
 Z
 d Z d Z d „  Z e
 d „  ƒ Z d S(	   s   Test embedding of IPythoniÿÿÿÿN(   t   NamedFileInTemporaryDirectory(   t
   skip_win32su   
from __future__ import print_function
import IPython

a = 3
b = 14
print(a, '.', b)

IPython.embed()

print('bye!')
s   exitc          C   s  t  d ƒ ü }  |  j t ƒ |  j ƒ  |  j ƒ  t j |  j g } t j	 j
 ƒ  } d | d <t j | d | d t j d t j d t j ƒ} | j t ƒ \ } } | j d ƒ } t j | j d	 ƒ t j d
 | ƒ t j d k rô t j d | ƒ n  t j d | ƒ Wd QXd S(   s!   test that `IPython.embed()` workss   file_with_embed.pyt   1t   IPY_TEST_SIMPLE_PROMPTt   envt   stdint   stdoutt   stderrs   UTF-8i    s   3 . 14t   ntt   IPythons   bye!N(   R    t   writet   _sample_embedt   flusht   closet   syst
   executablet   namet   ost   environt   copyt
   subprocesst   Popent   PIPEt   communicatet   _exitt   decodeR   t   assert_equalt
   returncodet	   assert_in(   t   ft   cmdR   t   pt   outt   errt   std(    (    s@   lib/python2.7/site-packages/IPython/terminal/tests/test_embed.pyt   test_ipython_embed)   s     


c          C   s²  d d l  }  d } t j j ƒ  } d | d <|  j t j d d d g d	 | ƒ} | j | ƒ | j d
 ƒ | j | ƒ | j d ƒ | j | ƒ | j d ƒ | j d ƒ y2 d } x% | d k rÚ | j | d g ƒ } q¶ WWn |  j	 k
 rù } | GHn X| j d ƒ | j | ƒ | j d ƒ | j d d g ƒ d k sBt
 ‚ | j | ƒ | j d ƒ | j d d g ƒ d k s}t
 ‚ | j | ƒ | j d ƒ y2 d } x% | d k rÇ| j | d g ƒ } q£WWn |  j	 k
 ræ} | GHn X| j d ƒ | j | ƒ | j d ƒ | j d d g ƒ d k s/t
 ‚ | j | ƒ | j d ƒ | j d d g ƒ d k sjt
 ‚ | j | ƒ | j d ƒ | j | ƒ | j d ƒ | j d d g ƒ d k s¿t
 ‚ | j | ƒ | j d ƒ | j d d g ƒ d k sút
 ‚ | j | ƒ | j d ƒ | j | ƒ | j d ƒ | j d d g ƒ d k sOt
 ‚ | j | ƒ | j d ƒ | j d d g ƒ d k sŠt
 ‚ | j | ƒ | j d ƒ | j ƒ  d S(   s'   test that `IPython.embed()` is nestableiÿÿÿÿNs   ]:R   R   s   -mR	   s   --colors=nocolorR   s%   from __future__ import print_functions   import IPythons   ip0 = get_ipython()s   IPython.embed()i    s   
s   embed1 = get_ipython()s/   print('true' if embed1 is not ip0 else 'false')s   true
s   false
s=   print('true' if IPython.get_ipython() is embed1 else 'false')s   embed2 = get_ipython()s2   print('true' if embed2 is not embed1 else 'false')s=   print('true' if embed2 is IPython.get_ipython() else 'false')t   exits5   print('true' if get_ipython() is embed1 else 'false')s2   print('true' if get_ipython() is ip0 else 'false')s:   print('true' if IPython.get_ipython() is ip0 else 'false')(   t   pexpectR   R   R   t   spawnR   R   t   expectt   sendlinet   TIMEOUTt   AssertionErrorR   (   R%   t
   ipy_promptR   t   childt   promptedt   e(    (    s@   lib/python2.7/site-packages/IPython/terminal/tests/test_embed.pyt   test_nest_embedA   sx    
		 !!	 !!!!!!(   t   __doc__R   R   R   t
   nose.toolst   toolsR   t   IPython.utils.tempdirR    t   IPython.testing.decoratorsR   R   R   R#   R/   (    (    (    s@   lib/python2.7/site-packages/IPython/terminal/tests/test_embed.pyt   <module>   s   	