Skip to content

Commit e8621b7

Browse files
committed
test_server(fix[isolation]): add teardown to test_tmux_bin_custom_path
why: Every other test that manually constructs a Server uses try/finally with is_alive()/kill() for cleanup. This test was missing that pattern. what: - Wrap test body in try/finally with is_alive()/kill() cleanup - Add docstring note explaining why the server fixture is not used
1 parent b58fc2b commit e8621b7

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

tests/test_server.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,15 +423,23 @@ def test_tmux_bin_default(server: Server) -> None:
423423

424424

425425
def test_tmux_bin_custom_path(caplog: pytest.LogCaptureFixture) -> None:
426-
"""Custom tmux_bin path is used for commands."""
426+
"""Custom tmux_bin path is used for commands.
427+
428+
Uses a manual Server instance (not the ``server`` fixture) because this
429+
test must control the tmux_bin parameter at construction time.
430+
"""
427431
tmux_path = shutil.which("tmux")
428432
assert tmux_path is not None
429433
s = Server(socket_name="test_tmux_bin", tmux_bin=tmux_path)
430-
assert s.tmux_bin == tmux_path
431-
with caplog.at_level(logging.DEBUG, logger="libtmux.common"):
432-
s.cmd("list-sessions")
433-
running_records = [r for r in caplog.records if hasattr(r, "tmux_cmd")]
434-
assert any(tmux_path in r.tmux_cmd for r in running_records)
434+
try:
435+
assert s.tmux_bin == tmux_path
436+
with caplog.at_level(logging.DEBUG, logger="libtmux.common"):
437+
s.cmd("list-sessions")
438+
running_records = [r for r in caplog.records if hasattr(r, "tmux_cmd")]
439+
assert any(tmux_path in r.tmux_cmd for r in running_records)
440+
finally:
441+
if s.is_alive():
442+
s.kill()
435443

436444

437445
def test_tmux_bin_invalid_path() -> None:

0 commit comments

Comments
 (0)