Пример #1
0
 def test_exit_process_when_no_more_output_is_generated(self, mock_os):
     mock_os.read.return_value = ""
     execute = Execute(['echo'], use_pty=True)
     execute.run()
     self.assertTrue(mock_os.close.called)
     self.assertNotEqual(None, execute.poll())
Пример #2
0
 def test_EIO_do_not_raise_exception(self, mock_os):
     execute = Execute(['echo'], use_pty=True)
     mock_os.read.side_effect = IOError(EIO, None)
     execute.run()
     self.assertTrue(mock_os.read.called)
Пример #3
0
 def test_non_EIO_raises_exception(self, mock_os):
     execute = Execute(['echo'], use_pty=True)
     mock_os.read.side_effect = IOError("test")
     with self.assertRaises(IOError):
         execute.run()
Пример #4
0
 def test_execute_without_pty(self):
     execute = Execute(['echo', 'helpers'])
     execute.run()
     self.assertTrue('helpers' in str(execute.output()))
Пример #5
0
 def test_parser_is_called_to_generate_output(self):
     parser = Mock()
     execute = Execute(['echo', 'test'], parser)
     execute.run()
     parser.parse.assert_called_with('test\n')
Пример #6
0
 def test_exit_process_when_no_more_output_is_generated(self, mock_os):
     mock_os.read.return_value = ""
     execute = Execute(['echo'], use_pty=True)
     execute.run()
     self.assertTrue(mock_os.close.called)
     self.assertNotEqual(None, execute.poll())
Пример #7
0
 def test_non_EIO_raises_exception(self, mock_os):
     execute = Execute(['echo'], use_pty=True)
     mock_os.read.side_effect = IOError("test")
     with self.assertRaises(IOError):
         execute.run()
Пример #8
0
 def test_EIO_do_not_raise_exception(self, mock_os):
     execute = Execute(['echo'], use_pty=True)
     mock_os.read.side_effect = IOError(EIO, None)
     execute.run()
     self.assertTrue(mock_os.read.called)
Пример #9
0
 def test_parser_is_called_to_generate_output(self):
     parser = Mock()
     execute = Execute(['echo', 'test'], parser)
     execute.run()
     parser.parse.assert_called_with('test\n')
Пример #10
0
 def test_execute_without_pty(self):
     execute = Execute(['echo', 'helpers'])
     execute.run()
     self.assertTrue('helpers' in str(execute.output()))