You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CliRunner.invoke doesn't capture stdout from logging #2761
I am hitting the issue described in that issue when using CliRunner. It is preventing me from being able to test the stdout and stderr of my click CLI commands.
The previous issue was closed with @davidism saying "Duplicate of existing issues about pretest's logging capture." Since I am unable to comment on that issue, I am creating a new one.
I would love to be pointed at the referenced duplicate issue so I can understand better what the issue and solutions are.
Ideally I would love to see some kind of workaround documented: Is there a way I can use python's builtin logging library in a way that would allow CliRunner to capture the output?
Happy to review PRs fixing this, but I haven't personally had issues with it so I'm not in the best position to investigate and fix it. Closing this as I think the existing issues cover it.
changed the title [-]CliRunner.invoke doesn't capture stdout from logging[/-][+]`CliRunner.invoke` doesn't capture `stdout` from `logging`[/+]on Apr 29, 2026
Activity
davidism commentedon Aug 8, 2024
Here are issues mentioning pytest: https://github.com/pallets/click/issues?q=is%3Aissue+pytest
Here are issues mentioning logging: https://github.com/pallets/click/issues?q=is%3Aissue+logging
Here's an open one mentioning both: #824
Happy to review PRs fixing this, but I haven't personally had issues with it so I'm not in the best position to investigate and fix it. Closing this as I think the existing issues cover it.
kdeldycke commentedon Apr 29, 2026
This is going to be addressed in v8.4.0 by #3391 which introduce a new
capture="fd"mode toCliRunner.[-]CliRunner.invoke doesn't capture stdout from logging[/-][+]`CliRunner.invoke` doesn't capture `stdout` from `logging`[/+]