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)
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)
def test_do_str(self, ms): ms.Popen = mock_popen('user') self.assertEqual('user', do('whoami'))
def test_do(self, ms): ms.Popen = mock_popen('user') self.assertEqual('user', do(['whoami']))