ó
]c           @   sü   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z m Z d d l	 m
 Z d d l m Z d d l m Z m Z d d l m Z d d l m
 Z
 d e
 j e
 j e j f d	     YZ d
   Z e d k rř e e    n  d S(   s   Tests for distutils.spawn.i˙˙˙˙N(   t   captured_stdoutt   run_unittest(   t   support(   t   _nt_quote_args(   t   spawnt   find_executable(   t   DistutilsExecErrort   SpawnTestCasec           B   s>   e  Z d    Z e j e j d k d  d    Z d   Z RS(   c         C   sa   xZ d d g d d g f d d g d d g f f D]( \ } } t  |  } |  j | |  q1 Wd  S(   Ns
   with spacet   nospaces   "with space"t   nochange(   R   t   assertEqual(   t   selft   argst   wantedt   res(    (    s+   lib/python2.7/distutils/tests/test_spawn.pyt   test_nt_quote_args   s    	t   ntt   posixs   Runs only under posix or ntc         C   s+  |  j    } t j d k rS t j j | d  } |  j | d  t j | d  n% t j j | d  } |  j | d  t j | d  |  j t t	 | g  t j d k rĺ t j j | d  } |  j | d  t j | d  n% t j j | d  } |  j | d  t j | d  t	 | g  d  S(	   NR   s   foo.shs   #!/bin/sh
exit 1i˙  s   foo.bats   exit 1s   #!/bin/sh
exit 0s   exit 0(
   t   mkdtempt   ost   namet   patht   joint
   write_filet   chmodt   assertRaisesR   R   (   R   t   tmpdirt   exe(    (    s+   lib/python2.7/distutils/tests/test_spawn.pyt
   test_spawn   s"    c   	      C   s  t  j   v} t  j } | d } t j j | |  } t | d   Wd  QXt j | t j	  t
 | d | } |  j | |  t j d k rś t
 | d | } |  j | |  n  t  j |  ! t
 |  } |  j | |  Wd  QXd | } t
 | d | } |  j |  t  j   _ } d d l m } t  j | j d |  . | j d	  t
 |  } |  j | |  Wd  QXWd  QXWd  QXd  S(
   Ns   .exet   wbR   t   win32t
   dontexist_i˙˙˙˙(   R   t   defpatht   PATH(   t   test_supportt   temp_dirt   TESTFNR   R   R   t   openR   t   statt   S_IXUSRR   R
   t   syst   platformt
   change_cwdt   assertIsNonet   EnvironmentVarGuardt	   distutilsR   t	   swap_attrt   pop(	   R   t   tmp_dirt   program_noeextt   programt   filenamet   rvt   dont_exist_programt   envR   (    (    s+   lib/python2.7/distutils/tests/test_spawn.pyt   test_find_executable;   s0    	

(   R   R   (	   t   __name__t
   __module__R   t   unittestt
   skipUnlessR   R   R   R7   (    (    (    s+   lib/python2.7/distutils/tests/test_spawn.pyR      s   	
c           C   s   t  j t  S(   N(   R:   t	   makeSuiteR   (    (    (    s+   lib/python2.7/distutils/tests/test_spawn.pyt
   test_suitee   s    t   __main__(   t   __doc__R   R&   R(   t   timeR:   t   test.supportR    R   t   testR   R"   t   distutils.spawnR   R   R   t   distutils.errorsR   t   distutils.testst   TempdirManagert   LoggingSilencert   TestCaseR   R=   R8   (    (    (    s+   lib/python2.7/distutils/tests/test_spawn.pyt   <module>   s"   	T	