44
55import io
66import pathlib
7- import subprocess
87import time
98import typing as t
109
@@ -86,6 +85,7 @@ def __init__(self) -> None:
8685 self .stdout = BlockingStdout ()
8786 self .stderr = None
8887 self ._terminated = False
88+ self .pid = 1234
8989
9090 def terminate (self ) -> None : # pragma: no cover - simple stub
9191 self ._terminated = True
@@ -96,14 +96,17 @@ def kill(self) -> None: # pragma: no cover - simple stub
9696 def wait (self , timeout : float | None = None ) -> None : # pragma: no cover
9797 return None
9898
99+ def poll (self ) -> int | None : # pragma: no cover - simple stub
100+ return 0
101+
99102 engine = ControlModeEngine (command_timeout = 0.01 )
100103
101104 fake_process = FakeProcess ()
102105
103106 def fake_start (server_args : t .Sequence [str | int ] | None ) -> None :
104107 engine .tmux_bin = "tmux"
105108 engine ._server_args = tuple (server_args or ())
106- engine .process = t . cast ( subprocess . Popen [ str ], fake_process )
109+ engine .process = fake_process
107110
108111 monkeypatch .setattr (engine , "_start_process" , fake_start )
109112
@@ -122,6 +125,7 @@ def __init__(self) -> None:
122125 self .stdout : t .Iterator [str ] = iter ([]) # no output
123126 self .stderr = None
124127 self ._terminated = False
128+ self .pid = 5678
125129
126130 def terminate (self ) -> None :
127131 self ._terminated = True
@@ -132,12 +136,15 @@ def kill(self) -> None:
132136 def wait (self , timeout : float | None = None ) -> None :
133137 return None
134138
139+ def poll (self ) -> int | None :
140+ return 0
141+
135142 engine = ControlModeEngine (command_timeout = 5.0 )
136143
137144 def fake_start (server_args : t .Sequence [str | int ] | None ) -> None :
138145 engine .tmux_bin = "tmux"
139146 engine ._server_args = tuple (server_args or ())
140- engine .process = t . cast ( subprocess . Popen [ str ], FakeProcess () )
147+ engine .process = FakeProcess ()
141148
142149 monkeypatch .setattr (engine , "_start_process" , fake_start )
143150
@@ -243,6 +250,7 @@ class FakeProcess:
243250 def __init__ (self ) -> None :
244251 self .stdin = FakeStdin ()
245252 self ._terminated = False
253+ self .pid = 9999
246254
247255 def terminate (self ) -> None :
248256 self ._terminated = True
@@ -253,8 +261,11 @@ def kill(self) -> None: # pragma: no cover - simple stub
253261 def wait (self , timeout : float | None = None ) -> None :
254262 return None
255263
264+ def poll (self ) -> int | None :
265+ return 0
266+
256267 engine = ControlModeEngine ()
257- engine .process = FakeProcess () # type: ignore[assignment]
268+ engine .process = FakeProcess ()
258269
259270 with pytest .raises (case .should_raise ):
260271 engine ._write_line ("list-sessions" , server_args = ())
0 commit comments