Skip to content

Commit 93ffccc

Browse files
committed
ControlModeEngine(types): Cast fakes to protocol in tests
why: Remove mypy assignment errors when injecting fake processes for control-mode tests. what: - Import _ControlProcess in tests and cast FakeProcess instances when assigning to engine.process - Keep protocol-typed engine.process without ignores
1 parent ffc05ed commit 93ffccc

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/test_control_mode_engine.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
import pathlib
77
import time
88
import typing as t
9+
from typing import cast
910

1011
import pytest
1112

1213
from libtmux import exc
1314
from libtmux._internal.engines.base import ExitStatus
14-
from libtmux._internal.engines.control_mode import ControlModeEngine
15+
from libtmux._internal.engines.control_mode import ControlModeEngine, _ControlProcess
1516
from libtmux._internal.engines.control_protocol import ControlProtocol
1617
from libtmux.server import Server
1718

@@ -106,7 +107,7 @@ def poll(self) -> int | None: # pragma: no cover - simple stub
106107
def fake_start(server_args: t.Sequence[str | int] | None) -> None:
107108
engine.tmux_bin = "tmux"
108109
engine._server_args = tuple(server_args or ())
109-
engine.process = fake_process
110+
engine.process = cast(_ControlProcess, fake_process)
110111

111112
monkeypatch.setattr(engine, "_start_process", fake_start)
112113

@@ -144,7 +145,7 @@ def poll(self) -> int | None:
144145
def fake_start(server_args: t.Sequence[str | int] | None) -> None:
145146
engine.tmux_bin = "tmux"
146147
engine._server_args = tuple(server_args or ())
147-
engine.process = FakeProcess()
148+
engine.process = cast(_ControlProcess, FakeProcess())
148149

149150
monkeypatch.setattr(engine, "_start_process", fake_start)
150151

@@ -265,7 +266,7 @@ def poll(self) -> int | None:
265266
return 0
266267

267268
engine = ControlModeEngine()
268-
engine.process = FakeProcess()
269+
engine.process = cast(_ControlProcess, FakeProcess())
269270

270271
with pytest.raises(case.should_raise):
271272
engine._write_line("list-sessions", server_args=())

0 commit comments

Comments
 (0)