@@ -29,13 +29,25 @@ def test_send_signal(
2929 mock_kill .assert_called_once_with (PID_RUNNING , signal .SIGTERM )
3030
3131 if sys .platform != "win32" :
32+ gid = 100
33+ mocker .patch ("os.getpgid" , return_value = gid )
3234 mock_killpg = mocker .patch ("os.killpg" )
3335 process_manager .send_signal (running_process , signal .SIGINT , True )
34- mock_killpg .assert_called_once_with (PID_RUNNING , signal .SIGINT )
36+ mock_killpg .assert_called_once_with (gid , signal .SIGINT )
37+ else :
38+ mock_kill .reset_mock ()
39+ process_manager .send_signal (
40+ running_process ,
41+ signal .CTRL_C_EVENT , # pylint: disable=no-member
42+ True ,
43+ )
44+ mock_kill .assert_called_once_with (
45+ PID_RUNNING , signal .CTRL_C_EVENT # pylint: disable=no-member
46+ )
3547
3648 mock_kill .reset_mock ()
3749 with pytest .raises (ProcessLookupError ):
38- process_manager .send_signal (finished_process , signal .SIGTERM )
50+ process_manager .send_signal (finished_process , signal .SIGTERM , False )
3951 mock_kill .assert_not_called ()
4052
4153 if sys .platform == "win32" :
@@ -59,39 +71,42 @@ def side_effect(*args):
5971
6072 mocker .patch ("os.kill" , side_effect = side_effect )
6173 with pytest .raises (ProcessLookupError ):
62- process_manager .send_signal (running_process , signal .SIGTERM )
74+ process_manager .send_signal (running_process , signal .SIGTERM , False )
6375 assert process_manager [running_process ].returncode == - 1
6476
6577 with pytest .raises (ProcessLookupError ):
66- process_manager .send_signal ("nonexists" , signal .SIGTERM )
78+ process_manager .send_signal ("nonexists" , signal .SIGTERM , False )
6779
6880
6981if sys .platform == "win32" :
7082 SIGKILL = signal .SIGTERM
83+ SIGINT = signal .CTRL_C_EVENT # pylint: disable=no-member
7184else :
7285 SIGKILL = signal .SIGKILL # pylint: disable=no-member
86+ SIGINT = signal .SIGINT
7387
7488
7589@pytest .mark .parametrize (
76- "method, sig" ,
90+ "method, sig, group " ,
7791 [
78- ("kill" , SIGKILL ),
79- ("terminate" , signal .SIGTERM ),
80- ("interrupt" , signal . SIGINT ),
92+ ("kill" , SIGKILL , False ),
93+ ("terminate" , signal .SIGTERM , False ),
94+ ("interrupt" , SIGINT , True ),
8195 ],
8296)
8397def test_kill_commands (
8498 mocker : MockerFixture ,
8599 process_manager : ProcessManager ,
86100 method : str ,
87101 sig : signal .Signals ,
102+ group : bool ,
88103):
89104 """Test shortcut for different signals."""
90105 name = "process"
91106 mock_kill = mocker .patch .object (process_manager , "send_signal" )
92107 func = getattr (process_manager , method )
93108 func (name )
94- mock_kill .assert_called_once_with (name , sig , True )
109+ mock_kill .assert_called_once_with (name , sig , group )
95110
96111
97112def test_remove (
0 commit comments