Exemplo n.º 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())
Exemplo n.º 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())
Exemplo n.º 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()
Exemplo n.º 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())
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 8
0
 def test_title(self):
     title = TestShell.cmd + 'title'
     shell = Shell(TestShell.cmd, title=title)
     self.assertEqual(title, shell.title)
Exemplo n.º 9
0
 def test_title_not_set_returns_command(self):
     shell = Shell(TestShell.cmd, stdout=True)
     self.assertEqual(TestShell.cmd, shell.title)
Exemplo n.º 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)
Exemplo n.º 11
0
 def test_stdout_true_stderr_true(self):
     shell = Shell(TestShell.cmd, stdout=True, stderr=True)
     self.assertEqual(TestShell.cmd, shell.command)