ó
æNXc           @   s>  d  Z  d d l Z d d l Z d d l m Z d d l j Z d d l m	 Z	 m
 Z
 m Z m Z m Z m Z m Z d d l m Z d d l m Z e j j e j ƒ Z e j d „  ƒ Z d „  Z e j e d	 ƒ d
 „  ƒ Z e j d „  d ƒ d „  ƒ Z e j d „  ƒ Z e j d „  ƒ Z  d e e j! f d „  ƒ  YZ" d S(   s   
Tests for platutils.py
iÿÿÿÿN(   t   TestCase(   t   find_cmdt   FindCmdErrort	   arg_splitt   systemt	   getoutputt   getoutputerrort   get_output_error_code(   t
   decorators(   t   toolsc          C   s&   t  d ƒ }  t j |  j d ƒ ƒ d S(   s*   Make sure we can find the full path to ls.t   lsN(   R   t   ntt   assert_truet   endswith(   t   path(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_find_cmd_ls$   s    c          C   s)   y d d  l  }  Wn t k
 r$ t SXt S(   Niÿÿÿÿ(   t   win32apit   ImportErrort   Falset   True(   R   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   has_pywin32+   s
    s"   This test requires win32api to runc          C   s1   t  d ƒ }  |  j ƒ  j d ƒ s- t |  ƒ ‚ d S(   s   Try to find pythonw on Windows.t   pythonws   pythonw.exeN(   R   t   lowerR   t   AssertionError(   R   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_find_cmd_pythonw3   s    c           C   s   t  j d k p t ƒ  S(   Nt   win32(   t   syst   platformR   (    (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   <lambda>:   s    s;   This test runs on posix or in win32 with win32api installedc           C   s   t  j t t d ƒ d S(   s?   Make sure that FindCmdError is raised if we can't find the cmd.t   asdfasdfN(   R   t   assert_raisesR   R   (    (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_find_cmd_fail:   s    c          C   sy   d d g g d d g g d d d g g d d g g d d d	 g g g }  x* |  D]" \ } } t  j t | ƒ | ƒ qO Wd
 S(   s?   Ensure that argument lines are correctly split like in a shell.t   hiu   his   hello theret   hellot   thereu   hÇŽllos   something "with quotes"t	   somethings   "with quotes"N(   R   t   assert_equalR   (   t   testst   argstrt   argv(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_arg_splitA   s    c          C   sy   d d g g d d g g d d d g g d d g g d d d	 g g g }  x* |  D]" \ } } t  j t | ƒ | ƒ qO Wd
 S(   s?   Ensure that argument lines are correctly split like in a shell.R    u   his   hello thereR!   R"   u   hÇŽllos   something "with quotes"R#   s   with quotesN(   R   R$   R   (   R%   R&   R'   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_arg_split_win32P   s    t   SubProcessTestCasec           B   sY   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z e j d „  ƒ Z	 d „  Z
 d „  Z RS(   c         C   s2   d d d d d d g } |  j  d j | ƒ ƒ d S(	   s   Make a valid python temp file.s%   from __future__ import print_functions
   import syss+   print('on stdout', end='', file=sys.stdout)s+   print('on stderr', end='', file=sys.stderr)s   sys.stdout.flush()s   sys.stderr.flush()s   
N(   t   mktmpt   join(   t   selft   lines(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   setUp^   s    	c         C   s-   t  d t |  j f ƒ } |  j | d ƒ d  S(   Ns   %s "%s"i    (   R   t   pythont   fnamet   assertEqual(   R-   t   status(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_systemh   s    c         C   s$   t  d t ƒ } |  j | d ƒ d  S(   Ns   %s -c "import sys"i    (   R   R0   R2   (   R-   R3   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_system_quotesl   s    c         C   sU   t  d t |  j f ƒ } y |  j | d ƒ Wn! t k
 rP |  j | d ƒ n Xd  S(   Ns   %s "%s"s   on stderron stdouts   on stdouton stderr(   R   R0   R1   R2   R   (   R-   t   out(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_getoutputp   s
    c         C   s*   t  d t ƒ } |  j | j ƒ  d ƒ d  S(   Ns   %s -c "print (1)"t   1(   R   R0   R2   t   strip(   R-   R6   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_getoutput_quotedx   s    c         C   sP   t  d t ƒ } |  j | j ƒ  d ƒ t  d t ƒ } |  j | j ƒ  d ƒ d  S(   Ns   %s -c 'print (1)'R8   s   %s -c 'print ("1")'(   R   R0   R2   R9   (   R-   R6   (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_getoutput_quoted2}   s    c         C   sC   t  d t |  j f ƒ \ } } |  j | d ƒ |  j | d ƒ d  S(   Ns   %s "%s"s	   on stdouts	   on stderr(   R   R0   R1   R2   (   R-   R6   t   err(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_getoutput_error„   s    c         C   s¥   d t  } t | ƒ \ } } } |  j | d ƒ |  j | d ƒ |  j | d ƒ t d t  |  j f ƒ \ } } } |  j | d ƒ |  j | d ƒ |  j | d ƒ d  S(   Ns   %s -c "import sys; sys.exit(1)"t    i   s   %s "%s"s	   on stdouts	   on stderri    (   R0   R   R2   R1   (   R-   t
   quiet_exitR6   R<   t   code(    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   test_get_output_error_code‰   s    
"(   t   __name__t
   __module__R/   R4   R5   R7   R:   t   dect
   skip_win32R;   R=   RA   (    (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyR*   ]   s   	
					(#   t   __doc__R   t   ost   unittestR    t
   nose.toolsR	   R   t   IPython.utils.processR   R   R   R   R   R   R   t   IPython.testingR   RD   t   ttR   t   basenamet
   executableR0   RE   R   R   t   onlyifR   R   R(   t   skip_if_not_win32R)   t   TempFileMixinR*   (    (    (    sX   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/tests/test_process.pyt   <module>   s    4	