✨ feat(cli): add --no-capture flag for interactive programs#3777
Merged
gaborbernat merged 3 commits intotox-dev:mainfrom Feb 19, 2026
Merged
✨ feat(cli): add --no-capture flag for interactive programs#3777gaborbernat merged 3 commits intotox-dev:mainfrom
gaborbernat merged 3 commits intotox-dev:mainfrom
Conversation
7e23ca8 to
5cd6533
Compare
5cd6533 to
8059d77
Compare
8059d77 to
a7d0944
Compare
Interactive programs like Python REPL need direct terminal access to query console dimensions and handle user input. Tox normally pipes stdout/stderr for output capture, giving subprocesses pipe handles instead of console handles. This causes Python 3.13+ REPL to crash on Windows with WinError 123 when _pyrepl/windows_console.py calls Win32 APIs that require real console buffers. Add --no-capture (-i) CLI flag that makes subprocesses inherit parent console handles instead of using pipes. This is opt-in because it's mutually exclusive with result logging (--result-json) and parallel mode where output capture is essential. The flag is platform-independent since terminal APIs need console handles on all platforms, not just Windows. Validates incompatible flag combinations early with clear error messages.
a7d0944 to
8d017eb
Compare
Test failures occurred because MagicMock objects return new MagicMock instances for undefined attributes, which evaluate to True. When tests accessed `env.options.no_capture` on mocked environments, this truthy mock caused subprocesses to inherit console handles instead of capturing output, breaking assertions that expected captured stdout/stderr. Explicitly set `no_capture = False` on all mock tox environments to ensure output capture behaves correctly in tests. Also updated test expectations to include the no_capture field now present in parsed options for commands that support environment arguments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Interactive programs like Python REPL, debuggers, and TUI applications need direct terminal access to work correctly. They query console dimensions, set raw mode for keystroke input, and send VT100 escape sequences for cursor control. 🐛 Tox normally pipes stdout/stderr to capture output for logging and result reporting, but this breaks terminal APIs that require real console handles instead of pipe handles. Python 3.13+ REPL crashes on Windows with
WinError 123when_pyrepl/windows_console.pytries to call Win32 APIs that only work on console buffers, and similar failures occur on other platforms when programs try to query terminal properties.The new
--no-capture(-i) flag disables output capture and makes subprocesses inherit parent console handles directly. ✨ This is opt-in because it's mutually exclusive with--result-jsonwhere output must be captured, and parallel mode where output from multiple environments would interleave. The implementation validates incompatible flag combinations early with clear error messages. Additionally,tox execnow always runs withno_captureenabled since it's designed for one-off interactive commands, and the flag is hidden from its help output to avoid confusion.The flag works on all platforms since terminal APIs universally require console handles, not just on Windows. Documentation has been added to both the how-to guide for practical usage and the explanation section to clarify why interactive terminal programs need special handling.