ó
æNXc           @@ sß   d  Z  d d l m Z 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 e j f d „  ƒ  YZ d „  a d „  Z d „  Z d „  Z d S(   s  Global IPython app to support test running.

We must start our own ipython object and heavily muck with it so that all the
modifications IPython makes to system behavior don't send the doctest machinery
into a fit.  This code should be considered a gross hack, but it gets the job
done.
i    (   t   absolute_import(   t   print_functionNi   (   t   tools(   t   page(   t   io(   t	   py3compat(   t   builtin_mod(   t   TerminalInteractiveShellt   StreamProxyc           B@ s/   e  Z d  Z d „  Z e d „  ƒ Z d „  Z RS(   s  Proxy for sys.stdout/err.  This will request the stream *at call time*
    allowing for nose's Capture plugin's redirection of sys.stdout/err.

    Parameters
    ----------
    name : str
        The name of the stream. This will be requested anew at every call
    c         C@ s   | |  _  d  S(   N(   t   name(   t   selfR	   (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   __init__1   s    c         C@ s   t  t |  j ƒ S(   N(   t   getattrt   sysR	   (   R
   (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   stream4   s    c         C@ s   |  j  j ƒ  d  S(   N(   R   t   flush(   R
   (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyR   8   s    (   t   __name__t
   __module__t   __doc__R   t   propertyR   R   (    (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyR   '   s   	c           C@ s   t  ƒ  S(   N(   t   start_ipython(    (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   get_ipython<   s    c         C@ sE   t  |  j | d t d d ƒj ƒ  d d d t j ƒt j j ƒ  d S(   sF   Replace the default system call with a capturing one for doctest.
    t   splitt   depthi   t   endt    t   fileN(   t   printt	   getoutputt   Falset   rstripR   t   stdoutR   (   R
   t   cmd(    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   xsysE   s    4c         C@ s#   t  |  j j | ƒ d t j ƒd S(   sD   Print the traceback purely on stdout for doctest to capture it.
    R   N(   R   t   InteractiveTBt   stb2textR   R   (   R
   t   etypet   evaluet   stb(    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   _showtracebackN   s    c          C@ s4  t  t d ƒ r d St t _ t j }  t j } t j j d ƒ } t	 j
 ƒ  } t j d | ƒ } | j j | j j ƒ | j j ƒ  t j t | ƒ | _ t j t | ƒ | _ | t j d <|  t _ | t _ | } | j a | t _ t t _ t d ƒ t _ t d ƒ t _ d d d d „ } t  j! t  _" | t  _! | S(	   sM   Start a global IPython shell, which we need for IPython-specific syntax.
    t   already_calledNt   __main__t   configR   t   stderri    c         S@ s   t  |  ƒ d  S(   N(   R   (   t   strngt   startt   screen_linest	   pager_cmd(    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   nopage   s    (#   t   hasattrR   t   TrueR(   R   t   displayhookt
   excepthookt   modulest   getR   t   default_configR   t   instancet	   tempfilest   appendt   HistoryManagert	   hist_filet   builtin_trapt   activateR   t
   MethodTypeR!   t   systemR'   R   R   t   _ipR   R   R   R+   t   NoneR   t
   pager_paget	   orig_page(   t   _displayhookt   _excepthookt   _mainR*   t   shellRA   R0   (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyR   T   s2    									(   R   t
   __future__R    R   t   osR   R   R   t   IPython.coreR   t   IPython.utilsR   R   t   IPython.utils.py3compatR   t!   IPython.terminal.interactiveshellR   t   IOStreamR   R   R!   R'   R   (    (    (    sS   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/testing/globalipapp.pyt   <module>   s   					