def test_has_successfull_false(self): shell = Shell(TestShell.cmd, stdout=True) exception = CalledProcessError(returncode=1, cmd='') with patch('subprocess.check_output', side_effect=exception): self.assertFalse(shell.was_successful())
def test_was_successfull_true(self): shell = Shell(TestShell.cmd, stdout=True) with patch('subprocess.check_output', return_value=''): self.assertTrue(shell.was_successful())
def test_run_pos_is_called_once(self): shell = Shell(TestShell.cmd, stdout=True) shell.run_pos = Mock() with patch('subprocess.check_output', return_value=''): shell.run() shell.run_pos.assert_called_once_with()
def test_run_without_output(self): shell = Shell(TestShell.cmd, stdout=False, stderr=False) expected = 0 with patch('subprocess.call', return_value=expected): actual = shell.run() self.assertEqual(expected, actual)
def test_run_with_stdout_stderr(self): shell = Shell(TestShell.cmd, stdout=True, stderr=True) expected = 'output' with patch('subprocess.check_output', return_value=expected): actual = shell.run() self.assertEqual(expected, actual)
def test_has_failed_false(self): shell = Shell(TestShell.cmd, stdout=True) with patch('subprocess.check_output', return_value=''): self.assertFalse(shell.has_failed())