Esempio n. 1
0
    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 )
Esempio n. 2
0
 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)
Esempio n. 3
0
    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 )
Esempio n. 4
0
 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)
Esempio n. 5
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' )
Esempio n. 6
0
 def test_stderr( self ):
     "sh writes on stderr"
     with shell() as sh:
         out = sh('echo coucou >&2')
     self.assertEqual( out.err, 'coucou' )
Esempio n. 7
0
    def test_simple_command( self ):
        "sh writes on stdout"

        with shell() as sh:
            out = sh('echo coucou')
        self.assertEqual( out.out, 'coucou' )