def test_get_pids_no_process(self): kill = Kill() with patch('utility.check_output', autospec=True, side_effect=CalledProcessError(1, 'pidof fake')) as mock: pids = kill.get_pids('fake') self.assertEqual(pids, None) mock.assert_called_once_with(['pidof', 'fake'])
def test_get_pids(self): kill = Kill() with patch('utility.check_output', autospec=True, return_value='1234 2345\n') as mock: pids = kill.get_pids('jujud') self.assertEqual(pids, ['1234', '2345']) mock.assert_called_once_with(['pidof', 'jujud'])