Fix resize and poller races; add coverage

- Fix resize message handling when session already exists
- Guard poller selector.modify against removed fds
- Handle send_bytes race when master_fd closes
- Add tests for resize edge case, poller write KeyError, send_bytes race
This commit is contained in:
GitHub Copilot
2026-01-26 20:07:40 +00:00
parent 245849ba9f
commit 63e8cba0ac
6 changed files with 56 additions and 6 deletions
+12
View File
@@ -288,6 +288,18 @@ class TestTerminalSession:
mock_exit.assert_called_once_with(1)
@pytest.mark.asyncio
async def test_send_bytes_handles_closed_fd(self):
from textual_webterm.terminal_session import TerminalSession
poller = MagicMock()
poller.write = AsyncMock(side_effect=KeyError)
session = TerminalSession(poller, "sid", "bash")
session.master_fd = 10
ok = await session.send_bytes(b"test")
assert ok is False
@pytest.mark.asyncio
async def test_run_reads_from_poller_and_closes(self):
from textual_webterm.terminal_session import TerminalSession