4 from unittest
.mock
import patch
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
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"""
25 # Make a copy until mozprocess can kill a specific process
26 process_handler
= runner
.process_handler
31 assert process_handler
.wait(1) not in [None, 0]
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)
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)
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)
60 if __name__
== "__main__":