ó
ØÆ÷Xc           @` sâ   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z d  d l m	 Z	 e j
 d  d k rz d  d l m Z n d  d l m Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d „  Z d S(   i    (   t   divisiont   absolute_importt   print_functionN(   t   TemporaryFile(   t   exec_commandi   (   t   StringIOt   redirect_stdoutc           B` s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s9   Context manager to redirect stdout for exec_command test.c         C` s   | p t  j |  _ d  S(   N(   t   syst   stdoutt   _stdout(   t   selfR   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt   __init__   s    c         C` s   t  j |  _ |  j t  _ d  S(   N(   R   R   t
   old_stdoutR	   (   R
   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt	   __enter__   s    c         C` s*   |  j  j ƒ  |  j t _ |  j  j ƒ  d  S(   N(   R	   t   flushR   R   R   t   close(   R
   t   exc_typet	   exc_valuet	   traceback(    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt   __exit__   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   R   R   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR      s   	t   redirect_stderrc           B` s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s9   Context manager to redirect stderr for exec_command test.c         C` s   | p t  j |  _ d  S(   N(   R   t   stderrt   _stderr(   R
   R   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   !   s    c         C` s   t  j |  _ |  j t  _ d  S(   N(   R   R   t
   old_stderrR   (   R
   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   $   s    c         C` s*   |  j  j ƒ  |  j t _ |  j  j ƒ  d  S(   N(   R   R   R   R   R   R   (   R
   R   R   R   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   (   s    N(   R   R   R   R   R   R   R   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR      s   	t   emulate_nonposixc           B` s,   e  Z d  Z d d „ Z d „  Z d „  Z RS(   s.   Context manager to emulate os.name != 'posix' s	   non-posixc         C` s   | |  _  d  S(   N(   t	   _new_name(   R
   t   osname(    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   0   s    c         C` s   t  j |  _ |  j t  _ d  S(   N(   t   ost   namet	   _old_nameR   (   R
   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   3   s    c         C` s   |  j  t _ d  S(   N(   R!   R   R    (   R
   R   R   R   (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   7   s    (   R   R   R   R   R   R   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyR   .   s   	c           C` s˜   t  t ƒ  ƒ ( t t ƒ  ƒ  t j d ƒ Wd  QXWd  QXt j d k r” t ƒ  > t  t ƒ  ƒ ( t t ƒ  ƒ  t j d ƒ Wd  QXWd  QXWd  QXn  d  S(   Ns   cd '.'t   posix(   R   R   R   R   R   R   R    R   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt   test_exec_command_stdout;   s    
c           C` sž   t  t d d ƒ ƒ ( t t ƒ  ƒ  t j d ƒ Wd  QXWd  QXt j d k rš t ƒ  > t  t ƒ  ƒ ( t t ƒ  ƒ  t j d ƒ Wd  QXWd  QXWd  QXn  d  S(   Nt   modes   w+s   cd '.'R"   (   R   R   R   R   R   R   R    R   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt   test_exec_command_stderrQ   s    
(   t
   __future__R    R   R   R   R   t   tempfileR   t   numpy.distutilsR   t   version_infot   ioR   t   objectR   R   R   R#   R%   (    (    (    sF   /tmp/pip-build-X4mzal/numpy/numpy/distutils/tests/test_exec_command.pyt   <module>   s   	