示例#1
0
 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())
示例#2
0
 def test_has_failed_false(self):
     shell = Shell(TestShell.cmd, stdout=True)
     with patch('subprocess.check_output', return_value=''):
         self.assertFalse(shell.has_failed())
示例#3
0
 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()
示例#4
0
 def test_was_successfull_true(self):
     shell = Shell(TestShell.cmd, stdout=True)
     with patch('subprocess.check_output', return_value=''):
         self.assertTrue(shell.was_successful())
示例#5
0
 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)
示例#6
0
 def test_run_exception(self):
     shell = Shell(TestShell.cmd, stdout=True)
     exception = CalledProcessError(returncode=1, cmd='')
     with patch('subprocess.check_output', side_effect=exception):
         self.assertRaises(CalledProcessError, shell.run)
示例#7
0
 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)
示例#8
0
 def test_title(self):
     title = TestShell.cmd + 'title'
     shell = Shell(TestShell.cmd, title=title)
     self.assertEqual(title, shell.title)
示例#9
0
 def test_title_not_set_returns_command(self):
     shell = Shell(TestShell.cmd, stdout=True)
     self.assertEqual(TestShell.cmd, shell.title)
示例#10
0
 def test_stdout_false_stderr_false(self):
     shell = Shell(TestShell.cmd, stdout=False, stderr=False)
     expected = TestShell.cmd + ' 1>/dev/null 2>/dev/null'
     self.assertEqual(expected, shell.command)
示例#11
0
 def test_stdout_true_stderr_true(self):
     shell = Shell(TestShell.cmd, stdout=True, stderr=True)
     self.assertEqual(TestShell.cmd, shell.command)