def test_run_executable_with_stream(self): with mock.patch('kb_python.utils.logger.debug') as debug_mock: utils.run_executable(['echo', 'TEST'], stream=True) debug_mock.assert_has_calls([call('TEST')])
def test_run_executable_no_wait(self): with mock.patch('kb_python.utils.sp') as sp_mock: sp_mock.Popen().returncode = 0 utils.run_executable(['echo', 'TEST'], wait=False) sp_mock.Popen().poll.assert_not_called()
def test_run_exectuable_with_returncode(self): utils.run_executable(['bash', 'nonexistent option'], returncode=127)
def test_run_exectuable_raises_exception(self): with self.assertRaises(sp.SubprocessError): utils.run_executable(['bash', 'nonexistent option'])
def test_run_executable(self): with mock.patch('kb_python.utils.STATS') as STATS: p = utils.run_executable(['echo', 'TEST'], stream=False) self.assertEqual(p.stdout.read(), 'TEST\n') STATS.command.assert_called_once_with(['echo', 'TEST'], runtime=ANY)
def test_run_executable(self): p = utils.run_executable(['echo', 'TEST'], stream=False) self.assertEqual(p.stdout.read(), 'TEST\n')