Test if a process is running

This commit is contained in:
Jake Howard 2018-12-13 11:36:04 +00:00
parent 1d32eeb24a
commit 31b1bc957c
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -33,3 +33,14 @@ class TerminateProcessesTestCase(BaseTestCase):
self.assertIsNone(still_alive) self.assertIsNone(still_alive)
for proc in created_processes: for proc in created_processes:
self.assertEqual(proc.poll(), 0) self.assertEqual(proc.poll(), 0)
class RunningProcessTestCase(BaseTestCase):
def test_current_process_running(self):
self.assertTrue(processes.is_process_running(os.getpid()))
def test_root_process_running(self):
self.assertTrue(processes.is_process_running(processes.get_root_process().pid))
def test_impossible_running_process(self):
self.assertFalse(processes.is_process_running(2938420983094892))