Separate input from enter submission in Slack bridge

This commit is contained in:
2026-02-17 05:55:49 +09:00
parent 51e63a0f85
commit 271376a7da
5 changed files with 88 additions and 14 deletions

View File

@@ -13,11 +13,18 @@ class FakeSpawn:
def __init__(self, *_args: object, **_kwargs: object) -> None:
self.before = ""
self._alive = True
self.sent: list[str] = []
self.sentline: list[str] = []
def isalive(self) -> bool:
return self._alive
def sendline(self, _text: str) -> None:
self.sentline.append(_text)
return None
def send(self, _text: str) -> None:
self.sent.append(_text)
return None
def expect(self, *_args: object, **_kwargs: object) -> None:
@@ -82,3 +89,33 @@ def test_start_and_stop_attach(monkeypatch: pytest.MonkeyPatch):
pty.stop()
assert not pty.is_alive
def test_send_and_send_enter_are_separated(monkeypatch: pytest.MonkeyPatch):
def fake_run(
_cmd: Sequence[str],
check: bool,
capture_output: bool,
text: bool,
):
assert check is False
assert capture_output is True
assert text is True
class Result:
returncode = 0
return Result()
monkeypatch.setattr("lazy_enter.pty_manager.subprocess.run", fake_run)
monkeypatch.setattr("lazy_enter.pty_manager.pexpect.spawn", FakeSpawn)
pty = PtyManager("claude")
pty.start()
assert pty._process is not None
pty.send("status")
pty.send_enter()
assert pty._process.sent == ["status"]
assert pty._process.sentline == [""]