
:Wg                 @   s]   d  d l  Z d  d l j j Z d  d l Z d  d l m Z d d   Z	 Gd d   d  Z
 d S)    N)cmdexecc               C   s   t  j j j   d S)N   )pystdsysexc_info r   r   B/home/ronny/Projects/pytest-dev/py/testing/process/test_cmdexec.pyexvalue   s    r
   c               @   sL   e  Z d  Z d d   Z d d   Z d d   Z d d   Z d	 d
   Z d S)Test_exec_cmdc             C   s  t  d  } | j } |   } d } | | k } | s t j d | f d | | f  d t j |  d d t j   k s t j |  r t j |  n d d t j |  d	 t j |  i } d d | i } t t j	 |    d  } } } } t
 j } | j } | |  } | sd
 d d t j |  d	 t j |  d d t j   k sbt j t
  rqt j t
  n d d t j |  d d t j   k st j |  rt j |  n d i } t t j	 |    d  } } } d  S)Nz
echo halloZhallo==D%(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.strip
}()
} == %(py7)spy4py0outpy2py7 assert %(py9)spy9zfassert %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.builtin
}._istext
}(%(py5)s)
}r   py5)r   )r   r   )r   strip
@pytest_ar_call_reprcompare	_saferepr@py_builtinslocals_should_repr_global_nameAssertionError_format_explanationr   builtin_istext)selfr   @py_assert1@py_assert3@py_assert6@py_assert5@py_format8@py_format10r   r   r	   test_simple   s"    	 	       	 	     zTest_exec_cmd.test_simplec       
      C   s  d d  l  } t d | j  } d } | | k } | s t j d | f d | | f  d d t j   k sy t j |  r t j |  n d d t j |  i } d d | i } t	 t j
 |    d  } } t j } | j } | |  } | sd	 d d t j |  d t j |  d d t j   k s=t j t  rLt j t  n d d t j |  d d t j   k st j |  rt j |  n d i }	 t	 t j
 |	    d  } } } d  S)Nr   z%s -c "print ('hello')" zhello
r   %(py0)s == %(py3)sr   r   py3r   assert %(py5)sr   zfassert %(py7)s
{%(py7)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.builtin
}._istext
}(%(py5)s)
}r   r   r   r   )r   )r*   r,   )r   r   
executabler   r   r   r   r   r   r   r   r   r    r!   )
r"   r   r   @py_assert2r#   @py_format4@py_format6r$   r%   r'   r   r   r	   test_simple_newline   s        j   
	 	     z!Test_exec_cmd.test_simple_newlinec             C   s   t  j j t j t d  d  S)Nzexit 1)r   testraisesr   Error)r"   r   r   r	   test_simple_error   s    zTest_exec_cmd.test_simple_errorc       
      C   s  y t  d  Wnt  j k
 rt   } | j } d } | | k } | s t j d | f d | | f  d d t j   k s t j |  r t j	 |  n d d t j	 |  d t j	 |  i } d d | i } t
 t j |    d  } } } t j } | j } | j } | |  } | sd	 d d t j	 |  d d t j   k s^t j t  rmt j	 t  n d d t j	 |  d d t j   k st j |  rt j	 |  n d d t j	 |  d t j	 |  i }	 t
 t j |	    d  } } } } t j } | j } | j } | |  } | sd	 d d t j	 |  d d t j   k sht j t  rwt j	 t  n d d t j	 |  d d t j   k st j |  rt j	 |  n d d t j	 |  d t j	 |  i }	 t
 t j |	    d  } } } } Yn Xd  S)Nzexit 1r   r   .%(py2)s
{%(py2)s = %(py0)s.status
} == %(py5)sr   er   r   r   assert %(py7)sr   zassert %(py9)s
{%(py9)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.builtin
}._istext
}(%(py7)s
{%(py7)s = %(py5)s.out
})
}r   r   r   zassert %(py9)s
{%(py9)s = %(py4)s
{%(py4)s = %(py2)s
{%(py2)s = %(py0)s.builtin
}._istext
}(%(py7)s
{%(py7)s = %(py5)s.err
})
})r   )r6   r8   )r   r4   r
   statusr   r   r   r   r   r   r   r   r   r    r!   r   err)
r"   r7   r#   @py_assert4r$   r0   r'   r%   @py_assert8r(   r   r   r	   test_simple_error_exact_status   s8    		    y   	 	 	     	 	 	     z,Test_exec_cmd.test_simple_error_exact_statusc             C   s  y t  d  t d   Wnt  j k
 rt   } d } t | |  } | s d d d t j |  d d t j   k s t j	 |  r t j |  n d d	 d
 t j   k s t j	 t  r t j t  n d
 d t j |  i } t t j
 |    d  } } d } t | |  } | sd d d t j |  d d t j   k s]t j	 |  rlt j |  n d d	 d
 t j   k st j	 t  rt j t  n d
 d t j |  i } t t j
 |    d  } } g  } | j } | } | s| j } | } | sd d t j |  d d t j   k s@t j	 |  rOt j |  n d i }	 | j |	  | sd d d t j   k st j	 |  rt j |  n d d t j |  i }
 | j |
  t j | d  i  } d d | i } t t j
 |    d  } } } } Yn Xd  S)Nzechoqweqwe123 hallozcommand succeeded but shouldn'tr:   r   z5assert %(py5)s
{%(py5)s = %(py0)s(%(py1)s, %(py3)s)
}r   py1r7   r   hasattrr+   r   z %(py4)s
{%(py4)s = %(py2)s.err
}r   r   z %(py8)s
{%(py8)s = %(py6)s.out
}py6py8r   assert %(py11)spy11rB   )r   r   r4   r
   r?   r   r   r   r   r   r   r:   r   append_format_boolop)r"   r7   r.   r;   r0   r#   r$   @py_assert0@py_assert7@py_format5@py_format9r(   @py_format12r   r   r	   test_err   sB    
	     
     
 	   	   O   O     zTest_exec_cmd.test_errN)__name__
__module____qualname__r)   r1   r5   r=   rK   r   r   r   r	   r      s
   	r   )builtinsr   _pytest.assertion.rewrite	assertionrewriter   r   Z
py.processr   r
   r   r   r   r   r	   <module>   s
     