Debian Codegraph @

testing/mozbase/mozprocess/tests/test_pid.py

raw
1 #!/usr/bin/env python
2
3 import os
4
5 import mozunit
6 import proctest
7 from mozprocess import processhandler
8
9 here = os.path.dirname(os.path.abspath(__file__))
10
11
12 class ProcTestPid(proctest.ProcTest):
13 """Class to test process pid."""
14
15 def test_pid_before_run(self):
16 """Process is not started, and pid is checked."""
17 p = processhandler.ProcessHandler([self.python])
18 with self.assertRaises(RuntimeError):
19 p.pid
20
21 def test_pid_while_running(self):
22 """Process is started, and pid is checked."""
23 p = processhandler.ProcessHandler(
24 [self.python, self.proclaunch, "process_normal_finish.ini"], cwd=here
25 )
26 p.run()
27
28 self.assertIsNotNone(p.pid)
29
30 self.determine_status(p, True)
31 p.kill()
32
33 def test_pid_after_kill(self):
34 """Process is killed, and pid is checked."""
35 p = processhandler.ProcessHandler(
36 [self.python, self.proclaunch, "process_normal_finish.ini"], cwd=here
37 )
38 p.run()
39 p.kill()
40
41 self.assertIsNotNone(p.pid)
42 self.determine_status(p)
43
44
45 if __name__ == "__main__":
46 mozunit.main()