Skip to content

Your lightweight open-source personal agent.

test(cli): update _make_console tests for isatty-based fix (#3265)

Alfredo Arenas2d0442976e4b
diff --git a/tests/cli/test_cli_input.py b/tests/cli/test_cli_input.py
index b772293bc..0e1235b86 100644
--- a/tests/cli/test_cli_input.py
+++ b/tests/cli/test_cli_input.py
@@ -167,7 +167,19 @@ def test_stream_renderer_stop_for_input_stops_spinner():
spinner.stop.assert_called_once()
-def test_make_console_uses_force_terminal():
- """Console should be created with force_terminal=True for proper ANSI handling."""
- console = stream_mod._make_console()
- assert console._force_terminal is True
+def test_make_console_force_terminal_when_stdout_is_tty():
+ """Console should set force_terminal=True when stdout is a TTY (rich output)."""
+ import sys
+ with patch.object(sys.stdout, "isatty", return_value=True):
+ console = stream_mod._make_console()
+ assert console._force_terminal is True
+
+
+def test_make_console_force_terminal_false_when_stdout_is_not_tty():
+ """Console should set force_terminal=False when stdout is not a TTY so that
+ ANSI escape codes (cursor visibility, braille spinner frames) don't pollute
+ piped output such as `docker exec -i` (#3265)."""
+ import sys
+ with patch.object(sys.stdout, "isatty", return_value=False):
+ console = stream_mod._make_console()
+ assert console._force_terminal is False