Add opt-in debug logging across the CLI pipeline
Thread RP_DEBUG-driven logging through input, detection, rendering, and pager decisions so CLI behavior is inspectable without polluting stdout. Add focused coverage for debug wiring, env parsing, and stderr-only output.
This commit is contained in:
@@ -25,6 +25,14 @@ class TestMouseCapableLess:
|
||||
with patch("rp.pager.shutil.which", return_value=None):
|
||||
assert _mouse_capable_less() is None
|
||||
|
||||
def test_logs_less_not_found(self) -> None:
|
||||
messages: list[str] = []
|
||||
|
||||
with patch("rp.pager.shutil.which", return_value=None):
|
||||
assert _mouse_capable_less(messages.append) is None
|
||||
|
||||
assert messages == ["pager: 'less' was not found"]
|
||||
|
||||
def test_returns_none_when_less_too_old(self) -> None:
|
||||
with patch("rp.pager.shutil.which", return_value="/usr/bin/less"):
|
||||
mock_result = MagicMock()
|
||||
@@ -99,6 +107,19 @@ class TestMousePager:
|
||||
|
||||
mock_instance.show.assert_called_once_with("content")
|
||||
|
||||
def test_logs_system_pager_fallback(self) -> None:
|
||||
messages: list[str] = []
|
||||
pager = MousePager(debug=messages.append)
|
||||
|
||||
with patch("rp.pager._mouse_capable_less", return_value=None):
|
||||
with patch("rp.pager.SystemPager") as mock_system_pager:
|
||||
mock_instance = MagicMock()
|
||||
mock_system_pager.return_value = mock_instance
|
||||
|
||||
pager.show("content")
|
||||
|
||||
assert messages == ["pager: falling back to Rich's SystemPager"]
|
||||
|
||||
def test_uses_less_when_available(self) -> None:
|
||||
pager = MousePager()
|
||||
mock_result = MagicMock()
|
||||
|
||||
Reference in New Issue
Block a user