示例#1
0
    def test_do_su(self, ms):
        ms.Popen = mock_popen('root')

        self.assertEqual('root', do('whoami', su=True))
        ms.Popen.assert_called_with('sudo whoami', env=None,
                                    stdout=ms.PIPE, stderr=ms.PIPE,
                                    shell=True)
示例#2
0
    def test_do_called_right(self, ms):
        ms.Popen = mock_popen('ubuntu')

        self.assertEqual('ubuntu', do('whoami', env={'HOME': 'heartis'}))
        ms.Popen.assert_called_with(['whoami'], env={'HOME': 'heartis'},
                                    stdout=ms.PIPE, stderr=ms.PIPE,
                                    shell=False)
示例#3
0
    def test_do_str(self, ms):
        ms.Popen = mock_popen('user')

        self.assertEqual('user', do('whoami'))
示例#4
0
    def test_do(self, ms):
        ms.Popen = mock_popen('user')

        self.assertEqual('user', do(['whoami']))