hermes-agent/tests/hermes_cli/test_cli_terminal_response_sanitizer.py
teknium1 d09dacf66a test: purge low-value tests, lane py10 (412 removed)
Change-detectors, tautologies, source-reading tests, redundant duplicates,
mock-echo tests and dead/unrunnable tests. Per-test rationale in the lane
ledger (category + reason for every removal).
2026-09-23 03:15:26 -07:00

40 lines
1 KiB
Python

"""Tests for defensive terminal control-response stripping in the CLI.
Covers Cursor Position Report (CPR / DSR) responses that occasionally
leak into the input buffer after terminal resize storms or multiplexer
tab switches — see issue #14692.
"""
from cli import _strip_leaked_terminal_responses_with_meta
def _strip_leaked_terminal_responses(text: str) -> str:
cleaned, _ = _strip_leaked_terminal_responses_with_meta(text)
return cleaned
class TestStripLeakedTerminalResponses:
def test_strips_multiple_dsr_responses(self):
text = "a\x1b[53;1Rb\x1b[51;1Rc\x1b[50;9Rd"
assert _strip_leaked_terminal_responses(text) == "abcd"
def test_strips_sgr_mouse_report_with_large_coordinates(self):
text = "abc\x1b[<10000;12345;98765Mdef"
assert _strip_leaked_terminal_responses(text) == "abcdef"
def test_strips_multiple_concatenated_sgr_mouse_reports(self):
text = "<65;1;49M<35;1;42Mhello<64;1;40m"
assert _strip_leaked_terminal_responses(text) == "hello"