Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a03397-4d51-7fd1-8ff2-946eb22ea2bc
This commit is contained in:
parent
2009d01ae4
commit
452235a01f
6 changed files with 133 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ import pty
|
|||
import struct
|
||||
import termios
|
||||
|
||||
from tamq.ptytap import PtyTap, copy_winsize, write_all
|
||||
from tamq.ptytap import PtyTap, copy_winsize, observed_line, write_all
|
||||
|
||||
|
||||
class RecordingBroker:
|
||||
|
|
@ -29,6 +29,48 @@ def test_input_observer_accepts_raw_terminal_carriage_returns():
|
|||
assert observed == ["#activity-core: hello"]
|
||||
|
||||
|
||||
def test_input_observer_accepts_enhanced_terminal_enter_sequences():
|
||||
broker = RecordingBroker()
|
||||
observed = []
|
||||
tap = PtyTap(["true"], broker, on_line=observed.append)
|
||||
buffer = bytearray()
|
||||
|
||||
tap._observe_input(buffer, b"#activity-core: CSI-u\x1b[13;1")
|
||||
assert broker.lines == []
|
||||
tap._observe_input(buffer, b":1u#other: modify\x1b[27;1;13~")
|
||||
tap._observe_input(buffer, b"plain\x1bOM")
|
||||
|
||||
assert broker.lines == [
|
||||
"#activity-core: CSI-u",
|
||||
"#other: modify",
|
||||
"plain",
|
||||
]
|
||||
assert observed == ["#activity-core: CSI-u", "#other: modify"]
|
||||
|
||||
|
||||
def test_input_observer_ignores_terminal_replies_before_typed_line():
|
||||
broker = RecordingBroker()
|
||||
observed = []
|
||||
tap = PtyTap(["true"], broker, on_line=observed.append)
|
||||
buffer = bytearray()
|
||||
|
||||
tap._observe_input(buffer, b"\x1b[9;1R\x1b[?1;2;4c")
|
||||
tap._observe_input(buffer, b"#activity-core: Helol\x7f\x7flo\r")
|
||||
|
||||
assert broker.lines == ["#activity-core: Hello"]
|
||||
assert observed == ["#activity-core: Hello"]
|
||||
|
||||
|
||||
def test_observed_line_removes_common_terminal_protocol_wrappers():
|
||||
raw = (
|
||||
b"\x1b[200~#target: pasted\x1b[201~"
|
||||
b"\x1b]10;rgb:ffff/ffff/ffff\x07"
|
||||
b"\x1bP1$r0m\x1b\\"
|
||||
)
|
||||
|
||||
assert observed_line(raw) == "#target: pasted"
|
||||
|
||||
|
||||
def test_copy_winsize_preserves_rows_columns_and_pixels():
|
||||
source_master, source_slave = pty.openpty()
|
||||
target_master, target_slave = pty.openpty()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue