<s> import py <EOL> from py . process import cmdexec <EOL> def exvalue ( ) : <EOL> return py . std . sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> class Test_exec_cmd : <EOL> def test_simple ( self ) : <EOL> out = cmdexec ( '<STR_LIT>' ) <EOL> assert out . strip ( ) == '<STR_LIT>' <EOL> assert py . builtin . _istext ( out ) <EOL> def test_simple_newline ( self ) : <EOL> import sys <EOL> out = cmdexec ( r"""<STR_LIT>""" % sys . executable ) <EOL> assert out == '<STR_LIT>' <EOL> assert py . builtin . _istext ( out ) <EOL> def test_simple_error ( self ) : <EOL> py . test . raises ( cmdexec . Error , cmdexec , '<STR_LIT>' ) <EOL> def test_simple_error_exact_status ( self ) : <EOL> try : <EOL> cmdexec ( '<STR_LIT>' ) <EOL> except cmdexec . Error : <EOL> e = exvalue ( ) <EOL> assert e . status == <NUM_LIT:1> <EOL> assert py . builtin . _istext ( e . out ) <EOL> assert py . builtin . _istext ( e . err ) <EOL> def test_err ( self ) : <EOL> try : <EOL> cmdexec ( '<STR_LIT>' ) <EOL> raise AssertionError ( "<STR_LIT>" ) <EOL> except cmdexec . Error : <EOL> e = exvalue ( ) <EOL> assert hasattr ( e , '<STR_LIT>' ) <EOL> assert hasattr ( e , '<STR_LIT>' ) <EOL> assert e . err or e . out </s>
