def test_returncode( self ): "return codes" with shell() as sh: out = sh('true') self.assertEqual( out.returncode, 0 ) with shell() as sh: out = sh('false') self.assertEqual( out.returncode, 1 )
def test_exit(self): """Check that the pid of the shell does not exist anymore, or is not the son of this python object""" with shell() as sh: pass self.assertEqual(sh.shell.returncode, -15)
def test_sequence_of_command( self ): with shell() as sh: zero = sh('export coucou=1').returncode zero += sh('test $coucou==1').returncode zero += sh('myfunc () { echo coucou ; return 42 ; }').returncode zero += sh('myfunc').returncode zero += sh('( echo $coucou )').returncode self.assertEqual( zero, 42 )
def test_enter( self ): """use enter(), ask for the shell pid, check with the os that the process with this pid is 'sh'""" with shell() as sh: self.assertTrue( sh.shell.pid > 0)
def test_bashism( self ): "handy bash curly brackets" with shell() as sh: out = sh('echo a{b,c}') self.assertEqual( out.out, 'ab ac' )
def test_stderr( self ): "sh writes on stderr" with shell() as sh: out = sh('echo coucou >&2') self.assertEqual( out.err, 'coucou' )
def test_simple_command( self ): "sh writes on stdout" with shell() as sh: out = sh('echo coucou') self.assertEqual( out.out, 'coucou' )