Skip to content

Commit 03fe61d

Browse files
committed
libtmux(test[logging]): add logging schema test
why: Verify structured logging contract per AGENTS.md testing standards. what: - Add test_tmux_cmd_debug_logging_schema asserting tmux_cmd and tmux_exit_code extra fields on log records from common.tmux_cmd - Uses caplog.records attributes (not caplog.text) per standards
1 parent c1ed3e5 commit 03fe61d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

tests/test_logging.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""Tests for libtmux logging standards compliance."""
2+
3+
from __future__ import annotations
4+
5+
import logging
6+
import typing as t
7+
8+
import pytest
9+
10+
if t.TYPE_CHECKING:
11+
from libtmux.server import Server
12+
13+
14+
def test_tmux_cmd_debug_logging_schema(
15+
server: Server,
16+
caplog: pytest.LogCaptureFixture,
17+
) -> None:
18+
"""Test that tmux_cmd produces structured log records per AGENTS.md."""
19+
with caplog.at_level(logging.DEBUG, logger="libtmux.common"):
20+
server.cmd("list-sessions")
21+
records = [r for r in caplog.records if hasattr(r, "tmux_cmd")]
22+
assert len(records) >= 1
23+
record = records[0]
24+
assert isinstance(getattr(record, "tmux_cmd"), str)
25+
assert isinstance(getattr(record, "tmux_exit_code"), int)

0 commit comments

Comments
 (0)