moo.shell.tests.test_prompt_io

Tests for the prompt’s outbound rendering and wire-format behaviour.

Covers _make_key_bindings, writer() in rich/raw modes, OSC 133 prompt markers, generate_prompt(), the IAC prompt-end marker (EOR/GA/no-op), and the “oob” route_event path.

Functions

test_generate_prompt_is_stable_marker()

The prompt is a single stable marker.

test_generate_prompt_no_location_still_stable()

The prompt does not change shape when the avatar has no location.

test_make_key_bindings_returns_keybindings()

_make_key_bindings() returns a KeyBindings with one binding per PROMPT_SHORTCUT entry.

test_osc133_disabled_for_iac_sessions()

MUD-client (IAC-enabled) sessions skip OSC 133 wrapping — Mudlet doesn't parse OSC 133 and the BEL-terminated frames swallow the trailing IAC GA, breaking the mapper's prompt-line detection.

test_osc133_enabled_for_vanilla_ssh()

Vanilla SSH sessions retain OSC 133 wrapping (the default).

test_prompt_end_marker_defaults_to_ga_for_iac_sessions()

When the session is IAC-enabled but EOR was not negotiated, the prompt-end marker defaults to IAC GA — the MUD convention; Mudlet's mapper relies on it for prompt boundary detection.

test_prompt_end_marker_emits_eor_when_negotiated()

After a prompt render, IAC EOR goes to the channel when the client negotiated EOR.

test_prompt_end_marker_noop_for_vanilla_ssh()

No IAC bytes are emitted when the session is not IAC-enabled.

test_route_event_oob_writes_iac_bytes_via_surrogate_str()

The "oob" event hands raw IAC bytes to _chan_write_iac, which converts them to surrogate-escaped str so the channel's UTF-8 encoder re-emits the original bytes on the wire.

test_shortcut_handler_cursor_at_end_when_no_percent()

Shortcut handler places the cursor at the end of the text when the template contains no %.

test_shortcut_handler_expands_with_cursor_at_percent()

Shortcut handler replaces the buffer with the template text and places the cursor at the % position.

test_writer_raw_mode_rich_capture_preserves_colour()

writer() in raw mode writes SGR escape sequences to the channel for styled markup.

test_writer_raw_mode_writes_to_chan()

writer() bypasses print_formatted_text and writes directly to the SSH channel in raw mode.

test_writer_rich_mode_uses_print_formatted_text()

writer() passes rendered ANSI output to print_formatted_text in rich mode.