Skip to content

Force rich non-terminal output in tests - #4081

Open
r4victor wants to merge 1 commit into
masterfrom
pr_tty_compatible_for_tests
Open

Force rich non-terminal output in tests#4081
r4victor wants to merge 1 commit into
masterfrom
pr_tty_compatible_for_tests

Conversation

@r4victor

@r4victor r4victor commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Fixes CLI tests failing for coding agents (and confusing them), which may run with FORCE_COLOR=3 set. rich then colorizes even though stdout is a pipe, so assertions on plain CLI text see ANSI escapes. The same tests pass in a normal terminal and in CI, where FORCE_COLOR is unset.

Two tests were affected, both asserting on "Usage: dstack":

  • TestDstack::test_prints_help_and_exists_with_0_exit_code
  • TestAgentIsolation::test_creates_private_cli_home_and_dstack_wrapper

DSTACK_CLI_RICH_FORCE_TERMINAL=0 could not prevent this: it only reaches the consoles dstack constructs, and --help is rendered by a console rich_argparse creates internally. TTY_COMPATIBLE=0 applies to every rich console in the process and is checked ahead of FORCE_COLOR, so it also covers dstack's own consoles. That makes DSTACK_CLI_RICH_FORCE_TERMINAL redundant, so it is removed - it was only ever added to keep control characters out of test output (0256b62) and is undocumented.

Verified: full suite green with FORCE_COLOR=3 still set (3271 passed, 1735 skipped); previously 2 failed in the same environment.

AI assistance: written with Claude Code.

Coding agents run with FORCE_COLOR set, which makes rich colorize even when
stdout is a pipe, so CLI tests asserting on plain text failed for agents while
passing locally and in CI. DSTACK_CLI_RICH_FORCE_TERMINAL could not prevent it
because rich_argparse builds its own console for --help that dstack never
constructs. TTY_COMPATIBLE=0 covers every rich console in the process and takes
precedence over FORCE_COLOR, which makes the dstack-specific setting redundant.
@r4victor r4victor changed the title Pin rich to non-terminal output in tests Force rich non-terminal output in tests Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant