Skip to content

Fix capture asymmetry in suspend_global_capture(in_=True)#14356

Open
FazeelUsmani wants to merge 4 commits intopytest-dev:mainfrom
FazeelUsmani:fix-13322-capture-suspend-asymmetry
Open

Fix capture asymmetry in suspend_global_capture(in_=True)#14356
FazeelUsmani wants to merge 4 commits intopytest-dev:mainfrom
FazeelUsmani:fix-13322-capture-suspend-asymmetry

Conversation

@FazeelUsmani
Copy link
Copy Markdown
Contributor

@FazeelUsmani FazeelUsmani commented Apr 6, 2026

Fixes #13322.

If a plugin hook suspends out/err and then calls suspend_global_capture(in_=True) (e.g. to read input), the matching resume_global_capture() was incorrectly re-enabling out/err even though the caller had them suspended. Fix is to remember what was started before the nested suspend and only resume those.

Includes a pytester regression that runs the flow from a pytest_terminal_summary hook and checks that the print after the resume reaches stdout before the 1 passed line. Before the fix it only shows up at teardown, after the summary.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Apr 6, 2026
@FazeelUsmani FazeelUsmani marked this pull request as draft April 6, 2026 11:44
@FazeelUsmani FazeelUsmani marked this pull request as ready for review April 6, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

calling capture.resume_global_capture() changes the used terminal width

1 participant