Bug 1890277: part 4) Add CSPParser support for the `trusted-types` directive, guarded...
[gecko.git] / testing / mozbase / mozrunner / tests / test_start.py
blob56e01ae84d10a95b5f5f6e7e4eb0ff59dc2eb083
1 #!/usr/bin/env python
3 from time import sleep
4 from unittest.mock import patch
6 import mozunit
7 from mozrunner import RunnerNotStartedError
8 from pytest import raises
11 def test_start_process(runner):
12 """Start the process and test properties"""
13 assert runner.process_handler is None
15 runner.start()
17 assert runner.is_running()
18 assert runner.process_handler is not None
21 def test_start_process_called_twice(runner):
22 """Start the process twice and test that first process is gone"""
23 runner.start()
24 # Bug 925480
25 # Make a copy until mozprocess can kill a specific process
26 process_handler = runner.process_handler
28 runner.start()
30 try:
31 assert process_handler.wait(1) not in [None, 0]
32 finally:
33 process_handler.kill()
36 def test_start_with_timeout(runner):
37 """Start the process and set a timeout"""
38 runner.start(timeout=0.1)
39 sleep(1)
41 assert not runner.is_running()
44 def test_start_with_outputTimeout(runner):
45 """Start the process and set a timeout"""
46 runner.start(outputTimeout=0.1)
47 sleep(1)
49 assert not runner.is_running()
52 def test_fail_to_start(runner):
53 with patch("mozprocess.ProcessHandler.__init__") as ph_mock:
54 ph_mock.side_effect = Exception("Boom!")
55 with raises(RunnerNotStartedError):
56 runner.start(outputTimeout=0.1)
57 sleep(1)
60 if __name__ == "__main__":
61 mozunit.main()